永发信息网

VB.net keybd_event函数怎么用

答案:2  悬赏:50  手机版
解决时间 2021-02-07 19:57
  • 提问者网友:沉默菋噵
  • 2021-02-07 02:05
VB.net keybd_event函数怎么用
最佳答案
  • 五星知识达人网友:神的生死簿
  • 2021-02-07 03:26
Imports System.Runtime.InteropServices

Public Class Form1

CharSet:=CharSet.Unicode, EntryPoint:="keybd_event", _
ExactSpelling:=True, SetLastError:=True)> _
Public Shared Sub keybd_event(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer) As Boolean
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Const VK_SCROLL As Byte = &H91
Const KEYEVENTF_KEYUP As Byte = &H2

keybd_event(VK_SCROLL, 0, 0, 0) ' Generates a KEY_DOWN
keybd_event(VK_SCROLL, 0, KEYEVENTF_KEYUP, 0) ' Generates a KEY_UP

End Sub

End Class
全部回答
  • 1楼网友:归鹤鸣
  • 2021-02-07 04:09
’声明 declare sub keybd_event lib "user32" (byval bvk as byte, byval bscan as byte, byval dwflags as long, byval dwextrainfo as long) ’参数bvk表示要模拟的按键的虚拟码,bscan表示该按键的扫描码(一般可以传0),dwflags表示是按下键还是释放键(按下键为0,释放键为2),dwextrainfo是扩展标志,一般没有用。 keybd_event vk_ctrl, 0, 0, 0 '按下ctrl键 keybd_event vk_c, 0, 0, 0 '按下c键 sleep 500 '延时500毫秒 keybd_event vk_c, 0, keyeventf_keyup, 0 '释放c键 keybd_event vk_ctrl, 0, keyeventf_keyup, 0 '释放ctrl键
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯