2,718
社区成员
发帖
与我相关
我的任务
分享
#define WM_CHAR 0x0102
Declare Long FindWindowEx in win32api Long, Long, String, String
Declare Long SendMessage in win32api Long, Long, Long, Long
m.hWnd = FindWindowEx(0, 0, 'Notepad', Null)
If m.hWnd == 0
MessageBox('先打开一个空记事本')
Return .f.
EndIf
m.hEdit = FindWindowEx(m.hWnd, 0, 'Edit', Null)
If m.hEdit == 0
? '没找到记事本编辑区'
Return .f.
EndIf
m.cTime = Time() + 0h0d0a && 写入当前时间字符串
For m.ii = 1 to Len(m.cTime)
m.cc = Substr(m.cTime, m.ii, 1)
SendMessage(m.hEdit, WM_CHAR, Asc(m.cc), 0)
EndFor
Declare long AttachThreadInput In user32.dll long,long,integer && 连接线程输入
Declare long GetForegroundWindow In user32.dll && 获得当前顶层窗口句柄
Declare long GetCurrentThreadId In kernel32.dll && 获取当前进程ID
Declare integer GetWindowThreadProcessId In user32.dll long ,long @ && 获取创建制定窗口的进程ID
Declare long SetForegroundWindow In user32.dll long &&设置顶层窗口
Declare integer GetLastError In kernel32.dll
Declare integer FindWindow In user32.dll string @ ,string @
*****************引用你3楼的代码*************
DECLARE INTEGER ShellExecute IN shell32.DLL INTEGER HWND,STRING lpszOP,STRING lpszFile,STRING lpszParams,STRING lpszDir,INTEGER fsshowcmd
DECLARE INTEGER GetDesktopWindow IN win32api
HWND = GetDesktopWindow()
lpszOP = "open"
* ?????????
lpszFile ="C:\WINDOWS\system32\notepad.exe"
lpszParams = ""
lpszDir = "c:\temp"
fsshowcmd = 1
* ??ShellExecute??
LNRETURN = ShellExecute(HWND, lpszOP,lpszFile, lpszParams, lpszDir,fsshowcmd)
*********************************************
Inkey(3)
lnNotepad = FindWindow("Notepad","无标题 - 记事本")
lnNotepadId = 0 &&记事本窗口进程id
lnMyId = 0&&当前进程id
GetWindowThreadProcessId(lnNotepad ,@lnNotepadId)
AttachThreadInput(GetWindowThreadProcessId(lnNotepad ,@lnNotepadId),GetCurrentThreadId(),1)&&共享进程
SetForegroundWindow(thisform.HWnd)
mykeybd(98) &&将你一楼的代码保存为mykeybd.prg
AttachThreadInput(GetWindowThreadProcessId(lnNotepad ,@lnNotepadId),GetCurrentThreadId(),0)&& 撤销共享