Run command with timeout

Started by erezpaz, September 02, 2016, 12:42:56 PM

Previous topic - Next topic

erezpaz

Hi

I want to run an external script and wait for it 1 min. If it wont end continue the process. I cannot control the script content so I don't know how much time it will run.
Is there a command for that?

Thanks

td

Use a Run* or ShellExecute function to start your script in an external process.  You can either call TimeDelay to suspend your main script for a specified time or create a loop structure that calls TimeDelay multiple times.   If you choose the later approach, you use a call to AppExist or WinExist inside your loop to exit the loop and continue processing if your second process/script ends before the allotted maximum time.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

morenos1

Kind of:

;Thus DefineFunction may be used
#DefineFunction   DoItToIt(MyDialogHandle,MyDialogMessage,MyDialogControlID,param4,param5)
InitDialog = 0
TimerTick  = 1
 
   Switch MyDialogMessage

          Case InitDialog   ; Init_Dialog  (case number 0 subject to change on implementation)
               DialogProcOptions(MyDialogHandle,TimerTick, 1000)   ; enable 1 second timer events
               Return (-1)
   
          Case TimerTick
               Clock=DialogControlGet(MyDialogHandle, 3, 4)
               Clock=Clock-1
               If Clock==0 Then Return(2) ; exit, buttonpushed==2
               DialogControlSet(MyDialogHandle, 3, 4, Clock)
               Return(-1)
   
   EndSwitch ; MyDialogMessage
   Return(-1) ; Do default processing
#EndFunction


MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=78
MyDialogY=129
MyDialogWidth=121
MyDialogHeight=117
MyDialogNumControls=3
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT`
MyDialogProcedure="DoItToIt" ;;;;;;;;;;;;;;;;added line

MyDialog001=`12,82,35,14,PUSHBUTTON,DEFAULT,"OK",1,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`66,82,35,14,PUSHBUTTON,DEFAULT,"Cancel",0,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`22,15,71,53,VARYTEXT,clock,"10",DEFAULT,DEFAULT,DEFAULT,"Tahoma|49152|70|34","128|0|0",DEFAULT`

ButtonPushed=Dialog("MyDialog")

Message("ButtonPushed Results",ButtonPushed)

Exit