Sign in to follow this  
Followers 0
talss

Remember last focused window

7 posts in this topic

My script switches between windows,and i want him to switch - and go back(give focus) to the original window.

so i tried this algorithem:

$windows = WinList()
    for $i = 0 to Ubound($windows)-1 Step +1
        $check = WinActive($windows[$i][0])
        if $check == 1 Then
            ExitLoop
        EndIf
    Next
Etc...Code...
WinActivate($windows[$check][0])

and it's not working,what should I do?

Sometimes when I check with MsgBox which window was active it writes :"Task Switching".

or somtimes even " " - empty string.

Share this post


Link to post
Share on other sites



You didn't understand what I meant to do.

1)I want to check which window has focus now.

2)Remember its title.

3)Perform a code.

4)Give focus to that window again using WinActivate();

Share this post


Link to post
Share on other sites

Man,It doesn't help me,

I want to see which window has focus now.

how do I do it?

Share this post


Link to post
Share on other sites

Global $tName = ''

MsgBox(0, '', WhoIsActive())

Func WhoIsActive()
    Local $List = WinList()

    For $x = 1 To $List[0][0]
        If $List[$x][0] <> "" And IsActive($List[$x][1]) Then
            $tName = $List[$x][0]
            Return $tName
            ExitLoop
        EndIf
    Next

EndFunc  ;==>WhoIsActive


Func IsActive($Handle)
    If BitAND(WinGetState($Handle), 8) Then
        Return 1
    Else
        Return 0
    EndIf

EndFunc  ;==>IsActive

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Man,It doesn't help me,

I want to see which window has focus now.

how do I do it?

WinGetHandle("[ACTIVE]", "")

Cheers,

Brett

Edited by BrettF

Share this post


Link to post
Share on other sites

WinGetHandle("[ACTIVE]", "")

Cheers,

Brett

xD I have forgotten it

Share this post


Link to post
Share on other sites

Global $tName = ''

MsgBox(0, '', WhoIsActive())

Func WhoIsActive()
    Local $List = WinList()

    For $x = 1 To $List[0][0]
        If $List[$x][0] <> "" And IsActive($List[$x][1]) Then
            $tName = $List[$x][0]
            Return $tName
            ExitLoop
        EndIf
    Next

EndFunc ;==>WhoIsActive


Func IsActive($Handle)
    If BitAND(WinGetState($Handle), 8) Then
        Return 1
    Else
        Return 0
    EndIf

EndFunc ;==>IsActive
Thank u very much!

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