Sign in to follow this  
Followers 0
Andre

Find last active window

10 posts in this topic

Hi,

I've tried to find this but no luck :(

How do i display the previous active window ?

For example :

I'm running notepad, and switch to an AutoIt program, how can i see that notepad is my last active window ?

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites



dunno but if you want to reactivate it you send can alt+tab once

Share this post


Link to post
Share on other sites

Hi,

thnx works but...

show the alt-tab dialog also quickly.....

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

$PrevWin = WinGetTitle("")
$CurWin = WinGetTitle("")
while 1
  if $CurWin <> WinGetTitle("") Then
    $PrevWin = $CurWin
    $CurWin = WinGetTitle("")
  endif
  Sleep(100)
Wend

This is some off-the-cuff pseudo-code, but maybe you get my drift.

Instead of Sleep, you could implement WinWaitNotActive($CurWin).

I suppose I have not left you a good way to get out of the loop though. :(

J


If I am too verbose, just say so. You don't need to run on and on.

Share this post


Link to post
Share on other sites

hi does not work.....

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

AutoItSetOption("WinTitleMatchMode", 4)
;mode four allows for the use of "last" in the next line

WinActive("last")
;activates the last active window


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

"last" uses the last successful window match so you don't have to keep specifying the title and text again and again. e.g.

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

This is what they call a "proof of concept." It has a message box which pops up every whipstitch, but maybe it can be refined.

The main prob. I had was with the scope of the variables. I tried several implementations, but my ideas all required some multi-threading, which wasn't working.

;Prog Start
Global $PrevWin = ""
Global $CurWin  = "dummy"
While 1
  Sleep(100)
  WinWaitNotActive($CurWin)
  $PrevWin = $CurWin
  $CurWin = WinGetTitle("")
  MsgBox(4096, "This win excluded", $PrevWin, 5)
WEnd

J


If I am too verbose, just say so. You don't need to run on and on.

Share this post


Link to post
Share on other sites

"last" uses the last successful window match so you don't have to keep specifying the title and text again and again. e.g.

Andre

<{POST_SNAPBACK}>

I know, but it worked for me at the start of a script... one that was started via an OS shortcut key... so, thinking about it further, the window that I was interested in never lost focus - so the "last" line probably did nothing for me. Thanks for helping me think thru that. I'll go back to sleep now.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Well I guess you could have all you "extra" desktop icons in a folder somewhere and when the boss comes in you hit alt + b or something and it switches them all. As for the windows just do a WinList function and save that list then have autoit close them all, and open a few new "innocent" ones.


Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

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