Jump to content

[Solved] Pass Varaibles Into Script


 Share

Recommended Posts

You could register a function for a known message ID.

In the main script add GUIRegisterMsg(0x8000, "FuncToCall"), inside "media.exe" use _SendMessage($YourGuiHandle, 0x8000)

If you want to pass additional information you might want to use wParam and lParam parameters

Link to comment
Share on other sites

The message registration was what I was going to suggest. Only I prefer to use RegisterWindowMessage() then broadcast with PostMessage() to avoid the wait.

Also it can be a good idea to stick part of a Guid string into the message name to avoid collisions for system wide messages. For example "MYMESSAGE_008C7A27-CC2B" is less likely a collision than "MYMESSAGE" :)

But there are many different ways to skin the cat:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx

For simple notification such as you are talking about, the message broadcast is probably the easiest. It has the advantage that the programs don't need to know each other's names or window handles. They just need to be using the same unique message string registered with RegisterWindowMessage().

Edited by MilesAhead
Link to comment
Share on other sites

  • Moderators

I agree with the two above. What you're looking for is called Inter Process Communication ( IPC ).

Is a decent example of simple IPC.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Heya

Sorry for not replying or posting anything on the topic but my health hasn't been very good the last few days :)

Using the code you provided i tryed to get a working example, but i have never used these commands before and the helpfile is a little confusing on it as well ;)

Main Script

#include <WindowsConstants.au3>
#Include <WinAPI.au3>

GUIRegisterMsg(0x8000, "FuncToCall")

while 1
sleep(5000)
WEnd

Func FuncToCall()
ConsoleWrite("A")
EndFunc

Media Script

#Include <SendMessage.au3>
_SendMessage("FuncToCall", 0x8000)
Edited by IanN1990
Link to comment
Share on other sites

try this:

media.exe

UDPStartup()
$socketS = UDPOpen("127.0.0.1", 65533) ;conect to main script on local host
UDPSend($socketS, "a") ; send data
UDPCloseSocket($socketS);  cleeanup and exit
UDPShutdown()

main script:

UDPStartup()
$socketR = UDPBind("127.0.0.1", 65533);Listen to conections on localhost
While 1 ; main loop
$data = UDPRecv($socketR, 8) ;wait for data
if $data="a" then
  whatever_a() ;compare data
  ExitLoop
EndIf
WEnd
UDPCloseSocket($socketR) ;always cleanup before exiting
UDPShutdown()
Exit
Func whatever_a()
 MsgBox(0,"","Executing a func",3)
 EndFunc
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...