Jump to content
njkone

How to return value from Child process

Recommended Posts

njkone

Hi,  sorry for My English, 

I would Like to create a simple script2.exe child that return a generic number value in script1 father and read this value through stdoutread(). 

What can i write in script2.exe to return the value? 

Thanks guys 

Share this post


Link to post
Share on other sites
Danyfirex

If is a Integer Number you can use Exit.

 

App 1 retuns number.

Exit 12345

App 2 Get the number

Local $iNumber=ShellExecuteWait("App1.exe")

 

Saludos

Edited by Danyfirex

Share this post


Link to post
Share on other sites
njkone

Thanks for reply

my script2.exe contain this code

#include <Array.au3>
#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <Constants.au3>

While 1

for $y=150 to 630

    $emay=PixelGetColor(736,$y)
    $emay2=PixelGetColor(739,$y)
    $emay3=PixelGetColor(742,$y)
    $emay4=PixelGetColor(744,$y)
    $emay5=PixelGetColor(746,$y)
    $emay6=PixelGetColor(748,$y)
    $emay7=PixelGetColor(750,$y)
    $emay8=PixelGetColor(752,$y)
    

    if $emay>15800000 or $emay2>15800000 or $emay3>15800000 or $emay4>15800000 or $emay5>15800000 or $emay6>15800000 or $emay7>15800000 or $emay8>15800000     Then
       $y -= 25
    EndIf

Next

WEnd

can i return the $y value ?

in main program this is the code:

$pid=Run("script2.exe","",$STDOUT_CHILD)
Sleep(500)
$out=StdoutRead($pid)

 

Share this post


Link to post
Share on other sites
Danyfirex

I meant this.

;Child Script
Local $iY=Random(-100,100,1)
Exit $iY



;father Script
Local $iY=ShellExecuteWait("child.exe")
MsgBox(0,"","Y value returned from Child: " & $iY)

 

 

Saludos

Share this post


Link to post
Share on other sites
njkone

yes i understand,

how can i return the $y form the while loop childr process?

Share this post


Link to post
Share on other sites
Danyfirex

Read help File.

 

Saludos

Share this post


Link to post
Share on other sites
njkone

 

ok, but i go not know what to look in the help file.

i'd like to know what function i can use in the child process to return value and in the fhater process to read value, but not close the process child.

thank you all.

Share this post


Link to post
Share on other sites
Danyfirex

mmm I see. Probably you need another way. Do a google search about comunication between procress. There is many examples around the forum.

 

 

Saludos

Share this post


Link to post
Share on other sites
njkone

i tried solutions before opening the topic but i did not find anything.

i expect other answers, do not have other choice.

thank you all.

Share this post


Link to post
Share on other sites
BrewManNH

Search for IPC or Inter Process Communication in the forum.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
njkone

thank you for the reply,

i tried ipc but is very complicated for me.

in summary i need a way to communicate 2 process, the child process contains the value and the father process read this value(in the child), for more times (loop).  

is there a simple way? example : send message from child to father? message= number value. 

Share this post


Link to post
Share on other sites
njkone

thank you for reply,

i need to receive a single variable automatically from children to father.

do you think i can change it for my purpose? 

Share this post


Link to post
Share on other sites
BrewManNH

Write to a file from the child, read it from the parent process if everything else is more than you need.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
njkone
2 hours ago, BrewManNH said:

Write to a file from the child, read it from the parent process if everything else is more than you need.

do you refer to the way MailSlot? or other? 

Share this post


Link to post
Share on other sites
RTFC
8 hours ago, njkone said:

do you refer to the way MailSlot?

No. Look up Iniwrite and IniRead in the Help file, if you don't want to use MailSlot.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.