Jump to content

How to get last active window?


Recommended Posts

I'm codding a program to close a dialog opened by a program.

I can easily close the dialog.. but i wanna give the focus to the window active before the dialog opened

how can i do it?

Link to comment
Share on other sites

I'm codding a program to close a dialog opened by a program.

I can easily close the dialog.. but i wanna give the focus to the window active before the dialog opened

how can i do it?

HI,

if you have got the title, use WinActivate().

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi! I wrote something like this

Func getActiveApp()
    $var = WinList()
    For $i = 1 To $var[0][0]
        $active = WinActive($var[$i][0])
        If $active == 1 And $var [$i][0] <> "" Then
            $title = $var[$i][0]
            ExitLoop
        EndIf
    Next
    $aktywne = $title
    Return $aktywne
EndFunc   ;==>getActiveApp
Link to comment
Share on other sites

but that way the active window is the dialog opened.

i want to give the focus to the previous active window.

is there a simple way to get the list of the windows of the ALT+TAB it has the last active window

Link to comment
Share on other sites

Bundy is right.

Run this in Scite.

$OldWin=WinGetTitle('')
While 1
    $NewWin = WinGetTitle('')
    If $NewWin='' OR $NewWin = 'program manager' Then ContinueLoop
    If $NewWin = $OldWin Then
        Sleep (100)
    Else
        ConsoleWrite('Old Window was ' & $OldWin&@CR)
        $OldWin=$NewWin
    EndIf   
WEnd    
Exit
Link to comment
Share on other sites

thanks :)

here is the script...

it closes the annoying dialog that bores me :(

$OldWin=WinGetTitle("")
While 1
    If WinExists("Profile storage space") Then
;closes the window
    WinClose("Profile storage space")
;restores the focus
    WinActivate($OldWin)
    Else
    $OldWin=WinGetTitle("")
    EndIf
    Sleep(100)
WEnd

cheers

Edited by raca
Link to comment
Share on other sites

better version

$OldWin=WinGetTitle("")
$oldControl=ControlGetFocus($OldWin)
While 1
    If WinExists("Profile storage space") Then
    ;fecha a janela
        WinClose("Profile storage space")
    ;restora o focus
        ControlFocus ($OldWin,"",$oldControl)
    Else
        $OldWin=WinGetTitle("")
        $oldControl=ControlGetFocus ($OldWin)
    EndIf
    Sleep(100)
WEnd
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...