Jump to content
Sign in to follow this  
tatane

Communication between 2 scripts

Recommended Posts

Hi,

I would like to send an array from a script to a another. This array has 1000 rows and 4 columns with this kind of data :

1st row  =     528  ;  31  ;   HOSTNAME|1|02:45:47|abcdefgh|username|5   ;   old

2nd row = ...

What IPC should I use ?

 

 

Share this post


Link to post
Share on other sites

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

I think it could be a situation of parent - child communication between 2 processes (compiled scripts).

with the use of consoleread / consolewrite and stdin / stdout

we will need more info to help you out

Edited by Nine

Share this post


Link to post
Share on other sites
34 minutes ago, ViciousXUSMC said:

It's not perfect real time but should work in most cases.

But if you need real time, you could use @ViciousXUSMC idea combine with a simple protocol using my approach of parent-child inter-process communication. 

Share this post


Link to post
Share on other sites

Hi tatane :)


Here are 2 scripts showing how to pass a 2 Dimension Array from a script to another.
With the help of jguinch's ArrayMultiDim.au3, it's possible, here is the link of his work :

https://www.autoitscript.com/forum/topic/179779-_arraydeclarefromstring-_arraytodeclarationstring-_arrayshufflemultidim-_arraycompare-_arrayenumvalues-_arrayassign/

He's got a function that transposes the whole Array into a String, it's the String that will be passed as a Parameter from a script to the other. Then a 2nd function will transpose the String back to an Array, job done !

I attach at the end of this post jguinch's ArrayMultiDim.au3 but it's a good idea to read what he said about all the functions he created. After download, just place his file ArrayMultiDim.au3 in the same folder as the 2 scripts below, named "script part1.au3" and "script part2.au3"

; This is "script part1.au3"
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <ArrayMultiDim.au3> ; Author jguinch

Local $aArray[3][4]
For $row = 0 to 2
    For $col = 0 to 3
        $aArray[$row][$col] = $row & ":" & $col
    Next
Next

_ArrayDisplay($aArray, "in script 1 : Array", "", $ARRAYDISPLAY_COLALIGNCENTER)

Local $sStringFromArray = _ArrayToDeclarationString($aArray)
MsgBox($MB_TOPMOST, "in script 1 : String From Array", $sStringFromArray)

$iPID = Run(@AutoItExe & " /AutoIt3ExecuteScript " & chr(34) & @ScriptDir & "\script part2.au3" & chr(34) & _
    " " & $sStringFromArray)

If $iPID = 0 Then
   MsgBox($MB_TOPMOST, "Error", "'script part2' didn't lauch")
   Exit
Else
   ProcessWaitClose($iPID)
   MsgBox($MB_TOPMOST, "Back to script 1", "Great : this message shows only after 'script part2' has ended !")
EndIf

script1-a.jpg.67fb41b4a8f60479bc8af9919c540c10.jpgscript1-b.jpg.be621c538060999d62a516af284d41fe.jpg

; This is "script part2.au3"
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <ArrayMultiDim.au3> ; Author : jguinch

$sParams = "$CmdLineRaw = " & $CmdLineRaw & @CRLF
For $i = 0 To $CmdLine[0]
   $sParams &= @CRLF & "$CmdLine[" & $i & "] = " & $CmdLine[$i] & @CRLF
Next

MsgBox($MB_TOPMOST, "in script 2 : Parameters passed from 'script part1'  to  'script part2'", _
    Eval("sParams"))

MsgBox($MB_TOPMOST, "in script 2 : Right part of $CmdLineRaw", _
    StringMid($CmdLineRaw, StringInStr($CmdLineRaw, "[[")))

Local $aArray2 = _ArrayDeclareFromString(StringMid($CmdLineRaw, StringInStr($CmdLineRaw, "[[")))

_ArrayDisplay($aArray2, "in script 2 : Array2", "", $ARRAYDISPLAY_COLALIGNCENTER)
if @error = 1 Then
    MsgBox($MB_TOPMOST, "Error", "Array2 is not an array")
endif

;~ #include <WinAPIShPath.au3>
;~ Local $aData = _WinAPI_CommandLineToArgv($CmdLineRaw)
;~ _ArrayDisplay($aData, '_WinAPI_CommandLineToArgv')

script2-a.jpg.3a411427954a219687017672a19b7668.jpgscript2-b.jpg.b3c62b8ccdbe7d82c8630d1e7ead443b.jpgscript2-c.jpg.bbf6b3b06151116ccb05bb393f7126ff.jpg

Something strange is why did $CmdLine[1] lose all his double-quotes, even _WinAPI_CommandLineToArgv() which is commented at the end of script 2 shows this ! Gladly the whole string, untouched, is found in the right part of $CmdLineRaw

In case you need to pass other variables between scripts, the syntax found in the following script may help you :
https://www.autoitscript.com/forum/topic/195073-autoit3executescript-variable-space-can-a-variable-defined-in-autoit-script-be-used-in-txt-file-autoit-code/?do=findComment&comment=1398965

Good luck :)

 

ArrayMultiDim.au3

 

Share this post


Link to post
Share on other sites

Thanks everybody. I will read all your links/advices.
My first script is a tcp server and I would like a second script to handle the "data processing" by this server.
So realtime would be great.

 

EDIT : So I can't use AutoitObject because the 2 scripts will be compiled. Because of the realtime update, I can't use command line parameters neither.

The array to string function is interesting with _FileWriteFromArray.

Maybe Filemapping could be another solution :

Edit 2 : I can't make FileMapping to work with 2 compiled scripts. It works with one.

Edited by tatane

Share this post


Link to post
Share on other sites

You could also look into Dynamic Data Exchange (DDE) for interprocess communication.

 

Edited by Mobius
added dde udf link

wtfpl-badge-1.png

Share this post


Link to post
Share on other sites

Hi all :)
This may interest the readers who (as me) never used until now a compiled script to run another script. Here is the 1st test I just did, based on the 2 scripts found in my precedent post ("script part1.au3" and "script part2.au3"). Actually this is also related to tatane's topic "Communication between 2 scripts"

1) Modify "script part1.au3", changing this :

$iPID = Run(@AutoItExe & " /AutoIt3ExecuteScript " & chr(34) & @ScriptDir & "\script part2.au3" & chr(34) & " " & $sStringFromArray)

To that :

If Not @Compiled Then
    $iPID = Run(@AutoItExe & " /AutoIt3ExecuteScript " & chr(34) & @ScriptDir & "\script part2.au3" & chr(34) & " " & $sStringFromArray)
Else
    $iPID = Run(chr(34) & @ScriptDir & "\script part2.exe" & chr(34) & " " & $sStringFromArray)
EndIf

2) Compile both scripts to script part1.exe and script part2.exe

3) To make sure no source file will interfere :
Rename script part1.au3, script part2.au3, the whole C:\Program Files\AutoIt3 directory to whatever

4) Double-clic on script part1.exe and everything works fine : the chaining from script part1.exe to script part2.exe works, the array is correctly displayed in script part2.exe as in precedent post :)

5) Revert part 3) to bring back the correct scripts & AutoIt3 directory names & locations.

Now it's time to do a 2nd test, with that #pragma directive, to "allow the compiled executable to execute non compiled scripts", also I'll test .a3x during chaining etc... but anyway, this 1st test "exe => exe" with parameters passed between both .exe did work

When the 2nd test will be done, I'll post the results here, in this same post (no need to create a new post for that). Let's hope I'll be as lucky in the 2nd test as I was in this 1st one :)

Edited by pixelsearch

Share this post


Link to post
Share on other sites

The commandline idea is nice but while the OP's requirement of "1000 rows and 4 columns" might not exceed the maximum commandline length with some planning, the method would fail eventually with larger arrays including the element contents.

DDE however is true IPC and would not entail the user having to be careful of exceeding a buffer length.

Edited by Mobius

wtfpl-badge-1.png

Share this post


Link to post
Share on other sites

@Mobius :
You're right, I tested the 2 precedent scripts on "big" arrays, to find where the limit was :

Local $aArray[555][4]
For $row = 0 to 554
    $aArray[$row][0] = $row & ":" & "0"
    $aArray[$row][1] = 528
    $aArray[$row][2] = 31
    $aArray[$row][3] = "HOSTNAME|1|02:45:47|abcdefgh|username|5"
Next

[555] rows are the limit in script 1, and $array2 will be ok in script 2 when [555] rows are populated like shown.
But if you try [556] rows or more,  an error will happen in script 2, _ArrayDisplay returning @error = 1 (not an array)

So before the error happened, I copied the long variable $CmdLineRaw in a file, to test its length and analyze how it ends :

FileWrite("c:\temp\test.txt", $CmdLineRaw)

Results show that if its length is > 32Kb (that's 556 rows or more) then the error happens because it's an unterminated string.

"AutoIt3 Limits/defaults" in help file shows a 32Kb limitation in these cases :
MAX_ENVSIZE 32767 Maximum size for an ENV variable.
WINTEXTBUFFER 32767 WM_GETTEXT randomly fails if > 32767

Good to know, sky isn't always the limit :)

 

Share this post


Link to post
Share on other sites

Thanks for your time passed on looking at my demand.

Because of the frequent updating I finally chose a txt file save (write only  by the server and read only by the client).

I just convert the array to a string with the function made by jguinch.

Edited by tatane

Share this post


Link to post
Share on other sites
On 12/5/2018 at 6:10 AM, Mobius said:

DDE however is true IPC ......

...looking around found this posting and tried the DDE. Found that it does not like the server example compiled as 64 bit.
The client example work compiled as 32 and 64bit.
I don't know anything about DLL calls. Could you fix the UDF to make it 64bit friendly ?
Thanks  :) ( the emoji is to manipulate you emotionally into doing it )  

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By argumentum
      so in https://www.autoitscript.com/forum/topic/193254-solved-ipc-between-system-and-user/ I asked around about IPCs and got all the answers I was looking for.
      Now the question is: what IPC is most "resilient" on an overwhelmed PC, meaning, the CPU is at 100%, memory is top out and, as is always, need to rely on the IPC.
      ..and all this happened because I open over 100 GUIs at once 😜
      ..but it happens sporadically on low CPU or memory demand anyways.
      ..should I sleep() some time before running another instance ?
      I did not know if to make the question in technical, chat, ..or here. So it's here.   
      Since you will ask what I've tried, I've used the IPC from the Fork UDFish ( WM_COPYDATA that can do Admin/user mix ) and the FMIPC file mapping,  that work under the same conditions.
      So, how do you handle IPC if it fails ?
       
    • By argumentum
      I was in need of an IPC (Interprocess communication) between system, admin and user levels, and ended up writing this UDF to suit my wantings.
      Hope you find it useful too.
      Works from WinXP/Server2003 to the now current Win10/Server2016.
      It communicates between any mix of x32, x64, Admin, User.

      In the zip file, there is the UDF and an example: FMIPC(v0.2018.04.04).zip
      Special thanks to @RTFC for the help in the support forum   
    • By argumentum
      There is this topic on Examples about IPC. My question is: What is the best IPC to work with between a script running as SYSTEM level, User level, and Administrator level to interact with each other ? 
      Thanks
    • By JohnWIlling
      IPC_IO.AU3
      I am in the need for a simple synchronous Client/Server communication.  I found several examples and references to various kinds of Inter-Process Communications such as TCP, Named Pipes, Mail Slots, Shared Memory, Memory Mapped Files, and simple Files.  I wanted to see what the best solutions would be.  I began developing a library and slowly began adding each of the IPC methods and ended up with a library with a very simple synchronous “ASCII” API where the application can choose which method to use at startup.
      For the Server side, a Server app must initialize communication by calling:
      Func InitConnection($cType = $cDefaultType, $ResourceName = "", $bBlock = $cDefaultBlocking, $fSleepFunc = "", $iBufSize = $DEFAULT_BUFSIZE)
      The optional arguments allow the app to specify the connection type (such as: $cNamedPipe, $cFile, $cTCP, $cSharedMem, $cMailSlot), a value for the resource name (such as the file, named pipe name, TCP port number, etc.), the communication buffer size, and a callback function for when the “read” is waiting for data.
      A “File Descriptor” is returned and must be used in the future API calls.
      The Server side must then call:
      Func StartConnection($iFD)
      This call waits for a Client to connect.  The Server then calls:
                      Func ReadData($iFD, ByRef $sData)
      To read a Request from the Client and then calls:
                      Func WriteData($iFD, ByRef $sData)
      To send the reply back to the Client.
      When communication with the Client is done, the Server app will call:
      Func StopConnection($iFD)
      When the Server app is done with the communications it will call:
      Func EndConnection($iFD)
       
      For the Client side, a Client app must open the communication by calling:
      Func OpenConnection($cType = $cDefaultType, $ResourceName = "", $bBlock = $cDefaultBlocking, $fSleepFunc = "", $iBufSize = $DEFAULT_BUFSIZE)
      The optional arguments allow the app to specify the connection type (such as: $cNamedPipe, $cFile, $cTCP, $cSharedMem, $cMailSlot), a value for the resource name (such as the file, named pipe name, TCP port number, etc.), the communication buffer size, and a callback function for when the “read” is waiting for data.
      A “File Descriptor” is returned and must be used in the future API calls.
      The Client side then send a request to the Server app by calling:
                      Func WriteData($iFD, ByRef $sData)
      To read a Response from the Server by calling:
                      Func ReadData($iFD, ByRef $sData)
      To end the connection to the Server by calling:
      Func CloseConnection($iFD)
       
      Within the IPC_IO.AU3 library, each IPC method is ether:
      ·         “stream” based where data is read/written by calling _WinAPI_ReadFile/TCPRecv or _WinAPI_WriteFile/ TCPSend
      ·         “direct” based for Shared memory where the Client reads the data directly from the Server App’s memory and the Server directly reads the Client App’s memory
      In processing a request, the “ReadData” process starts by checking if data is ready to be read by calling the routine: “ReadStart”, then it reads in the size of the request by calling “ReadSize”, it then reads in the Ascii Request by calling “ReadBuffer”, then the sequence is completed by calling “ReadEnd”. 
      The Write Process follows the same sequence with “WriteData” calling “WriteStart”, “WriteSize”, “WriteBuffer”, “WriteEnd”.
       
      Results
      My testing showed that the performance of sending and receiving of a 10k file took:
      ·         "Shared Memory" was the fastest, at 0.007468 Sec
      ·         “Named Pipes” at 0.015954
      ·         “Mail Slots” at 0.016427
      ·         “File Based” at 0.270287
      ·         “TCP” at 0.994884
       
      IPC_IO.au3
      Client.au3
      Server.au3
    • By dubi
      Hi,


       
      Background: i have a number of instances of the same application that I want to automate in parallel.

      Unfortunately, I cannot completely automate these instances in the background. So, from time to time these instances need to have the focus so that I can interact with the controls via “send” directly.

      Each of the application instances is controlled by a au3 complied script. Each script (called with a parameter) manages the automation of the respective application-instance. Each of the (complied) script (instances) is called by a (central) front end with a gui. The front end controls if the “focus” is available to do the “send” and “mouseclick” modifications. The central front end either allows a child to have the focus or prevents it to get the focus (in which case the child will wait and checks again). The code for the front end is included. Apologies for the lengthy explanation.


      #RequireAdmin #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIEdit.au3> #include <ScrollBarConstants.au3> #include <Array.au3> Global Const $APF_ALLOWMULTILINE = 1 Global Const $APF_RIGHTALIGN = 6 Global Const $APF_RIGHTALIGNCOL = 2 Global Const $APF_RIGHTALIGNDATA = 4 Global Const $APF_PRINTROWNUM = 8 Global Const $APF_DEFAULT = $APF_PRINTROWNUM Global $PID[9], $FocusAvailable = True, $previousEditMsg Global $PID_waiting[0][2], $logfile $logfile = "D:\MultiInstance\Logfiles\FrontEnd.txt" If FileExists($logfile) Then FileDelete($logfile) #Region ### START Koda GUI section ### Form= $hGui_1 = GUICreate("Instanzenmanager", 493, 1226, 1807, 93) $grpInst1 = GUICtrlCreateGroup(" 1 ", 8, 8, 233, 121) $btnPause01 = GUICtrlCreateCheckbox("Pause", 16, 64, 50, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $tbnStop01 = GUICtrlCreateCheckbox("Stop", 16, 96, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnMin01 = GUICtrlCreateCheckbox("Minimize", 72, 64, 66, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnWdh01 = GUICtrlCreateCheckbox("Restore", 144, 64, 90, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStart01 = GUICtrlCreateCheckbox("Start", 16, 32, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpInst3 = GUICtrlCreateGroup(" 3 ", 8, 136, 233, 121) $btnPause03 = GUICtrlCreateCheckbox("Pause", 16, 192, 50, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $tbnStop03 = GUICtrlCreateCheckbox("Stop", 16, 224, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnMin03 = GUICtrlCreateCheckbox("Minimize", 72, 192, 66, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnWdh03 = GUICtrlCreateCheckbox("Restore", 144, 192, 90, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStart03 = GUICtrlCreateCheckbox("Start", 16, 160, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpInst2 = GUICtrlCreateGroup(" 2 ", 248, 8, 233, 121) $btnPause02 = GUICtrlCreateCheckbox("Pause", 256, 64, 50, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $tbnStop02 = GUICtrlCreateCheckbox("Stop", 256, 96, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnMin02 = GUICtrlCreateCheckbox("Minimize", 312, 64, 66, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnWdh02 = GUICtrlCreateCheckbox("Restore", 384, 64, 90, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStart02 = GUICtrlCreateCheckbox("Start", 256, 32, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpInst4 = GUICtrlCreateGroup(" 4 ", 248, 136, 233, 121) $btnPause04 = GUICtrlCreateCheckbox("Pause", 256, 192, 50, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $tbnStop04 = GUICtrlCreateCheckbox("Stop", 256, 224, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnMin04 = GUICtrlCreateCheckbox("Minimize", 312, 192, 66, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnWdh04 = GUICtrlCreateCheckbox("Restore", 384, 192, 90, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStart04 = GUICtrlCreateCheckbox("Start", 256, 160, 218, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUICtrlSetBkColor(-1, 0x00FF00) $Edit1 = GUICtrlCreateEdit("", 8, 720, 473, 497) $btnPauseAll = GUICtrlCreateCheckbox("Pause all", 8, 656, 474, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) $btnStopAll = GUICtrlCreateCheckbox("Stop all", 7, 688, 474, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 CheckGuiMsg() FileWrite($logfile, @HOUR & ":" & @MIN & ":" & @SEC & "> " & "CheckGuiMsg" & @CRLF) CheckClientMessages() FileWrite($logfile, @HOUR & ":" & @MIN & ":" & @SEC & "> " & "CheckClientMessages" & @CRLF) WEnd Func CheckGuiMsg() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnStart01 AddTextToEdit("Starting Instance 1") $PID[0] = Run("D:\XVM05\Entwicklung_FilterTest_Multi_ToFileV001.exe 1", @ScriptDir, Default, 3) Case $btnStart02 AddTextToEdit("Starting Instance 2") $PID[1] = Run("D:\XVM05\Entwicklung_FilterTest_Multi_ToFileV001.exe 2", @ScriptDir, Default, 3) Case $btnStart03 AddTextToEdit("Starting Instance 3") $PID[2] = Run("D:\XVM05\Entwicklung_FilterTest_Multi_ToFileV001.exe 3", @ScriptDir, Default, 3) Case $btnStart04 AddTextToEdit("Starting Instance 4") $PID[3] = Run("D:\XVM05\Entwicklung_FilterTest_Multi_ToFileV001.exe 4", @ScriptDir, Default, 3) Case $btnPause01 AddTextToEdit("Send Pause to Instance 1") StdinWrite($PID[0], "Pause") Case $btnPause02 StdinWrite($PID[1], "Pause") Case $btnPause03 StdinWrite($PID[2], "Pause") Case $btnPause04 StdinWrite($PID[3], "Pause") Case $tbnStop01 StdinWrite($PID[0], "Stop") Case $tbnStop02 StdinWrite($PID[1], "Stop") Case $tbnStop03 StdinWrite($PID[2], "Stop") Case $tbnStop04 StdinWrite($PID[3], "Stop") Case $btnPauseAll AddTextToEdit(@CRLF & "************Pause All not yet implemented**************" & @CRLF) Case $btnStopAll AddTextToEdit(@CRLF & "************Stop All not yet implemented***************" & @CRLF) EndSwitch EndFunc ;==>CheckGuiMsg Func CheckClientMessages() For $i = 0 To 3 FileWrite($logfile, @HOUR & ":" & @MIN & ":" & @SEC & "> " & $i & @CRLF) Local $a = TimerInit() $p = $PID[$i] $streamRead = StdoutRead($p) If $streamRead <> "" Then Switch $streamRead Case StringInStr($streamRead, "Focus Needed") > 0 If $FocusAvailable Then $FocusAvailable = False StdinWrite($p, "Focus Granted") Else EndIf Case StringInStr($streamRead, "Release Focus") > 0 StdinWrite($p, "Release Focus Received") $FocusAvailable = True Case Else EndSwitch EndIf FileWrite($logfile, @HOUR & ":" & @MIN & ":" & @SEC & "> " & $i & " " & round(TimerDiff($a),2) & @CRLF) Next EndFunc ;==>CheckClientMessages Func AddTextToEdit($text) If $previousEditMsg <> $text Then $previousEditMsg = $text GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & @YEAR & "." & @MON & "." & @MDAY & " - " & @HOUR & ":" & @MIN & ":" & @SEC & "> " & $text & @CRLF) _GUICtrlEdit_Scroll($Edit1, $SB_SCROLLCARET) EndIf EndFunc ;==>AddTextToEdit



      My issue now is that the mechanism with with StdoutRead and StdinWrite is not efficient at all. The more instances I start the slower it gets. This is not just a bit slower (like a fraction of a second), but to the degree that the front end is not responding at all any longer (with 3 instances handling).

      So my questions are:

      1.       Is there a flaw in my implementation with StdoutRead and StdinWrite? (note that all works fine with 1 and also (slower) with 2 instances running) but actually breaks down with 3 instances running.

      2.       Can I optimize the currently used implementation so that I can control 30+ instances?

      3.       What other implementation do you see suitable for this approach?

      a.       I have already tried it with communication through files but observed that this is not sufficiently reliable with multiple instances.

      b.       Is Named Pipes a more performant approach (I am a bit scared of the effort to learn and implement this)

      c.       Any other method?


       
      Many thanks in advance

      -dubi





×
×
  • Create New...