solithus Posted August 30, 2006 Share Posted August 30, 2006 (edited) Let me begin by applauding the developer(s) of AutoIt: *clap clap*. I just started using it yesterday and am already a big fan!ProblemA while ago I wrote a vbscript that - among other things - opens an application I work with (let's call it EXAMPLE.EXE). I'm rewriting it in AutoIt and trying to making sure I'm activating the right window, not the ones that possibly already exist. However, all instances share the same windowtitle and classname.QuestionIs the code below a good (failsafe) way to go or is it overdoing it?$pid = Run("\\server\EXAMPLE.EXE") For $try = 1 To 20 ; give the window some time to appear Sleep(250) $arr = WinList(WinGetTitle("EXAMPLE")) $num = $arr[0][0] For $win = 1 To $num $ttl = $arr[$win][0] If WinGetProcess($ttl) == $pid Then ; If this equals our run process id $hnd = $arr[$win][1] ; then we get our unique window handle $try = 20 ; and we're done with trying ExitLoop ; so we don't have to check the other windows EndIf Next Next If WinActivate($hnd) Then Send("{ENTER}") EndIfThere must be a thread around here somewhere that discusses this, but I couldn't find it between all the help im noob!!1 topics. Anyway, you're help is appreciated. Edited August 30, 2006 by solithus Link to comment Share on other sites More sharing options...
solithus Posted September 1, 2006 Author Share Posted September 1, 2006 Link to comment Share on other sites More sharing options...
Helge Posted September 1, 2006 Share Posted September 1, 2006 (edited) Maybe http://www.autoitscript.com/fileman/users/Helge/udfs/_ProcessGetHWnd.au3 could help you ?Edit : link-error Edited September 1, 2006 by Helge Link to comment Share on other sites More sharing options...
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