Sign in to follow this  
Followers 0
Zuldan

Exit out of while loop, dependant on Run command

3 posts in this topic

Ok I got a tricky problem. I have the following code....

------------------------------

Run("myfile.exe")

while 1

WinWaitActive("Sever")

Send("{ENTER}")

wend

------------------------------

I only want the while loop to run while myfile.exe is running. Once myfile.exe has finished executing I want to exit out of the while loop.

Does anyone have any ideas on how I could do this? Maybe I'm approaching it the wrong way.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Ok I got a tricky problem. I have the following code....

------------------------------

Run("myfile.exe")

while 1

WinWaitActive("Sever")

Send("{ENTER}")

wend

------------------------------

I only want the while loop to run while myfile.exe is running. Once myfile.exe has finished executing I want to exit out of the while loop.

Does anyone have any ideas on how I could do this? Maybe I'm approaching it the wrong way.

Hi,

$pid = Run("myfile.exe")

While ProcessExists ($pid)
    WinWaitActive("Sever") 
    Send("{ENTER}")
    Sleep (20)
WEnd

But it doesn't seem to make sense, because it is not clear what happen after the Send command.

-> If the exe still runs, then the loop will run and if the window Sever still exists, the Send is still executing.

Suggestion:

$pid = Run("myfile.exe")
$benter = True
While ProcessExists ($pid)
    If $benter Then 
        WinWaitActive("Sever")
        Send("{ENTER}")
        $benter = False
    EndIf
    Sleep (20)
WEnd

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites

Thank you Stefan! You solved my problem and many other problems I was having with other scripts.

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