Jump to content

Stopping a running compiled script while a external progamms runs


pcjogi
 Share

Recommended Posts

Ehm... better descriptions -> better help

as in: garbage in -> garbage out :)

Sorry, thought that was ok.

I have something like this:

While 1
  $id_msg = GUIGetMsg()
  Select
    Case $id_msg = $GUI_EVENT_CLOSE Or $id_msg = $id_menu_file_exit
      ExitLoop
    Case $id_msg = $id_button_connect Or $id_msg = $id_menu_file_connect                
      Connect()
    EndSelect
Wend

func connect()
  runwait("externalprogram.exe")
endfunc

The function connect() may take a while. In case of difficulties I do not want to wait for any timeout but cancel the connect which does not work while the externalprogramm is running.

Understandable?

Thanks

Link to comment
Share on other sites

I hope so ! Let's see. You want your externalprogram.exe to

abort, as soon as you close your script, right ?

insert this before ExitLoop in your While/Wend

If ProcessExists("externalprogram.exe") Then
   ProcessClose("externalprogram.exe")
EndIf

BTW Please read the help file on these 2 commands

to adapt the code to your program. Also, you

might want to replace RunWait by Run & WinWaitActive,

so that your script still reacts !

hope that helps (not tested, YMMV)

Link to comment
Share on other sites

I hope so ! Let's see. You want your externalprogram.exe to

abort, as soon as you close your script, right ?

insert this before ExitLoop in your While/Wend

If ProcessExists("externalprogram.exe") Then
   ProcessClose("externalprogram.exe")
EndIf

BTW Please read the help file on these 2 commands

to adapt the code to your program. Also, you

might want to replace RunWait by Run & WinWaitActive,

so that your script still reacts !

hope that helps (not tested, YMMV)

Thanks, but the externalprogram.exe is an DOS application which I want to run hidden. Therefor WinWaitActive would not work. Any further ideas?

Thanks

Link to comment
Share on other sites

runwait is going to block the script until it's done running. Two possible options are:

1. Not block the script by using run() instead and then manually detect in a loop when the program finishes (ProcessExists() or WinExists() are viable here). In this loop you could then allow your script to handle other input (like pressing 'X').

2. Use a seperate thread (or a seperate 'proccess' by using a co-routine UDF) to run the blocking part and monitor it from the other thread/proccess.

Edited by evilertoaster
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...