Jump to content

Detect Desktop Focus


 Share

Recommended Posts

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

Link to comment
Share on other sites

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"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...