Sign in to follow this  
Followers 0
vigorman

how to send variables to another compiled script

10 posts in this topic

One compiled script send variables to another compiled script.

I only think a way through clibboard. Are there other way?

Thanks.

Share this post


Link to post
Share on other sites



TCP Send and Receive.. Just use the local host IP (127.0.0.1)

Share this post


Link to post
Share on other sites

TCP Send and Receive.. Just use the local host IP (127.0.0.1)

There is also writing to the other script's GUI (perhaps a hidden control), through the registry, through and intermediate file, and WM_COPYDATA (numeric data only).

<_<


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Maybe that will work ? ( I'm not tested )

#include <File.au3>

While 1
    $Receive = Receive()
    If GUIGetMsg() = $Send Then Send($Var)
WEnd

Func Receive()
    If FileExists("Receive/Test.ini") Then
        $Read = IniRead("Receive/Test.ini", "Test", "", "")
        If StringInStr($Read, "Var") Then
            $Read2 = StringSplit($Read, "|")
            FileDelete("Receive/Test.ini")
            Return $Read2[2]
        EndIf
        FileDelete("Receive/Test.ini")
    EndIf
EndFunc
        
Func Send($Var)
    FileDelete("Send/Test.ini")
    IniWrite("Send/Test.ini", "Test", "", "Var|" & $Var)
EndFunc
Edited by Jex

Share this post


Link to post
Share on other sites

Maybe that will work ? ( I'm not tested )

Func Send($Var)
    FileDelete("Send/Test.ini")
    IniWrite("Send/Test.ini", "Test", "", "Var|" & $Var)
EndFunc
Send() is an AutoIt native function, so you can't declare another one with the same name. Call it _Send() if you must use that name.

An .ini file might be a good choice to use a file for interaction, if there are not too many messages and they don't come at too high a frequency. The receiving script could just monitor the modified time attribute of the file to know when there was new data, and ini structure allows organizing the messages some.

<_<


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

StdinWrite and StdoutRead works fine for me <_<


Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator[center] VW Bug user[/center]Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral

Share this post


Link to post
Share on other sites

StdinWrite and StdoutRead works fine for me

Can you show working example please?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

One compiled script send variables to another compiled script.

I only think a way through clibboard. Are there other way?

Thanks.

Here's another way.

PsaltyDS said "WM_COPYDATA (numeric data only)." Although it's true that messages only send numbers they can be used to send any data because the number can be the memory location of a string or an array which the receiver of the message can then read.

ControlSend is another simple way to send data to another program which I don't think anyone has mentioned in this thread. Klaatu's debugger is a good example of using this.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Can you show working example please?

#include <Constants.au3>

$foo = Run( @ScriptDir & "\Another.exe", @ScriptDir, @SW_SHOW, $STDOUT_CHILD + $STDIN_CHILD )
Sleep( 2000 )
StdinWrite( $foo, "Where is the cat?" )

$Data = ""
While 1
    $Bytes = StdoutRead( $foo, '' ,true )
    if $Bytes > 0 then 
    ; leia o numero de bytes da stream
        $Data = StdoutRead( $foo, $Bytes )
        If StringLen( $Data ) Then
            ExitLoop
        EndIf
    EndIf
Wend
MsgBox( 0, "Return", $Data )

Compile the next script as "Another.exe"

#include <Constants.au3>

$Input = ""
While 1
    Sleep( 100 )
    $Bytes = ConsoleRead( "", true )
    If $Bytes > 0 Then
        $Input = ConsoleRead( $Bytes )
        ExitLoop
    EndIf
WEnd

If $Input = "Where is the cat?" Then
    ConsoleWrite( "What cat?" )
EndIf

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator[center] VW Bug user[/center]Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral

Share this post


Link to post
Share on other sites

A. Percy

Thanks for the example, but in this case it required calling of a child process, not so practic in some cases <_<.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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  
Followers 0