vb模拟按下空格键
某个网页上有个按钮当你点击这个按钮的时候,出现个对话框内容类似于“您确认要退出吗?”然后下面有个确认按钮,和一个取消按钮。默认情况是你只要你安键盘上的空格建,就相当点击了...
某个网页上有个按钮 当你点击这个按钮的时候,出现个对话框 内容类似于“您确认要退出吗?”然后下面有个确认按钮,和一个取消按钮。默认情况是你只要你安键盘上的空格建,就相当点击了确认按钮。。
我现在想知道,怎么让vb(最好用VB.net)模拟按下空格键。。。 展开
我现在想知道,怎么让vb(最好用VB.net)模拟按下空格键。。。 展开
展开全部
用API函数,但是vb.net与vb6的API声明不一样的。代码如下:
Public Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Const KEYEVENTF_KEYUP = &H2
Const VK_SPACE = &H20
Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick
keybd_event(VK_SPACE, 0, 0, 0)
keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0)
End Sub
如有问题,消息问我。我通常不看回答后的旧贴。
Public Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Const KEYEVENTF_KEYUP = &H2
Const VK_SPACE = &H20
Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick
keybd_event(VK_SPACE, 0, 0, 0)
keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0)
End Sub
如有问题,消息问我。我通常不看回答后的旧贴。
展开全部
有两个方法
1、写一句SendKeys(" ")
2、用API,不过很麻烦:
Private Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Const KEYEVENTF_KEYUP = &H2
Const VK_SPACE = &H20
'在需要的地方加入:
keybd_event VK_SPACE, 0, 0, 0
keybd_event VK_SPACE, 0, KEYEVENTF_KEYUP, 0
1、写一句SendKeys(" ")
2、用API,不过很麻烦:
Private Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Const KEYEVENTF_KEYUP = &H2
Const VK_SPACE = &H20
'在需要的地方加入:
keybd_event VK_SPACE, 0, 0, 0
keybd_event VK_SPACE, 0, KEYEVENTF_KEYUP, 0
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用sendkey()函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sendkeys "[SPACE]"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询