illya Posted April 14, 2008 Posted April 14, 2008 I'm trying to make an AutoIt who remembers the title of a focused window and a few moments later (during which I have lost focus on the window) sets focus on that window. But something doesnt work #Include <WinAPI.au3> sleep(3000) $handle = WinGetHandle("WinGetTitle()", "");get the title of the active window sleep(6000) WinActivate("$handle");switch to the window with the title I got above Anyone have an idea about whats wrong?
monoceres Posted April 14, 2008 Posted April 14, 2008 You know when you wrap something up in quotes the things inside is treated as plain text. Also you can't use WinActivate with handles, here's how you could do it: $handle=WinGetHandle(WinGetTitle("")) $list=WinList() For $i=0 To UBound($list)-1 If $handle=$list[$i][1] Then WinActivate($list[$i][0]) ExitLoop EndIf Next Broken link? PM me and I'll send you the file!
Monamo Posted April 14, 2008 Posted April 14, 2008 (edited) Also you can't use WinActivate with handlesActually, yes you can. @illya The problem wholly lies in your usage of quotes. In your code example, you have: $handle = WinGetHandle("WinGetTitle()", "");get the title of the active window Two quotation mark issues: Don't wrap your function name within quotes (RE: "WinGetTitle()")Use empty quotes ("") inside your call to WinGetTitle when trying to get the "active" window's handleCorrected code involves both changes to that particular line, as follows: $handle = WinGetHandle(WinGetTitle("")) Edit: details clarification Edited April 14, 2008 by Monamo - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]
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