继承我的代码不起作用:
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim wHandle As Long = FindWindow(vbNullString, "Ultima Online")
PostMessage(wHandle, MOUSEEVENTF_LEFTDOWN, 0, 0)
PostMessage(wHandle, MOUSEEVENTF_LEFTUP, 0, 0)
答案 0 :(得分:0)
我不确定为什么这段代码会起作用 - 看起来你只是点击窗口而不是特定按钮。
要最小化窗口,您可以使用另一个api函数:SetWindowPlacement
,
见:http://www.codeproject.com/KB/dialog/Minimizewindow.aspx
另一个想法:如果你想要一个hacky解决方案,你可以发送密钥 Alt + Space n 来最小化窗口,但这是非常hacky,只适用于英语机器:
SendKeys ("% n") ''//in vb6
SendKeys.Send("% n") ''//in vb.net