MrCreatoR Posted May 17, 2020 Author Share Posted May 17, 2020 (edited) 3 minutes ago, Danyfirex said: compare if they have same value Yes they are the same, i don't know why i didn't thought about that in the first place. Thanks. 4 minutes ago, Danyfirex said: maybe I can do it in my dreams meanwhile It's always good to dream! But soon everything will be better! 🍻 Edited May 17, 2020 by MrCreatoR Danyfirex 1 Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: 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 ProgramUDFs: 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 Examples: 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 ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
argumentum Posted May 17, 2020 Share Posted May 17, 2020 ...I'm kind of lost. The main script sends "_StringRepeat('Send', Random(10, 100))" The child responds "_StringRepeat('Return', Random(10, 100))" Where can I read what the main sent to the child in the child ? Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Danyfirex Posted May 17, 2020 Share Posted May 17, 2020 Inside _WM_COPYDATA check $tData.Data Saludos argumentum 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
argumentum Posted May 17, 2020 Share Posted May 17, 2020 (edited) @Danyfirex, this look awesome, very cool. The _WM_COPYDATA is used as an event, to trigger the read memory. Is there a way, that is not too far out of your way, to trigger the memory read without using a GUI for it ?, as a memory write that triggers a memory read, or simple in the main loop read, that is not heavy for AutoIt ? I know this is not the OP question but, can't help to wonder since is all a memory read/write and the GUI is just for the event handler. No GUI dependency would be like, WOW. Thanks. Edited May 17, 2020 by argumentum grammar :) Danyfirex 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Bilgus Posted May 17, 2020 Share Posted May 17, 2020 You still need a message loop Windows doesn't give you one without a GUI Non CLI Autoit apps have an internal window You could use the internal autoit window AutoItWinSetTitle(@ScriptName) $hAutoitInternal = WinGetHandle(@ScriptName) Link to comment Share on other sites More sharing options...
argumentum Posted May 17, 2020 Share Posted May 17, 2020 5 minutes ago, Bilgus said: You still need a message loop ...the script needs a loop, OnEvent or not. So, a loop is not a big deal. 6 minutes ago, Bilgus said: You could use the internal autoit window actually no. I can not GUIRegisterMsg() it. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Bilgus Posted May 17, 2020 Share Posted May 17, 2020 (edited) nah you need to use SetWindowSubclass AutoItWinSetTitle(@ScriptName) $hAutoitInternal = WinGetHandle(@ScriptName) $hMsgProc = DllCallbackRegister(NewMessage, 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') _WinAPI_SetWindowSubclass($hAutoitInternal, DllCallbackGetPtr($hMsgProc), $iMyID) Func NewMessage($hWnd, $iMsg, $wParam, $lParam, $iId, $pData) #forceref $iID, $pData Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc Func _Exit() If $hMsgProc Then _WinAPI_RemoveWindowSubclass($hAutoitInternal, DllCallbackGetPtr($hMsgProc), $iMyID) DllCallbackFree($g_hMsgProc) EndIf Edited May 17, 2020 by Bilgus Add #forceref $iID, $pData Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) argumentum and Danyfirex 1 1 Link to comment Share on other sites More sharing options...
argumentum Posted May 17, 2020 Share Posted May 17, 2020 1 minute ago, Bilgus said: nah you need to use SetWindowsSubclass WOW, thanks. So... , will AutoIt still receive it's messages or am I now in charge of every event ? Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Bilgus Posted May 17, 2020 Share Posted May 17, 2020 Quote ...the script needs a loop, OnEvent or not. So, a loop is not a big deal. When you do your own message loop it has to be pumped in a timely manner so it sometimes becomes a big deal at least with the subclass you can still have AutoIt take care of the minute Link to comment Share on other sites More sharing options...
Bilgus Posted May 17, 2020 Share Posted May 17, 2020 (edited) No you just pass on what you don't want to handle to the default with _WinAPI_DefSubclassProc() The helpfile explains it pretty clearly Edited May 17, 2020 by Bilgus argumentum 1 Link to comment Share on other sites More sharing options...
argumentum Posted May 17, 2020 Share Posted May 17, 2020 2 minutes ago, Bilgus said: When you do your own message loop it has to be pumped in a timely manner so it sometimes becomes a big deal ... ...all this is way above my pay grade !. I would have to build some coding experience to comfortably code with sub-classing. Thanks for the coding class I'll give a try in one of those moments when I'm bored. It'll be good to expand my knowing to the point that this technique is in my arsenal Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Bilgus Posted May 17, 2020 Share Posted May 17, 2020 (edited) OH don't conflate the two, Subclassing an existing winproc is not doing your own message loop its the same idea as GUIRegister message doing your own message loop isn't near as simple Edited May 17, 2020 by Bilgus argumentum 1 Link to comment Share on other sites More sharing options...
KaFu Posted May 18, 2020 Share Posted May 18, 2020 (edited) Using COM for IPC and triggering events without a loop but via ObjEvent() could be a good method too. Edit: Or do something like this in a loop and look for changes / reset the var when read. Edited May 18, 2020 by KaFu argumentum 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
argumentum Posted May 18, 2020 Share Posted May 18, 2020 (edited) looks like a solution to my question ...it does crash running x64 @trancexx, ..it been about a decade since the code. Can it be fixed ? ..it won't run on v3.3.6.1 or 3.3.8.1 either ( on Win10 ), so maybe there was no solution from the get go, regarding x64. Not that I "need" to run x64 but your view regarding this is welcomed. Edit: ..now that I read more about it, this would be an overkill, and misused to fit the purpose of triggering an event. Edited May 18, 2020 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
bladem2003 Posted 22 hours ago Share Posted 22 hours ago On 5/17/2020 at 12:09 PM, Danyfirex said: @MrCreatoR I meant something like this: expandcollapse popup#AutoIt3Wrapper_UseX64=y #include <WindowsConstants.au3> #include <WinAPIProc.au3> #include <WinAPIMem.au3> #include <String.au3> Global Const $tagCOPYDATASTRUCT = 'ulong_ptr dwData;' & _ 'dword cbData;' & _ 'ptr lpData' Global $stStr = 0 Global $bExit = False Global $hGUI If $CmdLine[0] And $CmdLine[1] = '/Child' Then $hGUI = GUICreate('Child') GUIRegisterMsg($WM_COPYDATA, '_WM_COPYDATA') Do Sleep(10) Until $bExit Exit EndIf Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /Child') $hChild = WinWait('[CLASS:AutoIt v3 GUI;TITLE:Child]') Sleep(500) ; ...relax $hTimer = TimerInit() ; ... timer Local $sDataToSend= "A_" & _StringRepeat('Send', Random(10, 100)) & "_Y" $sRet = _Send($hChild,$sDataToSend) $hTimer = Round(TimerDiff($hTimer), 5) ; ..time it took to return MsgBox(64, 'Return - ' & $hTimer, $sRet) Func _Send($hWnd,$sDataToSend) Local $tPtr = DllStructCreate("ptr Data") ;Pointer for reading vRet Value Local $iProcessID = @AutoItPID Local $tData = DllStructCreate("Ptr pReturn;long pid;wchar Data[" & (StringLen($sDataToSend) + 1) & "]") $tData.pReturn = DllStructGetPtr($tPtr) $tData.PID = $iProcessID ;Pid for write memory $tData.Data = $sDataToSend ;Data to Send ;~ ConsoleWrite("$tData.pid: " & $tData.PID & @CRLF) ;~ ConsoleWrite("$tData.Data: " & $tData.Data & @CRLF) Local $tCopyData = DllStructCreate($tagCOPYDATASTRUCT) $tCopyData.cbData = DllStructGetSize($tData) $tCopyData.lpData = DllStructGetPtr($tData) Local $aRet = DllCall('user32.dll', 'lresult', 'SendMessage', 'hwnd', $hWnd, 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr($tCopyData)) ;~ ConsoleWrite("$tData.pReturn: " & $tData.pReturn & @CRLF) ;~ ConsoleWrite("$tPtr.Data: " & $tPtr.Data & @CRLF) Local $tSize = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($tPtr.Data), 'long iSize') Local $stStr = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($tPtr.Data + 4), 'wchar sStr[' & $tSize.iSize & ']') Return DllStructGetData($stStr, 'sStr') EndFunc ;==>_Send Func _WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam) $bExit = True Local $vRet = "A_" & _StringRepeat('Return', Random(10, 100)) & "_Y" ; Return Local $iLen = (StringLen($vRet) + 1) Local $tCopyData = DllStructCreate($tagCOPYDATASTRUCT, $lParam) Local $tData = DllStructCreate("Ptr pReturn;long PID;wchar Data[" & ($tCopyData.cbData - (@AutoItX64 ? 12 : 8)) & "]", $tCopyData.lpData) $stStr = DllStructCreate('long iSize;wchar sStr[' & $iLen & ']') DllStructSetData($stStr, 'iSize', $iLen) DllStructSetData($stStr, 'sStr', $vRet) Return _WinAPI_WriteProcessMemoryPtr($tData.PID, $tData.pReturn, DllStructGetPtr($stStr)) EndFunc ;==>_WM_COPYDATA Func _WinAPI_WriteProcessMemoryPtr($iProcessID, $pPointer, $ptPtr) Local $iSYNCHRONIZE = (0x00100000), $iSTANDARD_RIGHTS_REQUIRED = (0x000F0000) Local $iPROCESS_ALL_ACCESS = ($iSTANDARD_RIGHTS_REQUIRED + $iSYNCHRONIZE + 0xFFF) Local $hProcess, $Struct, $StructPtr, $StructSize, $iWriten $hProcess = _WinAPI_OpenProcess($iPROCESS_ALL_ACCESS, False, $iProcessID) If @error Then Return SetError(@error, 1, $Struct) Local $Struct = DllStructCreate("ptr Data") $StructSize = DllStructGetSize($Struct) $StructPtr = DllStructGetPtr($Struct) $Struct.Data = $ptPtr Local $bWrite = _WinAPI_WriteProcessMemory($hProcess, $pPointer, $StructPtr, $StructSize, $iWriten) _WinAPI_CloseHandle($hProcess) Return SetError(@error, $iWriten, $bWrite) EndFunc ;==>_WinAPI_WriteProcessMemoryPtr Func _WinAPI_ReadProcessMemoryEx($iProcessID, $pPointer, $sStructTag) Local $iSYNCHRONIZE = (0x00100000), $iSTANDARD_RIGHTS_REQUIRED = (0x000F0000) Local $iPROCESS_ALL_ACCESS = ($iSTANDARD_RIGHTS_REQUIRED + $iSYNCHRONIZE + 0xFFF) Local $hProcess, $Struct, $StructPtr, $StructSize, $Read $hProcess = _WinAPI_OpenProcess($iPROCESS_ALL_ACCESS, False, $iProcessID) If @error Then Return SetError(@error, 1, $Struct) $Struct = DllStructCreate($sStructTag) $StructSize = DllStructGetSize($Struct) $StructPtr = DllStructGetPtr($Struct) _WinAPI_ReadProcessMemory($hProcess, $pPointer, $StructPtr, $StructSize, $Read) _WinAPI_CloseHandle($hProcess) Return SetError(@error, $Read, $Struct) EndFunc ;==>_WinAPI_ReadProcessMemoryEx Saludos Hi, how can I get the value of $sDataToSend in _WM_COPYDATA? _WM_COPYDATA only returns the string in $vRet. I want to make a selection based on the lParam and return a value or string Link to comment Share on other sites More sharing options...
Nine Posted 21 hours ago Share Posted 21 hours ago @bladem2003 You may want to try my UDF here bladem2003 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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