Sign in to follow this  
Followers 0
Earthquake

How can I determine if a window is inactive

6 posts in this topic

Hi Snipez,

I want a script to determine, wheater a window is inactive.

After some tests with WinGetState I've got no more ideas... :D

Please give me a little piece of code and I'm happy again.


Yes, I am a noob! But at least I try to learn!Moddingtech.de - Home of the german Modding-Scene!

Share this post


Link to post
Share on other sites



almost straight from help

If WinActive("Untitled -") Then
    MsgBox(0, "", "Window was active")
Else
    MsgBox(0, "", "Window was not active")
EndIf

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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!

Share this post


Link to post
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]

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