Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run a program, wait for exit, run again ...
#1
I am trying to decide which to use regarding the RUN command. According to your examples on the help file, both are dependable. What is you suggestion? I am a transcriptionist and edits files in Notepad. I run many different macros and functions and as a practice, closes Notepad and reopens it for the next file. What I would like to have is to automate this procedure, to open Notepad automatically, but making sure it was closed properly in the first place before it opens it again. And also, to have it timeout for like 10 seconds if its not up yet, so that the macro can decide what to do next. In this case, run it again.

The following is what I have so far. I appreciate any comments you may have.

Code:
Copy      Help
;Run program and max. 10 seconds wait until it will fully loads
run "notepad.exe"; wait 10 P


;or
; Run notepad and wait until it exits:
int hProcess=run("notepad.exe")
wait 0 H hProcess; CloseHandle hProcess


Could you also explain what "CloseHandle" means?

Thank you
#2
To insert run command, you can use "Run program" dialog. Specify window to wait for, and also select "wait for exit".

Code:
Copy      Help
rep
,run "notepad.exe" "" "" "" 0xC00 "Notepad"

Process handle can be used with Windows API functions. It must be closed when already not needed.
#3
Oh cool. Didn't know it was in the toolbar. I should play more with the toolbar.

One last question. What do you mean by "Wait for Exit"
#4
It is an option in the Run Program dialog. It maybe missing if you have older QM version. Download QM 2.1.8, or use code with wait and CloseHandle.
#5
Oh I found it. I am using Quick Macros 216 and it's in there also.

Is there also a way to check if the program is completely closed out? I use clo "Notepad" to close Notepad, but to be cautious, I would like to know if it is completely closed out. Just because the Window does not exists, does not mean it is gone from task manager. Sometimes, the programs do hang.

Thank you
#6
run waits until the process is completely closed.
#7
I found it in the help file:

Code:
Copy      Help
run "notepad.exe" "" "" "" 0x400

Will this solve the problem of hang application though? Is there no way to check if the application is still running in Task Manager even after it's been closed? If still running, forcely close it?
#8
To close hung process, use function ShutDownProcess2. You'll find it in one of recent posts here. To only check whether the process is running, use function GetProcessId. It returns process id if running, or 0 if not.
#9
Yes, I found it and posted!


Forum Jump:


Users browsing this thread: 1 Guest(s)