VB后台发送按键消息
PrivateConstPROCESS_ALL_ACCESSAsLong=&H1F0FFFPrivateConstWM_KEYUP=&H101PrivateConstWM...
Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Private Const WM_KEYUP = &H101
Private Const WM_CHAR = &H102
Private Const WM_KEYDOWN = &H100'定义常量
。。。。。。。。。。。
PostMessage& hwd, WM_KEYDOWN, vbKeyReturn, 0 '这是按下
PostMessage hwd, WM_KEYUP, vbKeyReturn, 0 '这是弹起按键
这是一段VB代码,向后台发送Enter键,我想再添加一个组合键Alt+N,和单独键F3键,请问我要怎么做,会的请帮下我,我是小菜。谢谢大家
误人子弟的就算咯,以免耽误大家的时间
谢谢大家的回答,但是还是 不行
ALT是系统按键和普通键好像有点区别,按下好像是WM_SYSKEYDOWN,vbKeyAlt,0 '按下Alt,我不是很清楚的,本人VB小菜,请大家出手相助,谢谢! 展开
Private Const WM_KEYUP = &H101
Private Const WM_CHAR = &H102
Private Const WM_KEYDOWN = &H100'定义常量
。。。。。。。。。。。
PostMessage& hwd, WM_KEYDOWN, vbKeyReturn, 0 '这是按下
PostMessage hwd, WM_KEYUP, vbKeyReturn, 0 '这是弹起按键
这是一段VB代码,向后台发送Enter键,我想再添加一个组合键Alt+N,和单独键F3键,请问我要怎么做,会的请帮下我,我是小菜。谢谢大家
误人子弟的就算咯,以免耽误大家的时间
谢谢大家的回答,但是还是 不行
ALT是系统按键和普通键好像有点区别,按下好像是WM_SYSKEYDOWN,vbKeyAlt,0 '按下Alt,我不是很清楚的,本人VB小菜,请大家出手相助,谢谢! 展开
3个回答
展开全部
hWnd1 = FindWindow(vbNullString, "1.txt - 记事本")
hWnd2 = FindWindowEx(hWnd1, 0, "Edit", vbNullString)
keybd_event VK_MENU, 0, 0, 0
PostMessage hWnd2, WM_KEYDOWN, vbKeyN, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
PostMessage hWnd2, WM_KEYDOWN, vbKeyF3, 0 '按下F3键
这样不知道符合楼主不?
hWnd2 = FindWindowEx(hWnd1, 0, "Edit", vbNullString)
keybd_event VK_MENU, 0, 0, 0
PostMessage hWnd2, WM_KEYDOWN, vbKeyN, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
PostMessage hWnd2, WM_KEYDOWN, vbKeyF3, 0 '按下F3键
这样不知道符合楼主不?
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
按下组合键就是Alt键按下后不抬起,再按N,然后一起抬起来结束组合键。
'按下组合键Alt+N
PostMessage hwnd,WM_KEYDOWN,vbKeyAlt,0 '按下Alt
PostMessage hwnd,WM_KEYDOWN,vbKeyN,0 '按下N
'抬起组合键Alt+N
PostMessage hwnd,WM_KEYUP,vbKeyAlt,0 '抬起Alt
PostMessage hwnd,WM_KEYUP,vbKeyN,0 '抬起N
'按下F3
PostMessage hwnd,WM_KEYDOWN,vbKeyF3,0 '按F3
PostMessage hwnd,WM_KEYUP,vbKeyF3,0
'按下组合键Alt+N
PostMessage hwnd,WM_KEYDOWN,vbKeyAlt,0 '按下Alt
PostMessage hwnd,WM_KEYDOWN,vbKeyN,0 '按下N
'抬起组合键Alt+N
PostMessage hwnd,WM_KEYUP,vbKeyAlt,0 '抬起Alt
PostMessage hwnd,WM_KEYUP,vbKeyN,0 '抬起N
'按下F3
PostMessage hwnd,WM_KEYDOWN,vbKeyF3,0 '按F3
PostMessage hwnd,WM_KEYUP,vbKeyF3,0
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
按下组合键Alt+N
PostMessage hwnd,WM_KEYDOWN,vbKeyAlt,0 '按下Alt
PostMessage hwnd,WM_KEYDOWN,vbKeyN,0 '按下N
'抬起组合键Alt+N
PostMessage hwnd,WM_KEYUP,vbKeyAlt,0 '抬起Alt
PostMessage hwnd,WM_KEYUP,vbKeyN,0 '抬起N
'按下F3
PostMessage hwnd,WM_KEYDOWN,vbKeyF3,0 '按F3
PostMessage hwnd,WM_KEYUP,vbKeyF3,0
PostMessage hwnd,WM_KEYDOWN,vbKeyAlt,0 '按下Alt
PostMessage hwnd,WM_KEYDOWN,vbKeyN,0 '按下N
'抬起组合键Alt+N
PostMessage hwnd,WM_KEYUP,vbKeyAlt,0 '抬起Alt
PostMessage hwnd,WM_KEYUP,vbKeyN,0 '抬起N
'按下F3
PostMessage hwnd,WM_KEYDOWN,vbKeyF3,0 '按F3
PostMessage hwnd,WM_KEYUP,vbKeyF3,0
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询