Есть код
- Код: Выделить всё
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowsName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal cCmdShow As Long) As Long
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Command1_Click()
Dim lFoundWindow As Long
lFoundWindow = FindWindow(vbNullString, "Counter-Strike")
Call SetForegroundWindow(lFoundWindow)
Call ShowWindow(lFoundWindow, 9)
Call ShowWindow(lFoundWindow, 10)
Const VK_esc = 27
keybd_event VK_esc, 0, 0, 0 ' press esc
End Sub
По идеи программа должна найти заголовок игры Counter-Strike открыть ее и нажать на кнопку Esc
Программа находит окно открывает его, но не нажимает кнопку Esc