JohnOne Posted May 15, 2010 Posted May 15, 2010 (edited) Im wanting to start having a go at using these to comunicate dynemicaly with scripts/execs. Problem is I cant even get off the geound, because I just cant understand it. In both examples in the helpfile there is a Run() function to get the PID of the app it wants to comunicate with. I get that, if one of them has the Run() in it but how can they both have a function to run each other, I just dont get it at all, one runs the other which in turn runs the one that run itself ? My goal it to have appA run appB and collect data from from it through the stream. I thought I was on the right track using EnvSet/Get until I realised I couldnt set and get a variable from a function on the fly. Can anyone explain this in a fashion that numbskull can understand ? I'd appreciate it. Edited May 15, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
DW1 Posted May 15, 2010 Posted May 15, 2010 (edited) Compile both of these and run AppA.exe AppA will read the Stdout from AppB and then just take the last line/number and display it in the GUI. I hope this example helps you. AppA #include <GUIConstantsEx.au3> #include <Constants.au3> $GUI = GUICreate("AppA", 200, 150, @DesktopWidth/2 - 215) $Label = GUICtrlCreateLabel('', 0, 65, 200, 20, 0x01) GUISetState(@SW_SHOW) If FileExists("AppB.exe") Then $Run = Run("AppB.exe", "", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) Else MsgBox(0, "Error", "AppB.exe Not found!") Exit EndIf While ProcessExists($Run) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $Read = StdoutRead($Run) $aRead = StringSplit($Read, @CRLF) GUICtrlSetData($Label, $aRead[$aRead[0]]) Sleep(10) WEnd AppB #include <GUIConstantsEx.au3> $GUI = GUICreate("AppB", 200, 150, @DesktopWidth/2) $Label = GUICtrlCreateLabel('', 0, 65, 200, 20, 0x01) $pid = ProcessExists("AppA.exe") If $pid <> 0 Then $A = 0 GUISetState(@SW_SHOW) Else MsgBox(0, "Error", "Run from AppA.exe") Exit EndIf While ProcessExists($pid) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $A += 1 GUICtrlSetData($Label, $A) ConsoleWrite(@CRLF & $A) Sleep(10) WEnd Edited May 15, 2010 by danwilli AutoIt3 Online Help
JohnOne Posted May 15, 2010 Author Posted May 15, 2010 danwilli Yes it helped enormously. Thank you very kindly, appreciated. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now