所以我正在开发一个程序,该程序可以输入一个没有 api 的开放应用程序。所以我需要选择该窗口,以便我的程序能够在其中输入内容。我正在使用这段代码,但它找不到该进程。
Dim windowHandle As IntPtr = FindWindow("LolClient", "League of Legends (TM) Client")
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As IntPtr
SetForegroundWindow(windowHandle)
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("{TAB}")
SendKeys.SendWait(ComboBox1.Text)
SendKeys.SendWait("{Enter}")
尝试这个:
Public Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Integer) As Integer
Public Declare Auto Function FindWindow Lib "user32.dll" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function IsIconic Lib "user32.dll" (ByVal hwnd As Integer) As Boolean
Public Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
Public Const SW_RESTORE As Integer = 9
Public Const SW_SHOW As Integer = 5
Sub FocusWindow(ByVal strWindowCaption As String, ByVal strClassName As String)
Dim hWnd As Integer
hWnd = FindWindow(strClassName, strWindowCaption)
If hWnd > 0 Then
SetForegroundWindow(hWnd)
If IsIconic(hWnd) Then 'Restore if minimized
ShowWindow(hWnd, SW_RESTORE)
Else
ShowWindow(hWnd, SW_SHOW)
End If
End If
End Sub
要显示“计算器”,您可以调用FocusWindow("Calculator", Nothing)
or FocusWindow(Nothing, "CalcFrame")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)