获得指定标题的程序是否运行

Public Class 获得指定标题的程序是否运行

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Private Const MOUSEEVENTF_LEFTDOWN = &H2

Private Const MOUSEEVENTF_LEFTUP = &H4

Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()

Dim a As Long

a = FindWindow(vbNullString, "Windows 任务管理器")

If a = 0 Then MsgBox("游戏未运行") : Exit Sub

ShowWindow(a, 0)

ShowWindow(a, 1)

'Call SetCursorPos(512, 384) '移动

'mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '点击

End Sub

End Class

你可能感兴趣的:(获得指定标题的程序是否运行)