| View previous topic :: View next topic |
| Author |
Message |
scribbly
Joined: 24 Apr 2009 Posts: 9
|
Posted: Tue Oct 13, 2009 12:30 am Post subject: Is there a reason why winGet returns different values? |
|
|
Consider the snippet:
| Code: | Run, %programme_to_run%, , UseErrorLevel, cmd_PID
WinWait ahk_pid %cmd_PID%,,10
if not ERRORLEVEL
{
WinGet, win_ID, ID, ahk_pid %cmd_PID%
if !win_ID
MsgBox, No matching windows
unique:= winexist(ahk_pid %cmd_PID%)
WinGet, active, ID, A
}
else
MsgBox, Errow waiting for ahk_pid %cmd_PID%
MsgBox, %win_ID%`n%unique%`n%active%
|
Why can the three values be different (apart from the window not being active)??
What I thought would be easy was to get the windowID from the ProcessID returned from Run and close it later... but the close fails because the Win_ID is usually not set to the same value as active.
Any ideas? _________________ Scribbly |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1381 Location: USA
|
Posted: Tue Oct 13, 2009 1:37 am Post subject: |
|
|
to use pid you have to have full path to exe _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
scribbly
Joined: 24 Apr 2009 Posts: 9
|
Posted: Tue Oct 13, 2009 2:20 am Post subject: |
|
|
| ahklerner wrote: | | to use pid you have to have full path to exe |
Thanks: where do you mean? %programme_to_run% is the full path, and Run returns the correct PID.
WinWait ahk_pid %cmd_PID% finds a window OK
WinGet, win_ID, ID, ahk_pid %cmd_PID% does not return the same ID that WinGet, active, ID, A returns (when the appropriate window is active). _________________ Scribbly |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1381 Location: USA
|
Posted: Tue Oct 13, 2009 2:43 am Post subject: |
|
|
perhaps the program you are running is creating multiple windows ? (you may not be able to see all of them) in that case also specify a window title or something like My Window Title ahk_pid %pid% ... iirc somewhere i read that if there are multiple windows that match the wintitle parameter, it returns the info for the topmost. _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
scribbly
Joined: 24 Apr 2009 Posts: 9
|
Posted: Tue Oct 13, 2009 3:01 am Post subject: |
|
|
| ahklerner wrote: | | perhaps the program you are running is creating multiple windows ? (you may not be able to see all of them) in that case also specify a window title or something like My Window Title ahk_pid %pid% ... iirc somewhere i read that if there are multiple windows that match the wintitle parameter, it returns the info for the topmost. |
Thanks for the pointer:
| Code: | | Get, NumberWindows, List, ahk_pid %cmd_PID% |
is very revealing!
Plus it helps if you turn off DetectHiddenWindows  _________________ Scribbly |
|
| Back to top |
|
 |
temp01
Joined: 09 Jul 2009 Posts: 120
|
Posted: Tue Oct 13, 2009 2:19 pm Post subject: Re: Is there a reason why winGet returns different values? |
|
|
BTW, | scribbly wrote: | | Code: | ...
unique:= winexist(ahk_pid %cmd_PID%)
... |
|
should be | Code: | | unique:= winexist("ahk_pid " . cmd_PID) |
|
|
| Back to top |
|
 |
scribbly
Joined: 24 Apr 2009 Posts: 9
|
Posted: Tue Oct 13, 2009 9:55 pm Post subject: Re: Is there a reason why winGet returns different values? |
|
|
| temp01 wrote: | BTW, | scribbly wrote: | | Code: | ...
unique:= winexist(ahk_pid %cmd_PID%)
... |
|
should be | Code: | | unique:= winexist("ahk_pid " . cmd_PID) |
|
Yes, of course: thanks.
I presume that WinExists() was returning the top-most, or last opened, window? _________________ Scribbly |
|
| Back to top |
|
 |
temp01
Joined: 09 Jul 2009 Posts: 120
|
Posted: Tue Oct 13, 2009 10:11 pm Post subject: Re: Is there a reason why winGet returns different values? |
|
|
| scribbly wrote: | | I presume that WinExists() was returning the top-most, or last opened, window? |
It was returning the last found found. |
|
| Back to top |
|
 |
|