Sign in to follow this  
Followers 0
Shafayat

Control one autoit exe (compiled) with another

7 posts in this topic

I'll elaborate what I need.

First, there is an A.EXE (autoit compiled executable)

I need a code from my autoit script (e.g. b.au3) that can make the A.EXE run this command: _ArrayDelete($XArray, 8)

I know about the INI file method. But in this case, I can not use that. Because A.EXE does NOT check for the INI file change. Also none of these has a GUI.

Can you help me? I think this can be done with Accessing Memory. (I don't understand structures yet. But I need this to work soon.)

Best Regards

Shafayat


[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites



You can't directly inject a line of code into another running compiler script (or uncompiled for that matter). You need to modify a.au3 to be able to listen to output from the outside (be it file changes, tcp/udp server, registry changes, whatever) and then rewrite b.au3 to invoke that somehow.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Does that limitation(being injected not injecting) apply for Autoit only? Because there is another RAD tool (named Multimedia Builder,MMB from Mediachance) in which I have been injecting codes via autoit. Here is the code I use:

Func SendScriptMMB($title,$script)
    
; get handle of MMB window
$hwnd = WinGetHandle($title)
if @error Then
    MsgBox(48,"","Can't find window with title " & $title)
    exit
endif

$slen = stringlen($script) +1

$str = "char[" & $slen & "]"; structure item must be "char"
$struct= DllStructCreate($str); create a struct for the string so we can get a pointer to it
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error)
    exit
endif

$iItem   = DllStructGetSize($struct); get structure size
$pMemory = _MemInit($hwnd, $iItem, $tMemMap); init memory and return pointer to initialized memory in target app
DllStructSetData($struct, 1, $script); set string to structure
$pointer = DllStructGetPtr($struct,1); pointer to string in structure
_MemWrite($tMemMap, $pointer, $pMemory, $iItem); write string pointer to application memory

_SendMessage($hwnd,$WM_RUNSCRIPTCODE,$RUNSCRIPTCODE_LOUD,$pMemory)
If @error Then
    MsgBox(0,"", "_SendMessage Error: " & @error)
    Exit
EndIf

_MemFree($tMemMap);release the memory
EndFunc

Can't something alike be done?

Edited by Shafayat

[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If you want to inject code into the AutoIt compiler at run-time you must reverse engineer the interpreter, which is not allowed.

Edit: By the way, _SendMessage sends a message to the GUI (which has a listener) and it does not "inject code" at all.

Edited by Manadar

Share this post


Link to post
Share on other sites

Ok. I am giving up all my hope. :sad:


[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok. I am giving up all my hope. :sad:

I have started working on an multiple file transfert (for the moment I have adandonned because there is some problems with TCP) and it requires 2process (because autoit does not support multithreading).

To make one interact with the other, there is an autoit window automaticly built with your script (in order for other programs to interact with :D)

Here is what you can do :

;This is for the main script

$hAutoIt = WinGetHandle(AutoItWinGetTitle( )) ;Get the handle of your built in autoit window
WinSetTitle($hAutoIt, "", 'Main Script') ;Change the title to avoid confusion with the child script

WinSetState($hAutoIt, "", @SW_SHOW) ;I change the state of this window so you will see what it is...
ControlSetText($hAutoIt, "", 1, 'Main') ;example to change the edit text but I will work only on the title

ShellExecute(@AutoItExe, 'Child.au3', @ScriptDir) ;execute child script
WinWait('Child Script')
$hChild = WinGetHandle('Child Script')

While WinGetTitle($hChild) <> 'Interact'
    Sleep(250)
WEnd

Msgbox(48, 'Interact - Main', 'Child script wants to interact with the main script !')

;This is the child script

$hAutoIt = WinGetHandle(AutoItWinGetTitle( ))
WinSetTitle($hAutoIt, "", 'Child Script') ;At this moment, the main script will recognize the child built-in window

ControlSetText($hAutoIt, "", 1, 'Child')
WinSetState($hAutoIt, "", @SW_SHOW)

Msgbox(64, 'Interact', 'Press OK to interact with the main script...')
WinSetTitle($hAutoIt, "", 'Interact')

Edit1 : This is just an example, you can hide those built-in windows when you have finished your script :D

Cheers, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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