Shafayat Posted September 11, 2009 Share Posted September 11, 2009 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 More sharing options...
jvanegmond Posted September 11, 2009 Share Posted September 11, 2009 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. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Shafayat Posted September 11, 2009 Author Share Posted September 11, 2009 (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 September 11, 2009 by Shafayat [Not using this account any more. Using "iShafayet" instead] Link to comment Share on other sites More sharing options...
jvanegmond Posted September 11, 2009 Share Posted September 11, 2009 (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 September 11, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Shafayat Posted September 11, 2009 Author Share Posted September 11, 2009 Ok. I am giving up all my hope. :sad: [Not using this account any more. Using "iShafayet" instead] Link to comment Share on other sites More sharing options...
jvanegmond Posted September 11, 2009 Share Posted September 11, 2009 There's no need for that, you just need to implement some sort of listener in a.exe . github.com/jvanegmond Link to comment Share on other sites More sharing options...
FireFox Posted September 11, 2009 Share Posted September 11, 2009 (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 ) 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 Cheers, FireFox. Edited September 11, 2009 by FireFox Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now