Sign in to follow this  
Followers 0
PicketFence

Detect Desktop Focus

2 posts in this topic

Im trying to get a script to not execute a portion of code if the desktop is in active focus. I have used the following code with no luck. Any help is greatly appreciated. Thank you!

For this example if notepad.exe was executed, it should focus on the Untitled window and hide it. It should then set the focus back to the previous application unless the desktop was the current active window.

WinWaitActive("Untitled -")

WinSetState("Untitled -", "", @SW_HIDE)

If Not WinActive("Program Manager", "") Then

Send("{ALT DOWN}")

Send("{TAB}")

Send("{ALT UP}")

EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

WinActive("Program Manager", "") method works fine.

As for your code snippet, keep in mind that even after you hide that Notepad window, it's still active. To make desktop active you'd have to click on it. Therefore your code always executes ALT-TAB.

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0