Simpel

[Solved] returning data from compiled script

12 posts in this topic

#1 ·  Posted (edited)

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

SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
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

Share this post


Link to post
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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites

Have you seen this?

StdinWrite

If both are in AutoIt, should not be difficult.

Alternatively pipe the commands 

find *.* | del *.* :) 


Skysnake

Why is the snake in the sky?

Share this post


Link to post
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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
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

 

1 person likes this

Share this post


Link to post
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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

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

  • Similar Content

    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      in need the path/text present int above shown input box to be copied or retrieved into a variable .. how can i do that?
       
      Thanks
       
    • RC86
      By RC86
      Afternoon!
      Just a quick one as this has dawned on me recently when creating a little program.  When calling an executable I've created like Run(otherapp.exe) from within my executable is there a best practice to ensure things have gone smoothly?  So for example, should I monitor the PID to ensure it runs and closes within an acceptable timeframe?  Or within my other executable should I do EXITs in a certain way after functions and return codes etc?
      Could be a silly question but thought I'd ask.
    • Eggsplorer
      By Eggsplorer
      Hi,
      Ich hab ein Script für Windows Updates, dass nach dem OOBE aufgerufen werden soll. Run/RunOnce ist daher nicht möglich.
      Stattdessen möchte ich das Script in den Autostart schreiben lasse. Wenn die OOBE beendet wird und der Administrator angemeldet wird, soll das Update-Script einmalig aufgerufen werden und sich anschl. selbst löschen.
      Lang rede, kurzer Sinn:
      Wie kann ich folgendes Script in den Autostart schreiben?
      RunWait(@ComSpec & " /c " & "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\UA\Scripts\win-updates.ps1 -MaxUpdatesPerCycle 100 -RestartRequired 1", "") Ich würde ungern eine BAT oder EXE reinkopieren, da ich es unsauber finde. Die müsste ja auch zusätzlich irgendwo liegen.
      Danke
      Eggsplorer
    • RC86
      By RC86
      Afternoon!
      I have a requirement to return both a string and an array from a function so as a result I put them both into an array and returned that.  I can access them in their entirety after returning them but then I can't seem to access the array elements after this.  Should I be able to or is there a prettier way?
      #include <Array.au3> ;Memory info returned as a string and an array $memoryInfo = _getMemoryInfo() msgbox(0,"Memory Info",$memoryInfo[0]) _ArrayDisplay($memoryInfo[1],"Memory as an Array") Local $newArray[7] $memoryInfo[1] = $newArray msgbox(0,"Test element",$newArray[0]) _ArrayDisplay($newArray) Func _getMemoryInfo() Local $newArray[7] Local $array = MemGetStats() $newArray[0] = $array[0] ;% of memory in use $newArray[1] = Round($array[1]/1024 * 0.001,2) ;Total physical RAM $newArray[2] = Round($array[2]/1024 * 0.001,2) ;Availaible physical RAM $newArray[3] = Round($array[3]/1024 * 0.001,2) ;Total pagefile $newArray[4] = Round($array[4]/1024 * 0.001,2) ;Available pagefile $newArray[5] = Round($array[5]/1024 * 0.001,2) ;Total virtual $newArray[6] = Round($array[6]/1024 * 0.001,2) ;Available virtual $memoryUsage = $newArray[1] - $newarray[2] $pagefileUsage = $newArray[3] - $newarray[4] ;Output/Return Local $returnArray[2] $returnArray[0] = "Memory: " & $memoryUsage & " GB/" & $newArray[1] & " GB " & @CRLF & "Pagefile: " & $pagefileUsage & " GB/" & $newArray[3] & " GB " $returnArray[1] = $newArray return $returnArray EndFunc A bit messy but hopefully it's understandable what I'm trying to achieve.
      Thanks!
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning
      I'm working on a little project, and I was wondering if there's a way ( sure there is ) to insert data to a ComboBox control everytime the user insert some text in the ComboBox which is not in the ComboBox data. I'll try to explain with an example:
      - Form with some data ( ComboBox is empty );
      - User prompt something in the ComboBox: if what the user prompts is not in the ComboBox values ( at the moment empty ), then insert the value in the ComboBox values, in order to have, next time the user prompts the form, the value that he entered.
      More pratical example:
      - First call of the form, ComboBox empty;
      - I prompt "A" in the ComboBox;
      - Second call, in the ComboBox I should see "A";
      - I prompt "B" in the ComboBox;
      - Third call, I should see "A"
                                                 "B";
      - And so on...
      Everytime the form is called, I re-create it, so I think I can't use _GUICtrlComboBox_AddStrings().
      I tried with
      Global $strCboStrings = "" ; When the user prompt the form, the code below is executed. ; I.E. : User prompt "A", after the if I should have "A"; ; In the second call, If I write "B", I should see "A" ; "B"; ; If I write "A" again, in the combobox values should not be any changes. If Not StringInStr($strCboStrings, GUICtrlRead($cboVoiceCategory)) <> 0 Then $strCboStrings &= $strCboStrings & "|" & GUICtrlRead($cboVoiceCategory) EndIf Any suggestion?
      Thanks