Jump to content

Exit out of while loop, dependant on Run command


Zuldan
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...