 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Wed Aug 13, 2008 10:00 pm Post subject: WinExist() finds more windows then WinGet,var,list |
|
|
When I make a Listview of all windows, I'm sometimes interested in finding the parent window in my Listview, where some window belongs to.
But sometimes "WinGet,var,list" can't find it, although WinExist() still can tell it exists.
Is this a Windows API problem (if so, worth a remark in Help file), or a AHK problem?
The following code shows this phenomena: | Code: | ; Tested with ahk V1.0.47.06 (and some earlier version) on WindowsXP
Gui, add, text,vTxt, <Ahk V%A_AhkVersion%>
Gui, +lastfound
gui_ID1 := WinExist()
Gui,show, x10 y65 w180 h18, Test Parent Issue
Run, calc.exe,,, CalcPID
WinWait, ahk_pid %CalcPID%
WinGet, hw_parent, ID, ahk_pid %CalcPID%
; The following line causing "WinGet, IDarray, list" not finding gui_ID2
DllCall("SetParent", "uint", gui_ID1, "uint", hw_parent)
TaskBarID := WinExist("ahk_class Shell_TrayWnd")
; ->testcode: to be sure lastfound window is changed from last "Gui, +lastfound"
Gui, +lastfound
gui_ID2 := WinExist() ; test: should be same as gui_ID1
; search Gui window with WinExist:
WinExistFoundStr := WinExist("ahk_id " gui_ID2) ? "" : "NOT" ; always find window
; search Gui window with WinGet,var,list:
WinGetFoundStr := "NOT"
WinGet, IDarray, list,
Loop, %IDarray% {
If (IDarray%A_index% = gui_ID2) { ; doesn't find window after SetParent
WinGetFoundStr := ""
Break
}
}
; [edit start] WinExist() can be applied to windows and controls
ControlListCalc := ""
WinGet, ControlListCalc, controllisthwnd, ahk_pid %CalcPID%
Loop, parse, ControlListCalc, `n, `r
if (A_loopField = gui_ID2) {
WinGetText, ChildText, ahk_id %A_loopField%
MsgBox,,%ChildText%, % WinExist("ahk_id " . A_loopField)
}
; [edit end] WinExist() can be applied to windows and controls
MsgBox,,%ChildText%,
(Ltrim
Before DllCall: gui_ID1= %gui_ID1%
After DllCall: gui_ID2= %gui_ID2%
WinExist() : %WinExistFoundStr% found AutoHotkeyGUI (gui_ID2)!
WinGet : %WinGetFoundStr% found AutoHotkeyGUI (gui_ID2)!
)
WinClose, ahk_pid %CalcPID%
ExitApp
Return | [edit:added]So, maybe we can conclude this:
1. WinExist() can be applied for all windows and controls ID's.
2. When getting the controls of Calc.exe with WinGet, you can find the gui_ID2 child window:
Results: WinGet,controllist: AutoHotkeyGUI1 , and WinGet,controllisthwnd: e.g. 0xf0b04
3. "WinGet, list" can only be applied to find windows that can move outside parent window, if there is any parent at all. (If there's no parent, it will find it anyway)
Although, some (or all other?) window commands (like WinGetText) are still working on the gui_ID2 child window.
Last edited by Peter on Thu Aug 14, 2008 8:47 am; edited 1 time in total |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Aug 14, 2008 1:19 am Post subject: Re: WinExist() finds more windows then WinGet,var,list |
|
|
| I didn't test your code (I read it tho), but for one thing, you are using WinGet, var, list only once BEFORE the DllCall...the string list is not auto-updated...on the other hand WinExist() is a function call & is updated at the time of the call...do WinGet, var1, list before the DllCall & WinGet, var2, list...then compare var1 & var2... |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Aug 14, 2008 1:38 am Post subject: Re: WinExist() finds more windows then WinGet,var,list |
|
|
| Anonymous wrote: | | ...but for one thing, you are using WinGet, var, list only once BEFORE the DllCall... |
...sorry, semi-nevermind...the "WinGet, hw_parent..." before the DllCall confused me, I thought it was a WinGet, , List, since that's what this topic is about...so on 2nd thought...WinGet, , List only gets the top level windows & WinExist() can see anything, regardless of parent...
OK...maybe I should stop guessing...the help on WinGet, , List doesn't mention only top-level windows...so maybe I'm wrong again...try adding DetectHiddenWindows, On & see if that helps it find it...
One more guess, that I'm nearly sure about...you can use WinGet, , ControlList to get the children windows of a window...it's called control since it's normally controls, but I'm almost 100% sure ControlList would get the SetParent'd calc window... |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Thu Aug 14, 2008 8:15 am Post subject: |
|
|
| guest wrote: | | you can use WinGet, , ControlList to get the children windows of a window... | Yes, I checked and that's true. I've added that to the code. |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 970 Location: London, UK
|
Posted: Thu Aug 14, 2008 8:22 am Post subject: |
|
|
All window commands will generally see the windows when you use an ahk_id to find it as you do above. If you change the winexist() command to work on the window title instead it also fails to detect the Window.
I also noticed, although it is probably something you would never do, If you use the ahk_id on the winget,list it fails there, however if I used winget,ID, it worked fine.
I thought maybe dettecthiddenwindows might have made a difference, but it didnt, ( I know they are not hidden, but at least it would of made some sense) _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|