Jump to content

Script Communication


McGod
 Share

Recommended Posts

This is a wrapper for WM_COPYDATA to commiuncate between scripts.

Using some code from:

http://www.autoitscript.com/forum/index.php?showtopic=59590

and

http://www.autoitscript.com/forum/index.php?showtopic=43112

Example:

Recv:

#include <scriptComm.au3>

_ScriptComCreateRecv("Recv", "Recv")

While 1
    Sleep(100)
WEnd

Func Recv($iHwnd, $iMsg)
    Local $sSplit = StringSplit($iMsg, "|")
    Switch $sSplit[1]
        Case "MSG"
            MsgBox(1, "Recv", $sSplit[2])
        Case "EXIT"
            Exit
    EndSwitch
EndFuncoÝ÷ Ù'§u«·jëh×6#include <scriptComm.au3>
_ScriptComSend("Recv", "MSG|Test for comm.")
_ScriptComSend("Recv", "EXIT")

A rough example to use:

Example.au3

UDF:

ScriptComm.au3

Edited by Chip
Link to comment
Share on other sites

The Send/Recv pair works with one little change: in the ScriptComm.au3 file, change line 2 from this

#include <SendMessage.au3>oÝ÷ Ø¥µêÞvØ^/±Êâ¦Ö¬~e£ºÚ"µÍÚ[ÛYH  ÍÜØÜÛÛ[K]LÉÝÂÔØÜÛÛPÜX]TXÝ   ][ÝÔXÝ][ÝË ][ÝÔXÝ][ÝÊBÚ[HBÛY
L
BÑ[[ÈXÝ  ÌÍÚRÛ   ÌÍÚSÙÊBØØ[   ÌÍÜÔÜ]HÝ[ÔÜ]
    ÌÍÚSÙË ][Ýß  ][ÝÊBÝÚ]Ú  ÌÍÜÔÜ]ÌWBØÙH    ][ÝÓTÑÉ][ÝÂÙÐÞ
K   ][ÝÔXÝ][ÝË ÌÍÜÔÜ]ÌJBØÙH    ][ÝÑVU    ][ÝÂBBSÙÐÞ
K   ][ÝÔXÝ][ÝË ][ÝÒHØÈÛÈ^]   ][ÝÊB^][ÝÚ]Ú[[oÝ÷ Ù©Ýi×^u§^¬zÜz{azÜ(ë,j¬~º&IéÝjíÚºÚ"µÍÚ[ÛYH ÍÜØÜÛÛ[K]LÉÝÂÔØÜÛÛTÙ[
    ][ÝÔXÝ][ÝË ][ÝÓTÑßÝÜÛÛ[K][ÝÊBÛY
Ì
BÔØÜÛÛTÙ[
    ][ÝÔXÝ][ÝË ][ÝÑVU    ][ÝÊBÙÐÞ
    ][ÝÔÙ[   ][ÝË  ][ÝÒIÌÎNÛH]H[][ÝÊ

I was surprised to see that if I left the first Recv Msgbox open for over three seconds that there was still a delay of 3 seconds before the second Msgbox came up. Can someone explain why that is - why does the Send script stop until the Recv script accepts the message? Is there a way to change this behavior - like for the Send script to keep working and maybe resend the message?

BlueBearrOddly enough, this is what I do for fun.
Link to comment
Share on other sites

:D I forgot to mention I'm using the latest beta which split up the SendMessage.au3
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...