Jump to content

Communicate between scripts on same pc


JohnMC
 Share

Recommended Posts

What would be the simplest most reliable method to communicate between scripts running seperatly (no parent/child relationship) on the same pc. ive looked into console write use with std, but i dont get how it would work in this instance... thanks!

I've tested script like this using two methods. One was client/server relationship using tcp and another was sharing an ini file to pass information back and forth. There was probably a better way as I made fake lock files and stuff to try to keep it all sane. Good luck and I'm interested to see what others post on this topic as well.

avery

www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
Link to comment
Share on other sites

Ok, here's an example.

Compile receive script, but don't execute it, when you compile it, go to the other script (send script), and run it (you may run it from scite or compile and then run it).

Important note: Both scripts must be in the same folder.... Also important: if you change compile name of the receive script you must change it's name in the send script as well

RECEIVE SCRIPT:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=ReceiveScript.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>

$Form1 = GUICreate("Receive commands script", 300, 400)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 300, 380)
$Button1 = GUICtrlCreateButton("Clear all", 0, 380, 150, 20)
$Button2 = GUICtrlCreateButton("Exit", 150, 380, 150, 20)
GUISetState(@SW_SHOW)

if NOT @Compiled Then
    MsgBox(0, "Compile please", "Compile this script, and then run the SEND script")
    Exit
EndIf

Global $Recieve_Data

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button2
            Exit
        Case $Button1
            GUICtrlSetData($Edit1, "")
    EndSwitch
    $Recieve_Data = ConsoleRead()
    if @error Then
        MsgBox(0, "Error", "Error occured, script will exit now")
        ExitLoop
    EndIf
    if $Recieve_Data <> "" Then
        if GUICtrlRead($Edit1) = "" Then
            GUICtrlSetData($Edit1, $Recieve_Data)
        Else
            _GUICtrlEdit_AppendText($Edit1, @CRLF & $Recieve_Data)
        EndIf
        if $Recieve_Data = "$$$EXIT_SCRIPT$$$" Then
            MsgBox(0, "Command", "Script has received command to shutdown, bye bye")
            Exit
        EndIf
    EndIf
    Sleep(10)
WEndoÝ÷ Ù!

  ôÚºÚ"µÍÚ[ÛYH  Ð]ÛÛÛÝ[Ë]LÉÝÂÚ[ÛYH   ÑY]ÛÛÝ[Ë]LÉÝÂÚ[ÛYH    ÑÕRPÛÛÝ[Ñ^]LÉÝÂÚ[ÛYH ÕÚ[ÝÜÐÛÛÝ[Ë]LÉÝÂÚ[ÛYH ÐÛÛÝ[Ë]LÉÝÂÌÍÜXÚY]WÜØÜÛ[YHH ][ÝÔXÙZ]TØÜ^I][ÝÂÌÍÑÜLHHÕRPÜX]J    ][ÝÔÙ[ÛÛ[X[ÈØÜ  ][ÝËÌ

BÌÍÒ[]HHÕRPÝÜX]R[]
    ][ÝÉ][ÝËÌ
BÌÍÐ]ÛHHÕRPÝÜX]P]Û  ][ÝÔÙ[]I][ÝËML
BÌÍÐ]ÛHÕRPÝÜX]P]Û   ][ÝÑ^]    ][ÝËMLML
BÌÍÐÛÛ[][XØ][ÛÜØÜH[ØÜ   [È ][ÝÉÌLÉ][ÝÈ   [È ÌÍÜXÚY]WÜØÜÛ[YKØÜÕ×ÔÒÕË ÌÍÔÕSÐÒS
È  ÌÍÔÕÕUÐÒS
BÚ[ØZ]
    ][ÝÔXÙZ]HÛÛ[X[ÈØÜ   ][ÝÊBÕRTÙ]Ý]JÕ×ÔÒÕÊBÚ[HBIÌÍÛÙÈHÕRQÙ]ÙÊ
BTÝÚ]Ú   ÌÍÛÙÂBPØÙH   ÌÍÑÕRWÑUSÐÓÔÑK ÌÍÐ]ÛBBTÝ[Ü]J ÌÍÐÛÛ[][XØ][ÛÜØÜ  ][ÝÉÌÍÉÌÍÉÌÍÑVUÔÐÔT   ÌÍÉÌÍÉÌÍÉ][ÝÊBBBQ^]BPØÙH   ÌÍÐ]ÛBBBTÝ[Ü]J    ÌÍÐÛÛ[][XØ][ÛÜØÜÕRPÝXY
    ÌÍÒ[]JJBQ[ÝÚ]ÚÑ[
Edited by sandin
Link to comment
Share on other sites

Hi sandin,

Thanks for posting your example above. Exactly what I was after for one of my applications I am writing.

My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...