Sign in to follow this  
Followers 0

RUN and the possibility of existing equal windows

3 posts in this topic

#1 ·  Posted (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!


A 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.


Is 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
    $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
If WinActivate($hnd) Then

There 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 by solithus

Share this post

Link to post
Share on other sites

#3 ·  Posted (edited)

Maybe could help you ?

Edit : link-error

Edited by Helge

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