Sign in to follow this  
Followers 0
raca

How to get last active window?

10 posts in this topic

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?

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

But You can get active window earlier and then WinWaitActive(Your_Dialog_Box). (I think You can :))

Share this post


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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

You should use some Ad-Aware scanner not write script ;p

Share this post


Link to post
Share on other sites

You should use some Ad-Aware scanner not write script ;p

didn't get it

Share this post


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

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