peter1234 Posted December 27, 2005 Share Posted December 27, 2005 Is there anyway in AutoIt to tell which window (GUI) is on top (has focus)? I can set the focus in AutoIt, but there does not seem to be any way to detect when the user has changed focus. It is possible to check for mouse clicks and check where the mouse was located when it was clicked, but this does not work when working with transparent regions because the Windows operating system can look through the transparent part of the region and set focus to what is under the region where the mouse was clicked. Also focus can be changed by clicking program in the task bar. I am writing some functions to drag transparent regions. When one transparent region is on top of another I can detect that mouse was clicked over the regions, but I need to know which window is on top in order to know which window to drag. It is not possible to keep track of which window is on top in the script because it is not possible to detect which region was clicked when one transparent region is on top of aother. Link to comment Share on other sites More sharing options...
jonk Posted December 27, 2005 Share Posted December 27, 2005 Is there anyway in AutoIt to tell which window (GUI) is on top (has focus)? I can set the focus in AutoIt, but there does not seem to be any way to detect when the user has changed focus. It is possible to check for mouse clicks and check where the mouse was located when it was clicked, but this does not work when working with transparent regions because the Windows operating system can look through the transparent part of the region and set focus to what is under the region where the mouse was clicked. Also focus can be changed by clicking program in the task bar. I am writing some functions to drag transparent regions. When one transparent region is on top of another I can detect that mouse was clicked over the regions, but I need to know which window is on top in order to know which window to drag. It is not possible to keep track of which window is on top in the script because it is not possible to detect which region was clicked when one transparent region is on top of aother. you could use WinGetTitle("") to get the windowtile of the currently active window and compare it with the windowtile of your desired window. e.g.: #include <misc.au3> opt("WinTitleMatchMode", 4) Dim $currentTitle Dim $lastTitle While Not _isPressed ("1B") $currentTitle = WinGetTitle("active") If $currentTitle <> $lastTitle And $currentTitle <> "" Then FileWriteLine(@ScriptDir & "\instructions.txt", WinGetTitle("active")) $lastTitle = $currentTitle EndIf WEnd Link to comment Share on other sites More sharing options...
peter1234 Posted December 27, 2005 Author Share Posted December 27, 2005 @jonk: Great idea. Thanks. Link to comment Share on other sites More sharing options...
peter1234 Posted December 27, 2005 Author Share Posted December 27, 2005 @jonk: Got it working. Thanks again for your help. Link to comment Share on other sites More sharing options...
Tippex Posted January 30, 2019 Share Posted January 30, 2019 Yes, I'm responding to an old post but anyone needing the same solution for the latest AutoIT may find they also need the square brackets now: WinGetTitle("[ACTIVE]") Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now