 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu Mar 10, 2005 12:14 am Post subject: window under the window under the mouse-cursor |
|
|
Hi,
it sounds funny, but is it possible to get the window-id of the window behind the window where the mouse-pointer is? Now I hide the window under the mouse, get the window-id and then show the hidden window. That works, but looks ugly.
Tekl |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5390 Location: /b/
|
Posted: Thu Mar 10, 2005 12:17 am Post subject: |
|
|
Is this what you're looking for:
MouseGetPos, [OutputVarX, OutputVarY, OutputVarWin, OutputVarControl, 1] _________________
 |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu Mar 10, 2005 12:42 am Post subject: |
|
|
Hi Titan,
maybe you've misunderstood me. I don't want the window under the mouse. I want the window covered by the window under the mouse.
Tekl |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Thu Mar 10, 2005 12:44 am Post subject: |
|
|
He wanted the window *behind* the one the mouse is hovering over.
The following script seems to work. It relies on the fact that "WinGet List" probably always retrieves its window in z-order, which is the order they are stacked on the desktop: | Code: | #space:: ; Win+Space hotkey.
CoordMode, Mouse
MouseGetPos, MouseX, MouseY
; 123321 is intentionally a non-existent window for compatibility with older AutoHotkey versions:
WinGet, List, List,,, 123321
FirstWindowFound := false
FoundID =
Loop %List% ; For each window on the desktop.
{
ID := List%A_Index%
WinGetPos, WinX, WinY, WinW, WinH, ahk_id %ID%
; Does the mouse cursor lie inside the boundary of this window?:
if (MouseX > WinX and MouseY > WinY and MouseX < WinX+WinW and MouseY < WinY+WinH)
{
; Mouse is inside this window's boundaries.
if FirstWindowFound
{
FoundID := ID ; The second window in the z-order has been found.
break
}
else
FirstWindowFound := true ; Now we want the second window.
}
}
if FoundID
{
WinGetTitle, FoundTitle, ahk_id %FoundID%
MsgBox The following window is underneath the mouse cursor's top window:`n%FoundTitle%
}
return |
|
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu Mar 10, 2005 11:41 am Post subject: |
|
|
Thanks Chris, that's really nice.
Tekl |
|
| 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
|