使用 vb.net 发送 ctrl+down 键
这是我的代码..由于某种原因它不起作用
Public Class Form1
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Const VK_CONTROL = &H11
Private Const VK_LEFT = &H25
Private Const VK_UP = &H26
Private Const VK_RIGHT = &H27
Private Const VK_DOWN = &H28
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim p As Process
Dim title As String
Dim handle As IntPtr
For Each p In Process.GetProcessesByName("winamp")
title = p.MainWindowTitle
handle = p.MainWindowHandle
If InStr(title, "Britney") Then
SendMessage(handle, WM_KEYDOWN, VK_SPACE, 0&)
SendMessage(handle, WM_KEYUP, VK_SPACE, 0&)
SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
SendMessage(handle, WM_KEYUP, VK_DOWN, 0)
SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
SendMessage(handle, WM_KEYUP, VK_DOWN, 0)
SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
SendMessage(handle, WM_KEYUP, VK_DOWN, 0)
End If
Next
End Sub
End Class
This is my code.. for some reason it is not working
Public Class Form1
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Const VK_CONTROL = &H11
Private Const VK_LEFT = &H25
Private Const VK_UP = &H26
Private Const VK_RIGHT = &H27
Private Const VK_DOWN = &H28
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim p As Process
Dim title As String
Dim handle As IntPtr
For Each p In Process.GetProcessesByName("winamp")
title = p.MainWindowTitle
handle = p.MainWindowHandle
If InStr(title, "Britney") Then
SendMessage(handle, WM_KEYDOWN, VK_SPACE, 0&)
SendMessage(handle, WM_KEYUP, VK_SPACE, 0&)
SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
SendMessage(handle, WM_KEYUP, VK_DOWN, 0)
SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
SendMessage(handle, WM_KEYUP, VK_DOWN, 0)
SendMessage(handle, WM_KEYDOWN, VK_CONTROL, 0)
SendMessage(handle, WM_KEYDOWN, VK_DOWN, 0)
SendMessage(handle, WM_KEYUP, VK_CONTROL, 0)
SendMessage(handle, WM_KEYUP, VK_DOWN, 0)
End If
Next
End Sub
End Class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论