Declare Function keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
发送按键用这个api
这里有api原型和vbs调用的格式- Dim UserWrap,hWnd
-
- Set UserWrap = CreateObject("DynamicWrapper")
-
- 'Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
-
- UserWrap.Register "USER32.DLL", "FindWindow", "I=ss", "f=s", "R=l"
-
- 'Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
-
- UserWrap.Register "USER32.DLL", "SetWindowPos", "I=Hllllll", "f=s", "R=l"
-
- hWnd = UserWrap.FindWindow(vbNullString, "计算器")
-
- UserWrap.SetWindowPos hWnd, -1, 0, 0, 0, 0, 3
-
- MsgBox "现在将鼠标移到左上角!"
-
- 'Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
-
- UserWrap.Register "USER32.DLL", "SetCursorPos", "I=ll", "f=s", "R=l"
-
- UserWrap.SetCursorPos 0,0
复制代码
|