Hi there
How can Pure Basic knows if an external Programme is closed?
What i want to do is, use Pure Basic to add as a bridge of communicatzion between two programme. One application will send text strings to a second applicatzion on starting my small pure basic application. And when the second application is closed, the text string from a text field in the second application will be copied back to the first application. Pure basic will have to know when the user closes the application and catches the text string in the second applicatio to send back to the first before the second application is closed.
So my question is how can Pure Basic know when the user closes the second application?
Thanks in advance
Cecil
How Pure Basic catches an application close event?
-
cecilcheah
- Enthusiast

- Posts: 168
- Joined: Wed Jun 04, 2003 8:44 am
- Location: Switzerland
Re: How Pure Basic catches an application close event?
> How can Pure Basic knows if an external Programme is closed?
If the external app has a static (non-changing) window title, you could
periodically check to see if it's still open. Start Notepad, then run this
to see what I mean:
If the external app has a static (non-changing) window title, you could
periodically check to see if it's still open. Start Notepad, then run this
to see what I mean:
Code: Select all
Repeat : Sleep_(1) : Until FindWindow_(0,"Untitled - Notepad")=0
Debug "Notepad has just closed!"
If I understand right, you need to know when the second app is about to
be closed, but still open, in order to read the string, is that corerect?
I don't know if that is possible.
However, starting an app from PureBasic, and finding out, if it has ended
(by the time it allready has ended) is easy:
Therefore, the app doesn't need any windows, but you have to start it
with RunProgram(), and the problem is, you can't take any actions on
that program anymore, because it allready ended.
Timo
be closed, but still open, in order to read the string, is that corerect?
I don't know if that is possible.
However, starting an app from PureBasic, and finding out, if it has ended
(by the time it allready has ended) is easy:
Code: Select all
; when starting the app
ProcessId = Runprogram(...)
;
; in your loop
GetExitCodeProcess_(ProcessID, @ExitCode.l)
If ExitCode <> #STATUS_PENDING
;
; the app has closed
;
EndIf
with RunProgram(), and the problem is, you can't take any actions on
that program anymore, because it allready ended.
Timo
quidquid Latine dictum sit altum videtur
>If I understand right, you need to know when the second app is about to
> be closed, but still open, in order to read the string, is that corerect?
You're right -- I didn't notice (at first) that cecilcheah needs to read a text
gadget from the second app before it closes. So... why not just use my tip
and periodically poll the text gadget, so that when it closes, you'll know the
gadget's final text?
> be closed, but still open, in order to read the string, is that corerect?
You're right -- I didn't notice (at first) that cecilcheah needs to read a text
gadget from the second app before it closes. So... why not just use my tip
and periodically poll the text gadget, so that when it closes, you'll know the
gadget's final text?
