ycomp Posted January 7, 2008 Posted January 7, 2008 Hi, I want to minimize the active window... however, once I run my script it is no longer active... because I am clicking a shortcut on my desktop to run the script. So how do I get the last active window? thanks!
PsaltyDS Posted January 7, 2008 Posted January 7, 2008 (edited) ycomp said: Hi,I want to minimize the active window... however, once I run my script it is no longer active... because I am clicking a shortcut on my desktop to run the script.So how do I get the last active window?thanks!There is a rakishly handsome flightless antarctic waterfowl lurking the Forum, who posted a function called _WinPrevious() some time back... P.S. You could also just save the handle of the current window before switching, and restore it when you're done. Edited January 7, 2008 by PsaltyDS 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
ycomp Posted January 7, 2008 Author Posted January 7, 2008 couldn't figure it out. What I want to do actually is to do this: 1) I'm using my favorite piece of software, but I like to have it at a specific window size... and the damn program is never opening new documents in my favorite size. So I want to resize it to my fave size. 2) so I click a shortcut on the desktop to run my autoit script 3) this of course takes focus away from my app's window 4) so from the script I want to activate the previous window (the app's window) and then change the size any ideas how to do this with winprevious? I couldn't get it to work for me... I'm on Vista also, if that helps.
Siao Posted January 7, 2008 Posted January 7, 2008 Wouldn't it make sense to use WinActivate() to activate that favorite piece of software? "be smart, drink your wine"
ycomp Posted January 7, 2008 Author Posted January 7, 2008 (edited) don't want to seem like an idiot, cause I'm new at this stuff... but how do I use WinActivate for this if I don't know what the title of the window will be? There is no consistent text in there... just the name of the document I'm working on. Edited January 7, 2008 by ycomp
martin Posted January 7, 2008 Posted January 7, 2008 ycomp said: don't want to seem like an idiot, cause I'm new at this stuff... but how do I use WinActivate for this if I don't know what the title of the window will be? There is no consistent text in there... just the name of the document I'm working on.You could get the window name from the process.Here's another way you could do it. Have a little script which need not have a gui and just runs in the background. For this sort of job I change the shortcut to the program I want to affect and make it so that it actually starts my script but it looks like the same shortcut.In the script I start the program if it's not already running. (ShellExecute or Run)I set a hotkey. (HotKetSet)When the hotkey is pressed you will only do it presumably when the program you want to affect is active, so then the function for the hotkey only has to say$CurrentWindow = WinGetactive("")WinsetPos($CurrentWindow,.... etc or whatever it is you want to doWhen the program is closed the script can detect that and closes as well. (If not Winexists($CurrentWindow) then Exit) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
PsaltyDS Posted January 7, 2008 Posted January 7, 2008 ycomp said: don't want to seem like an idiot, cause I'm new at this stuff... but how do I use WinActivate for this if I don't know what the title of the window will be? There is no consistent text in there... just the name of the document I'm working on.The _WinPrevious() function just activates the previous (or nth previous) window in the z-order. It won't help if you don't know the window you want is exactly the last window or the 3rd last window, etc.More likely you can find the window you want by other information (besides title) that you can identify with Au3Info.exe, the window info tool that comes with AutoIt. Information like CLASS can be used with Opt("WinTitleMatchMode", 4) to find your window. 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
ycomp Posted January 7, 2008 Author Posted January 7, 2008 send ALT-TAB sounds the easiest... I'll see if that works.. thanks for all the help
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