Page 1 of 1
Posted: Fri Apr 11, 2003 4:58 pm
by BackupUser
Restored from previous forum. Originally posted by cisc.
try to start two programs with RunProgram(). The first runs, but not the second.
Is this not possible with PB or is my code wrong?
Here it is:
Code: Select all
ProgramName.s = "Excel.exe" ; Executable file name
Ergebnis = RunProgram(ProgramName);Excel should start
MessageRequester("Info",Str(Ergebnis),0);just to see it passed
Ergebnis = RunProgram("D:\\outlook express\MSIMN.EXE");OE should start
MessageRequester("Info",Str(Ergebnis),0);but it never does
Every Run for itselfe does work, but not both.
What´s wrong, or is there any other solution?
Posted: Fri Apr 11, 2003 5:07 pm
by BackupUser
Restored from previous forum. Originally posted by dmoc.
Try a delay between the two
Posted: Fri Apr 11, 2003 5:33 pm
by BackupUser
Restored from previous forum. Originally posted by cisc.
Originally posted by dmoc
Try a delay between the two
MessageRequester should do, but I already tried it.
Same Effect.
Posted: Fri Apr 11, 2003 5:55 pm
by BackupUser
Restored from previous forum. Originally posted by ricardo.
Once i VB i has some similar problem and i use WaitForaSingleObject API to know when the application is running and then i can run the second one, this happens to me trying to run slow applications (slow to open) like Excell, etc.
Best Regards
Ricardo
Dont cry for me Argentina...
Posted: Fri Apr 11, 2003 6:14 pm
by BackupUser
Restored from previous forum. Originally posted by cisc.
Originally posted by ricardo
Once i VB i has some similar problem and i use WaitForaSingleObject API to know when the application is running and then i can run the second one, this happens to me trying to run slow applications (slow to open) like Excell, etc.
Best Regards
Ricardo
Dont cry for me Argentina...
Thank you both, dmoc and ricardo for your quick answers.
I will try it. But it´l take some time because i am a very beginner in PB just used to VB.
However the WaitForSingleObject function awaits a dwMilliseconds parameter. This seems to affect the same as delay().
We will see.
--cisc
Posted: Fri Apr 11, 2003 6:39 pm
by BackupUser
Restored from previous forum. Originally posted by dmoc.
cisc, I tried the following and it works ok. I also tried a program in the "Program Files" directory and it was ok. You try this and tell me what happens...
Code: Select all
ProgramName.s = "notepad.exe" ; Executable file name
Ergebnis = RunProgram(ProgramName);Excel should start
Ergebnis = RunProgram("write.exe");OE should start
Posted: Sat Apr 12, 2003 1:00 am
by BackupUser
Restored from previous forum. Originally posted by PB.
Your example fails for me, too. But as dmoc said, if you remove the MessageRequesters
then it works (both apps are launched). Also, the problem only occurs if you test your
app in the compiler -- if you make an exe and run that, it works fine (even if you leave
the MessageRequesters in).
Posted: Sat Apr 12, 2003 9:12 am
by BackupUser
Restored from previous forum. Originally posted by cisc.
the example from dmoc fails with and without MessageRequesters in my test!?
But it is the compiler. An exe does the work fine
Thanks for your help. I am glad I spared the work with the WaitForSingleObject, with the window handles and all this stuff. Would have been quite much for this little problem - I just wanted to begin in PB with starting a spamproxy and then OutlookExpr., do OE and with closing the window, the SpamProxy should close too.
Just to do something helpful and beginning with PB and making it out fast.
cisc
Posted: Sat Apr 12, 2003 9:30 am
by BackupUser
Restored from previous forum. Originally posted by cisc.
yeah it works now. Here´s the code:
Code: Select all
#STANDARD_RIGHTS_REQUIRED = $000F0000
#SYNCHRONIZE = $00100000
#PROCESS_ALL_ACCESS = #STANDARD_RIGHTS_REQUIRED+#SYNCHRONIZE+$0FFF
ProgEins.s="D:\\spamproxy\SPAMPRXY.EXE"
WinTitleEins.s="SpamProxy (Alpha)"
ProgZwei.s = "D:\\outlook express\MSIMN.EXE"
Ergebnis = RunProgram(ProgEins)
;MessageRequester("Info",Str(Ergebnis),0)
Ergebnis = RunProgram(ProgZwei,"","",1)
;If Ergebnis=0
; MessageRequester("Done?", WinTitleZwei+" scheisse", 0)
;EndIf
ProcessId.l
ExitCode.l
hWindow = FindWindow_(0, WinTitleEins)
If hWindow =0
MessageRequester("Done?", WinTitleEins+" scheisse", 0)
Goto aus
EndIf
Ergebnis = GetWindowThreadProcessId_(hWindow, @ProcessId)
If Ergebnis=0
MessageRequester("Done?", Str(hWindow)+" Window scheisse", 0)
Goto aus
EndIf
hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #TRUE, ProcessId)
If Ergebnis=0
MessageRequester("Done?", Str(hProcess)+" Process scheisse", 0)
Goto aus
EndIf
If GetExitCodeProcess_(hProcess, @ExitCode) = 0
MessageRequester("Done?", Str(hProcess)+" GetExitCodeProcess scheisse", 0)
Goto aus
EndIf
;ExitProcess_(ExitCode) 0
If TerminateProcess_(hProcess, ExitCode)
MessageRequester("Done?", "has been killed.", 0)
Else
MessageRequester("Done?", Str(hProcess)+" TerminateProcess scheisse", 0)
EndIf
aus:
End
The only little blemish is the icon from SpamProxy remaining in the info bar until mouse is moved over. Seems, terminating the process is not the very best - but how else can it be stopped?

cisc
Posted: Sun Apr 13, 2003 1:04 am
by BackupUser
Restored from previous forum. Originally posted by PB.
> the example from dmoc fails with and without MessageRequesters in my test!?
Strange. I'm using W2K Pro and both apps are launched from the compiler if the
MessageRequesters are left out. What OS are you running?
Posted: Sun Apr 13, 2003 10:56 pm
by BackupUser
Restored from previous forum. Originally posted by cisc.
Originally posted by PB
> the example from dmoc fails with and without MessageRequesters in my test!?
Strange. I'm using W2K Pro and both apps are launched from the compiler if the
MessageRequesters are left out. What OS are you running?
XP Pro

. It hangs at the second Prog start. See the Debug Window below.
But it only was for testing and compiled it works, so.....
Posted: Sun Apr 13, 2003 11:27 pm
by BackupUser
Restored from previous forum. Originally posted by cisc.
>The only little blemish is the icon from SpamProxy remaining in the >info bar until mouse is moved over. Seems, terminating the process >is not the very best - but how else can it be stopped?
Maybe it´s intresting for some newbies like me.
A better way to quit a running process or window (and to get rid of the tray-icon) is with
Code: Select all
winHwnd = FindWindow_(0, WinTitle);to find the Handle
PostMessage_(winHwnd,#wm_close,0,0);to close it
Two lines instead of the 26 before.
It took me some time to find this information and I had the same problem some time ago in VB and didn´t find anything.
It can be so easy if one knows how.