以下是引用kesc在2020-7-22 23:31:12的发言:
不行啊,我自己添加的第一句就出错
DECLARE integer Findwindow IN WIN32API string,string
mhandle=findwindow(0,'记事本')
=showwindow(mhandle,1)
declare keybd_event in win32api short bvk,short bscan,integer dwflags,integer deextrainfo
_cliptext='VFP编程论坛'
keybd_event(17,0,0,0)
keybd_event(asc('V'),0,0,0)
keybd_event(asc('V'),0,2,0)
keybd_event(17,0,2,0)
API函数声明要区分大小写
DECLARE integer FindWindow IN WIN32API string,string
showwindow未声明(ShowWindow)
试试:
DECLARE LONG FindWindow IN user32 STRING@,STRING@
DECLARE LONG SetWindowPos IN user32 LONG,LONG,LONG,LONG,LONG,LONG,LONG
DECLARE LONG SetFocus IN user32 LONG
DECLARE LONG keybd_event IN user32 LONG,LONG,LONG,LONG
cWindowName = "无标题 - 记事本"
&& 按实际的窗口标题
hWnd = FindWindow(NULL, cWindowName)
IF hWnd == 0
? "找不到窗口"
RETURN
ENDIF
SetWindowPos(hWnd, -1, 0, 0, 0, 0, 3)
&& HWND_TOPMOST
SetFocus(hWnd)
_cliptext='VFP编程论坛'
keybd_event(17,0,0,0)
keybd_event(asc('V'),0,0,0)
keybd_event(asc('V'),0,2,0)
keybd_event(17,0,2,0)
SetWindowPos(hWnd, -2, 0, 0, 0, 0, 3)
&& HWND_NOTOPMOST
如果针对某个输入对象,还要模拟鼠标动作使对象获得输入焦点
模拟鼠标动作API mouse_event()
API SendInput() 可以模拟一组鼠标键盘动作,功能强大,但用起来有点复杂。
[此贴子已经被作者于2020-7-23 16:08编辑过]