Jump to content

Remember last focused window


talss
 Share

Recommended Posts

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.

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

Link to comment
Share on other sites

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
Link to comment
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!
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...