I've glued it all together and added some functions to hopefully make it simpler to talk to another script.
In this example it is probably easier to compile them rather than trying to run 2 from Scite.
Run Script1 (nothing exciting will happen at this point)
Then Run script 2, enter some string in to the input box and OK it. The string will get sent to script 1 then script 1 will sned it back to script 2.
It doesn't sound that exciting but it did just make it quite easy to send the string backwards and forwards between the 2 scripts.
The important bits....
$Local_ReceiverID_Name = "MyMessageWindowTitle"
_SetAsReceiver($Local_ReceiverID_Name) ;means that this script will accept messages and this it the identifier to use for the other script to send a message to me on
_SetReceiverFunction("_MyFunc") ;this is the function you want to call when data is received, you could do absolubtly anything with it I just chose a message box for ease ideally it should do something very quickly and return
to send a message to the above you would use...
$vText = "My text I want to send"
$Remote_ReceiverID_Name = "MyMessageWindowTitle" ;(The other scripts message window title)
_SendData($vText,$Remote_ReceiverID_Name)
Of course you can use both/all scripts to send data between themselves just give each script a unique title in _SetAsReceiver("Unique title")
;Script1 #include "MessageHandler.au3" $Local_ReceiverID_Name = "Script1sReceiverID";This is the ID that the other script will use to send data $Remote_ReceiverID_Name = "Script2sReceiverID";This is the ID of the script we want to send data too $hwnd = _SetAsReceiver($Local_ReceiverID_Name) ConsoleWrite("hwnd of the Local_ReceiverID_Name is " & $hwnd & @crlf) $myFunc = _SetReceiverFunction("_MyFunc2") ConsoleWrite("My data receiver function is " & $myFunc & @crlf) While 1 Sleep(1000) WEnd Func _MyFunc2($vText) Msgbox(0,@ScriptName,"I am " & @ScriptName & " I have received some data" & @crlf & @crlf & $vText & @crlf & @crlf & "And now I'm sending the data back") $iSent = _SendData($vText,$Remote_ReceiverID_Name) Exit EndFunc
;Script2 #include "MessageHandler.au3" $Local_ReceiverID_Name = "Script2sReceiverID";This is the ID that the other script will use to send data $Remote_ReceiverID_Name = "Script1sReceiverID";This is the ID of the script we want to send data too $hwnd = _SetAsReceiver($Local_ReceiverID_Name) ConsoleWrite("hwnd of the Local_ReceiverID_Name is " & $hwnd & @crlf) $myFunc = _SetReceiverFunction("_MyFunc2") ConsoleWrite("My data receiver function is " & $myFunc & @crlf) $Str = InputBox(@ScriptName," I am " & @ScriptName & @crlf & "Enter some data to be sent to the other script") $iSent = _SendData($Str,$Remote_ReceiverID_Name) While 1 sleep(100) WEnd Func _MyFunc2($vText) Msgbox(0,@ScriptName,@ScriptName & " has received a message" & @crlf & $vText) Exit EndFunc
New version attached which now has a better message handler system which will not stop the sending script from pausing allowing a quick return to the script.
Old version had 105 downloads
Attached Files
Edited by ChrisL, 01 November 2008 - 10:44 AM.






