Jump to content

AppInteract - Yet another interaction UDF


MrCreatoR
 Share

Recommended Posts

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:

#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:

#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 by MrCreatoR
New version

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

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_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

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_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

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_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

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.

 

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 2 years later...

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