MrCreatoR Posted April 28, 2020 Author Share Posted April 28, 2020 (edited) 4 minutes ago, Nine said: Who cares what it returns I care, i want to implement some kind of an "answer" for my AppInteract UDF. I did it but using the same method by setting the interaction and SendMessage back to the calling process. And also it's just curiosity of how can we pass pointer to our external process and transform that pointer to data. Edited April 28, 2020 by MrCreatoR 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...
MrCreatoR Posted April 28, 2020 Author Share Posted April 28, 2020 Just now, Nine said: A pointer to what structure ? To one that created in WM_COPYDATA. 1 minute ago, Nine said: I am out. Ok . Thanks for trying to help. 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...
Nine Posted April 28, 2020 Share Posted April 28, 2020 I know I said I am out. And I am, but I want to inform the community (those who will read this thread). I tested speed of communication between 2 processes using usual TCP/UDF approach and stream (STDIO). And I am quite impressed with the result with this exchange of WM_COPYDATA messages. Very fast and easy to use. I will let you know my final results in example section later this week “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...
LarsJ Posted April 29, 2020 Share Posted April 29, 2020 According to the documentation, either True or False should be returned in a WM_COPYDATA function. These are the only values you can say for sure are always returned correctly. If you want to have other than these values back from the WM_COPYDATA function with some certainty, it should probably be some kind of IPC technique. My favorite array IPC technique is the running object table (ROT) technique based on AutoItObject as demonstrated in this thread. The technique can handle multi-dimensional arrays and retains the internal data type of the array elements. It should be possible to implement the technique using ObjCreateInterface() instead of AutoItObject. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
KaFu Posted April 29, 2020 Share Posted April 29, 2020 "The receiving application should consider the data read-only. The lParam parameter is valid only during the processing of the message. The receiving application should not free the memory referenced by lParam. If the receiving application must access the data after SendMessage returns, it must copy the data into a local buffer." Create a second WM_COPYDATA loop handling comm in the opposite direction. 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...
MrCreatoR Posted April 29, 2020 Author Share Posted April 29, 2020 3 hours ago, LarsJ said: These are the only values you can say for sure are always returned correctly As far as i tested, a pointer also can be returned, the issue with translating it back to structure. 3 hours ago, LarsJ said: My favorite array IPC technique is the running object table (ROT) technique based on AutoItObject as demonstrated in this thread. Thanks will check that. 12 minutes ago, KaFu said: Create a second WM_COPYDATA loop handling comm in the opposite direction. That's what i did. 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...
KaFu Posted April 29, 2020 Share Posted April 29, 2020 9 minutes ago, MrCreatoR said: That's what i did. Oops! … I Did It Again 😋 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...
Bilgus Posted April 29, 2020 Share Posted April 29, 2020 (edited) 14 minutes ago, MrCreatoR said: 3 hours ago, LarsJ said: These are the only values you can say for sure are always returned correctly As far as i tested, a pointer also can be returned, the issue with translating it back to structure. The best way to do that is to share the beginning of the struct with all potential daya something like StructCreate("DataType dword; Size dword;") and then a data item StructCreate("DataType dword; Size dword;byte;int;data[42]") another data item StructCreate("DataType dword; Size dword;byte;int;long;ptr;data[88]") when you receive the ptr on the other side do dllstructcreate("DataType dword; Size dword;", $ptr) parse the data and create your final struct DllStructCreate("DataType dword; Size dword;byte;int;long;ptr;data[88]", $ptr) you could even pass the struct definition if you so desired Edited April 29, 2020 by Bilgus Link to comment Share on other sites More sharing options...
MrCreatoR Posted April 29, 2020 Author Share Posted April 29, 2020 1 minute ago, Bilgus said: The best way to do that is to share the beginning of the struct Not sure what you mean by beginning of the structure. Any attempt to use the pointer from another process leads to a hard crash. 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...
Bilgus Posted April 29, 2020 Share Posted April 29, 2020 Oh then maybe I misunderstand what you are trying to do then I thought you were referring to the data you already got during the wmCD call, I'd totally expect if you use a pointer from another process it'd crash Link to comment Share on other sites More sharing options...
MrCreatoR Posted April 29, 2020 Author Share Posted April 29, 2020 Just now, Bilgus said: expect if you use a pointer from another process it'd crash Maybe there is some way to get an address by this pointer and use it in ReadProcessMemory? 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...
KaFu Posted April 29, 2020 Share Posted April 29, 2020 WM_COPYDATA structure should be different to make it x64 save, plus I always define it and the pointer as a Global Var, because it's always blocking and distinct (speed-wise optimization again). Global $t_WM_COPYDATA = DllStructCreate("ulong_ptr;dword;ptr") Global $p_WM_COPYDATA = DllStructGetPtr($t_WM_COPYDATA) 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...
Bilgus Posted April 29, 2020 Share Posted April 29, 2020 ReadProcessMem is a train wreck waiting to happen use shared memory or something first IIUC you should be notifying your app with a different message and having it initiate the wm_copydata not trying to retrieve the struct off the send message call Link to comment Share on other sites More sharing options...
MrCreatoR Posted May 14, 2020 Author Share Posted May 14, 2020 Finally i found a way: expandcollapse popup#include <WindowsConstants.au3> #include <WinAPIProc.au3> #include <WinAPIMem.au3> 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]') $sRet = _Send($hChild) MsgBox(64, 'Return', $sRet) Func _Send($hWnd) Local $stData = DllStructCreate('ulong_ptr;dword;ptr') Local $aRet = DllCall('user32.dll', 'ptr', 'SendMessage', 'hwnd', $hWnd, 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr($stData)) Local $stStr = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($aRet[0]), 'wchar sStr[1024]') Return DllStructGetData($stStr, 'sStr') EndFunc Func _WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam) $bExit = True $vRet = 'Test' $iLen = (StringLen($vRet) * 2) + 3 $stStr = DllStructCreate('wchar sStr[' & $iLen & ']') DllStructSetData($stStr, 'sStr', $vRet) Return DllStructGetPtr($stStr) EndFunc 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 Just one small(?) limitation: i should set structure manually ('wchar sStr[1024]') without really knowing the size of the data returned. 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...
Danyfirex Posted May 15, 2020 Share Posted May 15, 2020 You can do something like this to remove that limitation. expandcollapse popup#include <WindowsConstants.au3> #include <WinAPIProc.au3> #include <WinAPIMem.au3> #include <String.au3> 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]') $sRet = _Send($hChild) MsgBox(64, 'Return', $sRet) Func _Send($hWnd) Local $stData = DllStructCreate('ulong_ptr;dword;ptr') Local $aRet = DllCall('user32.dll', 'ptr', 'SendMessage', 'hwnd', $hWnd, 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr($stData)) Local $tSize = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($aRet[0]), 'long iSize') Local $stStr = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($aRet[0] + 4), 'wchar sStr[' & $tSize.iSize & ']') Return DllStructGetData($stStr, 'sStr') EndFunc ;==>_Send Func _WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam) $bExit = True $vRet = "A_" & _StringRepeat('Test', Random(1, 1000)) & "_Y" $iLen = (StringLen($vRet) + 1) $stStr = DllStructCreate('long iSize;wchar sStr[' & $iLen & ']') DllStructSetData($stStr, 'iSize', $iLen) DllStructSetData($stStr, 'sStr', $vRet) Return DllStructGetPtr($stStr) EndFunc ;==>_WM_COPYDATA 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 KaFu and MrCreatoR 2 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...
KaFu Posted May 15, 2020 Share Posted May 15, 2020 (edited) 5 hours ago, Danyfirex said: You can do something like this to remove that limitation. 👍 exactly what came to my mind, but what I was too lazy to do 🤫 Edited May 15, 2020 by KaFu Danyfirex 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...
MrCreatoR Posted May 15, 2020 Author Share Posted May 15, 2020 3 hours ago, Danyfirex said: You can do something like this to remove that limitation. Wow, i didn't thought about that one! Thanks. 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 15, 2020 Share Posted May 15, 2020 7 hours ago, Danyfirex said: You can do something like this .... So I wanted to time the IPC and added a timer Spoiler expandcollapse popup#include <WindowsConstants.au3> #include <WinAPIProc.au3> #include <WinAPIMem.au3> #include <String.au3> 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 $sRet = _Send($hChild) $hTimer = Round(TimerDiff($hTimer), 5) ; ..time it took to return MsgBox(64, 'Return - ' & $hTimer, $sRet) Func _Send($hWnd) Local $stData = DllStructCreate('ulong_ptr;dword;ptr') Local $aRet = DllCall('user32.dll', 'ptr', 'SendMessage', 'hwnd', $hWnd, 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr($stData)) Local $tSize = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($aRet[0]), 'long iSize') Local $stStr = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($aRet[0] + 4), 'wchar sStr[' & $tSize.iSize & ']') Return DllStructGetData($stStr, 'sStr') EndFunc ;==>_Send Func _WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam) $bExit = True $vRet = "A_" & _StringRepeat('Test', Random(10, 100)) & "_Y" ; ..changed to try to avoid failure $iLen = (StringLen($vRet) + 1) $stStr = DllStructCreate('long iSize;wchar sStr[' & $iLen & ']') DllStructSetData($stStr, 'iSize', $iLen) DllStructSetData($stStr, 'sStr', $vRet) Return DllStructGetPtr($stStr) EndFunc ;==>_WM_COPYDATA 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 and came to see that it fails every so often I takes from 1 to 10 ms. to return ( unless it fails ), and that is quite good but the lack of reliability is a problem. Is this ready to use code, or just an example for a more complete script ? 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 15, 2020 Share Posted May 15, 2020 _WinAPI_SendMessageTimeout.. Link to comment Share on other sites More sharing options...
argumentum Posted May 15, 2020 Share Posted May 15, 2020 28 minutes ago, Bilgus said: _WinAPI_SendMessageTimeout nope, I see Local $tSize = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($aRet[0]), 'long iSize') ConsoleWrite(@TAB & $tSize.iSize & @CRLF) ; 19005632 <-- on this size, obviously wrong, fails so it's related to that. 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...
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