Page 1 of 1
RunProgram() Question
Posted: Fri Oct 10, 2025 9:06 pm
by swhite
In the WriteProgramString() documentation it states:
The program to use. It must have been started before with RunProgram() and the #PB_Program_Write flag.
Now lets assume I have a program called RunProgramMgr() that uses RunProgram(MyProgram). Is there a way to have MyProgram write data back to the RunProgramMgr()'s stdIn even though it was not started by RunProgram()? I know I could always write data to a file but I am curious about whether stdIn can be used.
Thanks,
Simon
Re: RunProgram() Question
Posted: Fri Oct 10, 2025 9:56 pm
by Randy Walker
swhite wrote: Fri Oct 10, 2025 9:06 pm
In the WriteProgramString() documentation it states:
The program to use. It must have been started before with RunProgram() and the #PB_Program_Write flag.
Now lets assume I have a program called RunProgramMgr() that uses RunProgram(MyProgram). Is there a way to have MyProgram write data back to the RunProgramMgr()'s stdIn even though it was not started by RunProgram()? I know I could always write data to a file but I am curious about whether stdIn can be used.
Thanks,
Simon
Hi Simon... I think what you are trying to do is get two separate apps that you created to communicate data with each other. I thought I had a similar need a while back and decided DDE might be the answer, which led me to this thread and might help you:
viewtopic.php?p=627839#p627839
Turned out a better solution
for me was to consolidate my two apps into a single app by effectively merging one app into the other using threads.
Re: RunProgram() Question
Posted: Sat Oct 11, 2025 10:30 am
by mk-soft
Pipes ...
Re: RunProgram() Question
Posted: Sat Oct 11, 2025 10:48 am
by Piero
…also, in theory (I never tried):
"#PB_Program_Connect: Connect another programs output to this programs input."
"When using the #PB_Program_Connect flag, another program must have been started before with #PB_Program_Open and #PB_Program_Read. The number returned when running this program must be passed as the 'SenderProgram' parameter to RunProgram()."
PS: Ooops, I see now that you said "not started with runprogram", so this would probably not help
PPS: There can be various "problems" to get what you need with pipes (shell), e.g., program may need to be run in interactive mode, or you may need its PID………
Re: RunProgram() Question
Posted: Sat Oct 11, 2025 11:19 am
by Axolotl
Well, stdin, stdout, and stderr are usually intended for console applications.
Nevertheless at the Win32 layer, those 3 handles are returned by
GetStdHandle_()
I guess you need the API ReadFile_() and WriteFile_() functions to get it running. (educated guess, never tried)
Re: RunProgram() Question
Posted: Sat Oct 11, 2025 11:31 am
by Piero
Axolotl wrote: Sat Oct 11, 2025 11:19 am
Well, stdin, stdout, and stderr are usually intended for console applications.
Nevertheless at the Win32 layer, those 3 handles are returned by
GetStdHandle_()
I guess you need the API ReadFile_() and WriteFile_() functions to get it running. (educated guess, never tried)
I dunno **** about win API, but GetStdHandle_ seems more for "general devices" (not apps); hope I'm wrong
Re: RunProgram() Question
Posted: Sat Oct 11, 2025 11:53 am
by Axolotl
Oh, I am not sure if you are on window or others?
But if so, this might be interests you.... (Attention it is C/C++)
Creating a Child Process with Redirected Input and Output
@Piero: I agree, you are wrong. Please follow the link.
Re: RunProgram() Question
Posted: Sat Oct 11, 2025 1:18 pm
by Piero
Please forgive me; I don't have time to analyze your example code properly, but it SEEMS to me it's not direct inter-applications communication; just kinda filtering general stdout (hope I'm wrong)
PS:
Code: Select all
tell "PB Forum" to tell "Axolotl" to please forgive "Piero"