Jump to content

Control one autoit exe (compiled) with another


Shafayat
 Share

Recommended Posts

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]

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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
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...