Sign in to follow this  
Followers 0
pcjogi

Stopping a running compiled script while a external progamms runs

8 posts in this topic

Hi,

I am locking for a way to stop (abort) a running script with only pressing the X while an external program is running.

Thanks

Share this post


Link to post
Share on other sites



Ehm... better descriptions -> better help

as in: garbage in -> garbage out :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Ehm... better descriptions -> better help

as in: garbage in -> garbage out

what's the 'DOS program' ?

Share this post


Link to post
Share on other sites

what's the 'DOS program' ?

It is the CISCO VPN Client (vpnclient.exe)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

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