I trying to select a window in system process but it returns nothing.
Here is the window I'm trying to get:
What's wrong with the code below?
Sub Find_Window
Dim Profit As Integer = Win32.FindWindow(Nothing, "ProfitPro - 5.0.0.35 - Registrado"
Dim Menu As Integer = Win32.FindWindowEx(Profit, Nothing, "Editor de Estratégias", Nothing)
If (Not Menu = 0) Then
Win32.SetForegroundWindow(Menu)
SendKeys.Send("{TAB}")
End If
End Sub
There are a few problems with your code.
the editor window you are looking for is an MDI child, so you need to get the
HWND
of its parentMDIClient
window first, which you are not doing.in your final
FindWindowEx()
call, you are passing the editor's text in thelpszClass
parameter instead of thelpszWindow
parameter.you can't always pass a child window to
SetForegroundWindow()
. Since you know the editor is an MDI child, you should instruct MDI to bring the editor into focus, if that is what you are trying to do.Try this instead: