lauch exe在vb.net中填充并获取其windows标题
我有这个密码lauch exe在vb.net中填充并获取其windows标题,vb.net,Vb.net,我有这个密码 Private Sub tmrMain_Tick(sender As Object, e As EventArgs) Handles tmrMain.Tick EnumWindows(AddressOf Enumerator, 0) End Sub Private Function Enumerator(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean If
Private Sub tmrMain_Tick(sender As Object, e As EventArgs) Handles tmrMain.Tick
EnumWindows(AddressOf Enumerator, 0)
End Sub
Private Function Enumerator(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean
If IsWindowVisible(hwnd) Then
Dim text As String
Dim pPid As Integer
GetWindowText(hwnd, text, Int16.MaxValue) 'return integer value
Dim tempprocess As Process
GetWindowThreadProcessId(hwnd, pPid)
tempprocess = Process.GetProcessById(pPid)
text = tempprocess.MainWindowTitle
If "Holyrics is free - v2.15.1 x64" = text Then
contador = contador + 1
MessageBox.Show(contador)
tmrMain.Enabled = False
End If
End If
Return True
End Function
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MyProcess = Process.Start(txtNome.Text)
MyProcess.WaitForInputIdle()
End Sub
此exe在一段时间后将主窗口更改为“Holyrics是免费的-v2.15.1 x64”。
为什么MyProcess不自动将主窗口标题更改为“Holyrics是免费的-v2.15.1 x64”,而不使用我尝试过的if?
如何获取MyProcess生成的所有窗口的句柄?您可能需要使用获取窗口标题的长度,然后调用GetWindowText()
传递一个使用该容量+1初始化的StringBuilder。当然,删除tempprocess.MainWindowTitle
&Co.IsWindowVisible()
不是必需的。找到匹配项时返回False
,以停止枚举。也许,执行不区分大小写的比较。