Page 1 of 1

ProgramRunning()

Posted: Wed Jun 06, 2012 4:09 am
by J. Baker
It appears that ProgramRunning() quits returning a positive value, even if the app is still running.

Code: Select all

Preview = RunProgram("open", "-a Preview", "", #PB_Program_Open)

 If Preview
  
   While ProgramRunning(Preview) > 0
    
    Debug ProgramRunning(Preview)
    
    Delay(1)
    
   Wend
  
    Debug "No longer running"
   
 EndIf
  
End

Re: ProgramRunning()

Posted: Wed Aug 08, 2012 2:15 pm
by Fred
It seems to work OK here. 'open' quits as soon than the other program is launched, so it's not running anymore PB wise. Or do I miss something ? Can anyone confirm ?

Re: ProgramRunning()

Posted: Sat Aug 11, 2012 5:38 am
by J. Baker
Fred wrote:It seems to work OK here. 'open' quits as soon than the other program is launched, so it's not running anymore PB wise. Or do I miss something ? Can anyone confirm ?
I thought that ProgramRunning() would keep checking to see if it's running until the app is no longer running. If "open" quits shortly after like you said, is there a reason why it does?

Also, can anyone else confirm?

Re: ProgramRunning()

Posted: Sat Aug 11, 2012 10:46 am
by Fred
Just open a Terminal and see the behaviour. 'open' just spawn a new process and gives back the prompt. There is a flag to wait until the app ends: -W

Code: Select all

Preview = RunProgram("open", "-W -a Preview", "", #PB_Program_Open)

Re: ProgramRunning()

Posted: Sat Aug 11, 2012 1:12 pm
by J. Baker
Thanks Fred, I'll try it out. ;)