如何用VB编写一个向指定窗口发送键盘命令的程序?
如何用VB编写一个向指定窗口发送键盘命令的程序?或者是向当前窗体发送键盘和鼠标命令的程序?谁知道怎么写啊给点提示啊谢谢了...
如何用VB编写一个向指定窗口发送键盘命令的程序? 或者是向当前窗体发送键盘和鼠标命令的程序 ? 谁知道怎么写啊 给点提示啊 谢谢了
展开
3个回答
展开全部
用 Api函数 keybd_event
具体定义
Private Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
keybd_event 17, vbNull, &H2, vbNull
17 是要模拟的按键 17 是 ctrl 键
&H2模拟按键的动作 &H2是按下弹起
mouse_event 是模拟鼠标
具体定义
Private Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
mouse_event &H2,vbnull,vbnull,vbnull,vbnull
&H2是要模拟的动作
移动鼠标 =&H1
模拟鼠标左键按下 =&H2
模拟鼠标左键抬起 =&H4
模拟鼠标右键抬起 =&H8
模拟鼠标右键按下 =&H10
模拟鼠标中键按下 =&H20
模拟鼠标中键抬起=&H40
具体定义
Private Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
keybd_event 17, vbNull, &H2, vbNull
17 是要模拟的按键 17 是 ctrl 键
&H2模拟按键的动作 &H2是按下弹起
mouse_event 是模拟鼠标
具体定义
Private Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
mouse_event &H2,vbnull,vbnull,vbnull,vbnull
&H2是要模拟的动作
移动鼠标 =&H1
模拟鼠标左键按下 =&H2
模拟鼠标左键抬起 =&H4
模拟鼠标右键抬起 =&H8
模拟鼠标右键按下 =&H10
模拟鼠标中键按下 =&H20
模拟鼠标中键抬起=&H40
参考资料: -原创-
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用函数 sendkey
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询