Is there a generic way to identify a window as a sub window of an app instead of the app main window?
For instance if you run Notepad++, Window Spy will show ahk_class Notepad++ & ahk_exe notepad++.exe & ahk_pid 10220 for the main window, but ahk_class #32770 & ahk_exe notepad++.exe & ahk_pid 10220 for the Find window.
But in Excel it's ahk_class XLMAIN & ahk_exe EXCEL.EXE & ahk_pid 14360 for the main window and ahk_class bosa_sdm_XL9 & ahk_exe EXCEL.EXE & ahk_pid 14360 for the Find window.
I need to be able to identify (and reject/ignore) sub windows.
Any thoughts?
Main Window v Sub Window
Re: Main Window v Sub Window
Hallo,
when starting an app, the main window gets a new PID each time. Its sub-windows then each have the same PID as their main window. It is enough to clearly identify the main windows. Move the cursor over a window and press Q.
when starting an app, the main window gets a new PID each time. Its sub-windows then each have the same PID as their main window. It is enough to clearly identify the main windows. Move the cursor over a window and press Q.
Code: Select all
GroupAdd, Main_Window, ahk_class OpusApp ahk_exe WINWORD.EXE
GroupAdd, Main_Window, ahk_class XLMAIN ahk_exe EXCEL.EXE
GroupAdd, Main_Window, ahk_class Notepad++ ahk_exe notepad++.exe
GroupAdd, Main_Window, ahk_class Notepad ahk_exe notepad.exe
GroupAdd, Sub_Window, ahk_exe WINWORD.EXE
GroupAdd, Sub_Window, ahk_exe EXCEL.EXE
GroupAdd, Sub_Window, ahk_exe notepad++.exe
GroupAdd, Sub_Window, ahk_exe notepad.exe
; ...
q::
MouseGetPos,,, ID
IF WinExist("ahk_id " ID " ahk_group Main_Window")
ToolTip, Main Window
Else If WinExist("ahk_id " ID " ahk_group Sub_Window")
ToolTip, Sub Window
Else
ToolTip, ???
Return
Re: Main Window v Sub Window
Thanks a lot @Rohwedder
That ALMOST SOLVED my problem!
Your solution works fine as long as you know in advance what classes and exes look like in a Main App Window, but if you don't, how can you tell if it's a Main o Sub/Client Window?
I need some kind of generic solution
That ALMOST SOLVED my problem!
Your solution works fine as long as you know in advance what classes and exes look like in a Main App Window, but if you don't, how can you tell if it's a Main o Sub/Client Window?
I need some kind of generic solution