Jump to content

How can I determine if a window is inactive


Recommended Posts

Or.. in addition to what Valuater posted...

If Not WinActive("Title") Then
    MsgBox(0, "Title", "Window is not active.")
Else
    MsgBox(0, "Title", "Window is active.")
EndIf

The same thing, only negated. :D

Link to comment
Share on other sites

Run("notepad")
WinWait("Untitled -")
WinActivate("Untitled -")
WinWaitActive("Untitled -")

If BitAND(WinGetState("Untitled -"), 8) Then
    MsgBox(0, "", "Window was active")
Else
    MsgBox(0, "", "Window was not active")
EndIf
...since you mentioned WinGetState...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Thanks a lot!

But I tried this as well...

Here's my code:

$dif = TimerDiff($begin)

If ($dif > 1000) Then
    CheckforMinimized()
EndIf

Func CheckforMinimized()
    
    $Minimized = WinGetState("Untitled - Notepad", "")
    
    If BitAND($Minimized, 8) Then
        WinSetState("Test","", @SW_SHOW); Test is my script.
    Else
        WinSetState("Test","",@SW_HIDE)
    EndIf
EndFunc

First I check, whether Notepad is open. If that's true, the script should stay topmost (is definded in another function).

But when another program is active, it should hide. But right now, its blinking every second!!! :D

He,he, cool effect, but I want to use this GUI, too!

Edited by Earthquake
Yes, I am a noob! But at least I try to learn!Moddingtech.de - Home of the german Modding-Scene!
Link to comment
Share on other sites

While 1
    CheckforMinimized()
    Sleep(1000)
WEnd

Func CheckforMinimized()
    $Minimized = WinGetState("Untitled - Notepad", "")
    If BitAND($Minimized, 16) Then MsgBox(0, "", "mini")
    If BitAND($Minimized, 8) Then MsgBox(0, "", "active")
    If $Minimized = 0 Then MsgBox(0, "", "not there")
EndFunc   ;==>CheckforMinimized
This works as a stand alone test.

I'll have to let others see if they understand the problem with the sample code you posted.

[size="1"][font="Arial"].[u].[/u][/font][/size]

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...