MrCreatoR Posted April 23, 2020 Share Posted April 23, 2020 (edited) Yes, we have those here and there (including my Container UDF), but i didn't find one that able to pass arrays or other types to be reliable enough. Differences from other analogs: Stability (reliability) Array support (2D ATM) Ability to get the return data from the interaction process Easy both ways interaction Notes: Quote * This UDF registers $WM_COPYDATA, if you or other UDF uses this message, __AppInteract_WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam) should be called from that other message function. * Do not use any delay functions inside the receiver function, the return must be as soon as possible. Examples (run both)... Spoiler Script1.au3: expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <Array.au3> #include 'AppInteract.au3' Global $iApp = 1 Global $sApp_Name = 'My App' & $iApp Global $sSend_App_Name = 'My App' & Mod($iApp, 2) + 1 Global $sSend_Script_Name = 'Script' & Mod($iApp, 2) + 1 & '.' & (@Compiled ? 'exe' : 'au3') Global $iGUI_Width = 600 Global $iGUI_Left = 100 + ($iGUI_Width * ($iApp - 1)) + (10 * ($iApp - 1)) _AppInteract_SetReceiver($sApp_Name, '_Receiver') $hGUI = GUICreate(@ScriptName & ' - AppInteract Example', $iGUI_Width, 400, $iGUI_Left, 20) GUICtrlCreateLabel('Please run ' & $sSend_Script_Name & ' and enter some data to send:', 10, 5, -1, 15) $iEdit = GUICtrlCreateEdit(StringFormat('Send\r\nThis\r\nData\r\nTo\r\n%s', $sSend_Script_Name), 10, 20, 580, 150) GUICtrlCreateLabel('Received:', 10, 175, -1, 15) $iReceiver_LV = GUICtrlCreateListView('Type|Data', 10, 190, 580, 170) GUICtrlSendMsg($iReceiver_LV, $LVM_SETCOLUMNWIDTH, 0, 285) GUICtrlSendMsg($iReceiver_LV, $LVM_SETCOLUMNWIDTH, 1, 285) GUICtrlCreateLabel('Send to ' & $sSend_Script_Name & ' as:', 20, 373) $iSendStr_Bttn = GUICtrlCreateButton('String', 150, 370, 70, 20) $iSendArr_Bttn = GUICtrlCreateButton('Array', 230, 370, 70, 20) $iSendBin_Bttn = GUICtrlCreateButton('Binary', 310, 370, 70, 20) GUISetState(@SW_SHOW, $hGUI) WinSetOnTop($hGUI, '', 1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iSendStr_Bttn, $iSendArr_Bttn, $iSendBin_Bttn $vData = GUICtrlRead($iEdit) Switch $nMsg Case $iSendArr_Bttn $vData = StringSplit(StringStripCR($vData), @LF) Case $iSendBin_Bttn $vData = StringToBinary($vData) EndSwitch _AppInteract_Send($sSend_App_Name, $vData, @AutoItExe) If @error Then MsgBox(48, @ScriptName, 'Unable to send, probably ' & $sSend_Script_Name & ' is not executed!', 0, $hGUI) EndIf EndSwitch WEnd Func _Receiver($vData) Local $sData = $vData Local $sType = VarGetType($vData) Switch $sType Case 'Array' $sData = _ArrayToString($vData, '~', -1, -1, Chr(10)) Case 'Binary' $sData = BinaryToString($vData) EndSwitch GUICtrlCreateListViewItem($sType & '|' & $sData, $iReceiver_LV) EndFunc Script2.au3: expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <Array.au3> #include 'AppInteract.au3' Global $iApp = 2 Global $sApp_Name = 'My App' & $iApp Global $sSend_App_Name = 'My App' & Mod($iApp, 2) + 1 Global $sSend_Script_Name = 'Script' & Mod($iApp, 2) + 1 & '.' & (@Compiled ? 'exe' : 'au3') Global $iGUI_Width = 600 Global $iGUI_Left = 100 + ($iGUI_Width * ($iApp - 1)) + (10 * ($iApp - 1)) _AppInteract_SetReceiver($sApp_Name, '_Receiver') $hGUI = GUICreate(@ScriptName & ' - AppInteract Example', $iGUI_Width, 400, $iGUI_Left, 20) GUICtrlCreateLabel('Please run ' & $sSend_Script_Name & ' and enter some data to send:', 10, 5, -1, 15) $iEdit = GUICtrlCreateEdit(StringFormat('Send\r\nThis\r\nData\r\nTo\r\n%s', $sSend_Script_Name), 10, 20, 580, 150) GUICtrlCreateLabel('Received:', 10, 175, -1, 15) $iReceiver_LV = GUICtrlCreateListView('Type|Data', 10, 190, 580, 170) GUICtrlSendMsg($iReceiver_LV, $LVM_SETCOLUMNWIDTH, 0, 285) GUICtrlSendMsg($iReceiver_LV, $LVM_SETCOLUMNWIDTH, 1, 285) GUICtrlCreateLabel('Send to ' & $sSend_Script_Name & ' as:', 20, 373) $iSendStr_Bttn = GUICtrlCreateButton('String', 150, 370, 70, 20) $iSendArr_Bttn = GUICtrlCreateButton('Array', 230, 370, 70, 20) $iSendBin_Bttn = GUICtrlCreateButton('Binary', 310, 370, 70, 20) GUISetState(@SW_SHOW, $hGUI) WinSetOnTop($hGUI, '', 1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iSendStr_Bttn, $iSendArr_Bttn, $iSendBin_Bttn $vData = GUICtrlRead($iEdit) Switch $nMsg Case $iSendArr_Bttn $vData = StringSplit(StringStripCR($vData), @LF) Case $iSendBin_Bttn $vData = StringToBinary($vData) EndSwitch _AppInteract_Send($sSend_App_Name, $vData, @AutoItExe) If @error Then MsgBox(48, @ScriptName, 'Unable to send, probably ' & $sSend_Script_Name & ' is not executed!', 0, $hGUI) EndIf EndSwitch WEnd Func _Receiver($vData) Local $sData = $vData Local $sType = VarGetType($vData) Switch $sType Case 'Array' $sData = _ArrayToString($vData, '~', -1, -1, Chr(10)) Case 'Binary' $sData = BinaryToString($vData) EndSwitch GUICtrlCreateListViewItem($sType & '|' & $sData, $iReceiver_LV) EndFunc Downloads: AppInteract_v0.5.zip AppInteract_v0.4.zip AppInteract_v0.3.zip AppInteract_v0.2.zip AppInteract_v0.1.zip Edited May 19, 2020 by MrCreatoR New version qsek, Danyfirex, yutijang and 1 other 4 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 26, 2020 Author Share Posted April 26, 2020 Update: Quote v0.2 * Better interaction in both ways. + Added $sCmdLine optional parameter to check executable command line. * Examples changed. 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 Update: Quote v0.3 + Added option to return from the receiver back to the sent process. + For the return option, added optional parameter $sRetAppName to _AppInteract_Send function. * Minor corrections. + Added examples to show how the _AppInteract_Send can get the return. 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 May 14, 2020 Author Share Posted May 14, 2020 Update: Quote v0.4 + Added x64 support. + Added more examples (Thanks to Vanguger for Example #3). * Now sent data can be any type of data except 3D (or higher) arrays, objects and structures. * Now the option to return data back from the receiver is more reliable. * _AppInteract_Send now returns only string data type (up to 1024 bytes) from the receiver. - Removed $sRetAppName parameter from _AppInteract_Send function due to change of return method. 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 May 19, 2020 Author Share Posted May 19, 2020 Update: Quote v0.5 * Removed 1024 bytes limitation (thanks to Danyfirex). * Now the return data can be any type of data except 3D (or higher) arrays, objects and structures. * Changed return values on @error in _AppInteract_Send. * Better error handling. argumentum 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...
RAMzor Posted July 2, 2022 Share Posted July 2, 2022 (edited) MrCreatoR, Many thanks for awesome UDF! Some issue: Although v0.5 shouldn't have limitation, I can't send more then 1013 chars. Your UDF crashes without any error. Edited July 2, 2022 by RAMzor 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