Jump to content

[Solved] returning data from compiled script


Simpel
 Share

Recommended Posts

Hi.

If I embedd a compiled autoit script into my new script, is there a possibility to pass some data from the compiled embedded exe to my script?

I know it's possible with an ini or txt-file. But is there something without creating a file? I plan to return an array or an unformatted string of datas with delimiters inside.

Any ideas?

Regards, Conrad

Edited by Simpel
solved
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

Consolewrite?

EDIT: One other thought: I have also used a GUI control to set data that can be read from another app before.  I don't believe the GUI or control has to be set to visible for it to work.

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Hi,

I have to get data from a data base with an authentification, I don't want to know. So one guy will write me a compiled AI-script passing me the data. I send via command line a question and I want to get back the data. How can he pass me the data? Is it clearer now?

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

Where is the compiled app the other guy is writing that interacts with the database?  Is it on your machine?  I think you are saying it is an AI (Adobe Illustrator) script, correct?  How much data is it?  Can you use a network protocol to send and receive it?

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Hi,

the compiled app is local on my machine. It is written in autoit (AI), too. I guess it is text or binary.

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

Ok,

the examples tell me how to send something to a child and to receive it back. But what should the child do to get the data and to push it back to parent?

Can me someone give an example in two parts? First the parent, second the child executed by the parent.

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

Conrad, You can do it this way. You must download AutoItObject UDF.

Parent.au3:

#include <Array.au3>
#include "AutoItObject.au3"

MsgBox( 0, "Parent", "This is parent" )

_AutoItObject_StartUp()

; Register object to transfer data
Global $sDataTransferObject = "DataTransferObject"
Global $oDataTransferClass, $oDataTransferObject, $hDataTransferObject
$oDataTransferClass = _AutoItObject_Class()
$oDataTransferClass.AddProperty( "ArrayData" )
$oDataTransferObject = $oDataTransferClass.Object
$hDataTransferObject = _AutoItObject_RegisterObject( $oDataTransferObject, $sDataTransferObject )

; Create array
Global $aArray[1000][10]
For $i = 0 To 1000 - 1
  For $j = 0 To 9
    $aArray[$i][$j] = $i & "/" & $j
  Next
Next
_ArrayDisplay( $aArray, "Array on parent" )

; Transfer data
$oDataTransferObject.ArrayData = $aArray

; Start child
ShellExecuteWait( "Child.au3" )


; ------- Parent waiting while child is executing -------


MsgBox( 0, "Parent", "This is parent again" )

; Receive data on parent
$aArray = $oDataTransferObject.ArrayData
_ArrayDisplay( $aArray, "Modified array on parent" )

; Unregister data transfer object
_AutoItObject_UnregisterObject( $hDataTransferObject )

_AutoItObject_Shutdown()

Exit

Child.au3:

#include <Array.au3>

MsgBox( 0, "Child", "This is child" )

; Data transfer object
Global $sDataTransferObject = "DataTransferObject"
Global $oDataTransferObject = ObjGet( $sDataTransferObject )

; Receive data on child
Global $aArray = $oDataTransferObject.ArrayData
_ArrayDisplay( $aArray, "Array on child" )

; Modify array on child
For $i = 0 To 100 - 1
  $aArray[$i][0] = "Modified"
  $aArray[$i][1] = "on"
  $aArray[$i][2] = "child"
Next
_ArrayDisplay( $aArray, "Modified array on child" )

; Transfer data
$oDataTransferObject.ArrayData = $aArray

Exit

 

Link to comment
Share on other sites

Sorry @LarsJ but I can't find  AutoItObject UDF. I get 1326 pages of results and I cant' find that UDF. Any suggestion?

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

Thanks very much LarsJ and Jfish. Your examples work great and that UDF seemed to be a powerful thing.

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

  • 4 years later...
On 9/15/2015 at 10:18 PM, LarsJ said:

You can do it this way

I know it's an old topic, but just small note - the ObjGet in this example doesn't work if you use it in callback function (WM_* for example):

Parent.au3:

#include <WindowsConstants.au3>
#include "AutoItObject.au3"

MsgBox( 0, "Parent", "This is parent" )

_AutoItObject_StartUp()

; Register object to transfer data
Global $oDataTransferClass, $oDataTransferObject, $hDataTransferObject
$oDataTransferClass = _AutoItObject_Class()
$oDataTransferClass.AddProperty( "Data" )
$oDataTransferObject = $oDataTransferClass.Object
$hDataTransferObject = _AutoItObject_RegisterObject($oDataTransferObject,  "DataTransferObject")

; Transfer data
$oDataTransferObject.Data = 'test'

; Start child
ShellExecute("Child.au3")
$hWnd = WinWait('DataTransferObject Window')

;Send command to receiver (just a trigger actualy)
DllCall('user32.dll', 'ptr', 'SendMessage', 'hwnd', $hWnd, 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr(DllStructCreate('ulong_ptr;dword;ptr')))

; ------- Parent waiting while child is executing -------

MsgBox( 0, "Parent", "This is parent again" )

; Receive data on parent
MsgBox(64, 'Should be test2', $oDataTransferObject.Data)

; Unregister data transfer object
_AutoItObject_UnregisterObject($hDataTransferObject)
_AutoItObject_Shutdown()

Exit

 

Child.au3:

#include <WindowsConstants.au3>

$GhUI = GUICreate('DataTransferObject Window')
GUIRegisterMsg($WM_COPYDATA, '_WM_COPYDATA')

While 1
    Sleep(10)
WEnd

Func _WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam)
    ; Data transfer object
    Local $oData = ObjGet("DataTransferObject")
    
    ;It's always False
    If IsObj($oData) Then
        ; Transfer data
        $oData.Data = 'test2'
    EndIf
    
    Exit
EndFunc

 

Any ideas why, and how to make it work there?

 

 

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

Link to comment
Share on other sites

Make sure that DllCall works, that the GUIRegisterMsg code works, and that the objects have enough time to do their job. You can do it this way. Tested on Windows 7 32/64 bit.

Parent.au3

#AutoIt3Wrapper_UseX64=y

#include <WindowsConstants.au3>
#include "AutoItObject.au3"

MsgBox( 0, "Parent", "This is parent" )

_AutoItObject_StartUp()

; Register object to transfer data
Global $oDataTransferClass, $oDataTransferObject, $hDataTransferObject
$oDataTransferClass = _AutoItObject_Class()
$oDataTransferClass.AddProperty( "Data" )
$oDataTransferObject = $oDataTransferClass.Object
$hDataTransferObject = _AutoItObject_RegisterObject($oDataTransferObject,  "DataTransferObject")

; Transfer data
$oDataTransferObject.Data = 'test'

; Start child
ShellExecute("Child.au3")
$hWnd = WinWait('DataTransferObject Window')

;Send command to receiver (just a trigger actualy)
DllCall( "User32.dll", "lresult", "SendMessage", "hwnd", $hWnd, "uint", $WM_USER, "wparam", 0, "lparam", 0 )

; ------- Parent waiting while child is executing -------

MsgBox( 0, "Parent", "This is parent again" )

; Receive data on parent
MsgBox(64, 'Should be test2', $oDataTransferObject.Data)

; Unregister data transfer object
_AutoItObject_UnregisterObject($hDataTransferObject)
_AutoItObject_Shutdown()

Exit

Child.au3

#AutoIt3Wrapper_UseX64=y

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate('DataTransferObject Window')
Global $idDummy = GUICtrlCreateDummy()
GUIRegisterMsg( $WM_USER, "WM_USER" )
GUISetState( @SW_SHOW )

While 1
  Switch GUIGetMsg()
    Case $idDummy
      Local $oData
      While Not IsObj( $oData )
        $oData = ObjGet("DataTransferObject")
        Sleep(10)
      WEnd
      ; Transfer data
      $oData.Data = 'test2'
      Exit
  EndSwitch
WEnd

Func WM_USER( $hWnd, $iMsg, $wParam, $lParam )
  GUICtrlSendToDummy( $idDummy )
EndFunc

 

Link to comment
Share on other sites

5 hours ago, LarsJ said:

Make sure that DllCall works, that the GUIRegisterMsg code works, and that the objects have enough time to do their job

I did that, but if you check that object from inside the WM function it never became an object.

 

5 hours ago, LarsJ said:

You can do it this way

Thanks, but i would like to avoid using any external loops or calls, because then i will have to wait from the parent to accept the return data.

But still it's not strange that it's not working from inside of the message function?

Edited by MrCreatoR

 

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

Link to comment
Share on other sites

Btw, if we use _AutoItObject_StartUp(False) (default, no dll load), then it will not work for x64.

 

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

Link to comment
Share on other sites

I thought it should work with all data types, but for structures it says "The requested action with this object has failed".

Parent...

$oDataTransferObject.Data = DllStructCreate('dword')

Child...

$oData.Data = 'Other data'

 

 

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

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

×
×
  • Create New...