Dim frmhwnd As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
Const WM_KEYDOWN = &H100
Const WM_KEYUP = &H101
Const WM_CHAR = &H102
Const VK_A = &H41
''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const KEYEVENTF_KEYUP = &H2
Const KEYEVENTF_KEYDOWN = 0
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32.dll" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Timer1_Timer()
Dim pt As POINTAPI
Call GetCursorPos(pt)
If GetAsyncKeyState(vbKeyF6) <> 0 Then
Timer2 = False
frmhwnd = WindowFromPoint(pt.X, pt.Y)
Print frmhwnd
End If
If GetAsyncKeyState(vbKeyF7) <> 0 Then
Timer2 = True
ElseIf GetAsyncKeyState(vbKeyF8) <> 0 Then
Timer2 = False
End If
End Sub
Private Sub Timer2_Timer()
PostMessage frmhwnd, WM_KEYDOWN, 65, 0
PostMessage frmhwnd, WM_KEYUP, 65, 0
End Sub
为什么就只能对文本起作用啊?
我想要按相应技能的快捷键.
用SENDKEYS 可以,但是后台比较好!