monte Posted October 16, 2007 Posted October 16, 2007 Hello, I have a tray menu and I want to activate the window that was active before I accessed the tray menu. How do I do this, is there a z order list I can access with winactivate, or something like that? Any help would greatly be appreciated, thanks. expandcollapse popup#include <IE.au3> #Include <Constants.au3> #NoTrayIcon ;;;;;;;;; ;hotkeys ;;;;;;;;; HotKeySet("^#b", "cmd") ;cmd prompt HotkeySet("^#c", "copy") ;copy ;;;;;; ;tray ;;;;;; Opt("TrayMenuMode",1) $cmd = TrayCreateItem("Cmd Prompt - Ctrl Win B") $copy = TrayCreateItem("Copy - Ctrl Win C") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() TraySetToolTip("Hotkeys") While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $exititem ExitLoop Case $msg = $cmd cmd() Case $msg = $copy copy() EndSelect WEnd ;;;;;; ;CMD ;;;;;; func cmd() TraySetState(4) Run(@ComSpec & " /k color 02&prompt #&cls" & @cr) traysetstate(8) endfunc ;;;;;; ;Copy ;;;;;; func copy() ;activate previous window and copy what's selected ;winactivate ???? ;winwaitactive ??? sleep(100) send("^c", 0) sleep(100) msgbox(0, "Hotkeys", "You copied:" & @cr & stringstripws(ClipGet(), 8) endfunc
monte Posted October 16, 2007 Author Posted October 16, 2007 Well, that's a little anti-climactic! And here I was looking for something a little more difficult....hello captain obvious! Thanks, Nahuel
PsaltyDS Posted October 16, 2007 Posted October 16, 2007 Windows does keep track of the Z-order of previous windows. The array returned from WinList is in z-order. Based on that, I did a function called _WinPrevious(). It will let you go back 1 in the z-order by default, but can receive an integer to go back farther. If Alt-Tab covers all your bases, then it's still overkill, of course. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now