Jump to content



Photo

_Communicate UDF


  • Please log in to reply
17 replies to this topic

#1 ludocus

ludocus

    Possibly inventive crap going on right here

  • Active Members
  • PipPipPipPipPipPip
  • 664 posts

Posted 20 September 2010 - 03:15 PM

Hiii!

I made this UDF for making my scripts being able to communicate with each other.
It uses a file to store data and check data for the command transfer.
This script will execute your function when your program got a command.

;Functions: ;   _CommunicateStartup ;   _CommunicateSend ;   _CommunicateGetCommands ;   _CommunicateBroadcast ;   _CommunicateRenewFile ;   _CommunicateGetUsers ;   _CommunicateEnd


UDF:
AutoIt         
#include-once ;Be sure to not use these variables in your script: global $sInit, $sData1, $sData2, $szgCommandings[3], $xProgramFile = @WindowsDir&'\CommunicationPrograms.cmf', $xyzAdlibFunc='', $rpdHandle[3], $lrszSpeed='' global $yzlMaxLines = 200 ;Max lines of the communication files. If it contains more lines than this var the file will be renewed/cleared with _CommunicateRenewFile ;^ Set to -1 if you do not want this to be done automaticly ;Functions: ;   _CommunicateStartup ;   _CommunicateSend ;   _CommunicateGetCommands ;   _CommunicateBroadcast ;   _CommunicateRenewFile ;   _CommunicateGetUsers ;   _CommunicateEnd ;============================================================================= ; Description:      Starts up the communication ; Version:          1.0.0 ; Syntax:           _CommunicateStartup($sApp, $sFunction, $hFile=1, $xSpeed=200) ; ; Parameter(s):     $sApp       = The name of your program/app, you'll this need when using _CommunicateSend ;                   $sFunction  = The name of the function that will be called when a command has been send to you, The function should look like this: ;                                 _Function($command). The $command is an array. $command[1] contains the command, $command[2] contains the name of the ;                                 name of the program that send it to you. ;                   $hFile      = The file that you want to use for the communication. Default is: @WindowsDir&'\CommunicationFile.cmf' ;                   $xSpeed     = The speed that you want to use for getting commands. Default is: 200, (recommended) ; Requirement(s):   - ; Return Value(s):  On Success - Returns a handle you'll need for other functions. ;                   On Failure - Returns an empty string and sets @Error on errors ;                          @Error=1 $sApp, $sFunction, $hFile or/and $xSpeed is/are containing nothing. ;                          @Error=2 Could not create communication file ;                          @Error=3 Could not create program file ;                          @Error=4 Could not write $sApp to program file ; Author(s):        Ludocus <ludovic1993@hotmail.com> ; Note(s):          This works like an OnEvent function using AdlibRegister and executing your function when a command has been send to you. ;                   Do not use this function more than once in your script. ;=============================================================================== Func _CommunicateStartup($sApp, $sFunction, $hFile=1, $xSpeed=200)     if $sApp = '' or $sFunction = '' or $hFile = '' or $xSpeed = '' Then return SetError(1)     if $hFile = 1 then $hFile = @WindowsDir&'\CommunicationFile.cmf'     $lrszSpeed = $xSpeed     if not FileExists($hFile) then         If not FileWrite($hFile, '-start communicate file-') then return SetError(2)     EndIf     if not FileExists($xProgramFile) then         If not FileWrite($xProgramFile, '-programs running-') then return SetError(3)     EndIf     $xyzAdlibFunc=$sFunction     if not FileWrite($xProgramFile, @CRLF&$sApp) then return SetError(4)     AdlibRegister('_CommunicateAdlib', $lrszSpeed/2)     $rpdHandle[1] = $hFile     $rpdHandle[2] = $sApp     return $rpdHandle EndFunc ;============================================================================= ; Description:      Sends a command to an app ; Version:          1.0.0 ; Syntax:           _CommunicateSend($sHandle, $sToApp, $xCommand) ; ; Parameter(s):     $sHandle    = The handle returned from _CommunicateStartup ;                   $sToApp     = The name of the app/program you want to send a command ;                   $xCommand   = The command you want to send ; Requirement(s):   - ; Return Value(s):  On Success - Returns 1 ;                   On Failure - Returns 0 or sets error to: ;                          @Error=1 $sHandle isn't an array ; Author(s):        Ludocus <ludovic1993@hotmail.com> ; Note(s):          ;=============================================================================== Func _CommunicateSend($sHandle, $sToApp, $xCommand)     if not IsArray($sHandle) then return SetError(1)     $hFile = $sHandle[1]     $sApp = $sHandle[2]     $sRet = FileWrite($hFile, @CRLF&$sToApp&'->'&$xCommand&'<-'&$sApp)     return $sRet EndFunc ;============================================================================= ; Description:      Returns all raw commands that have been send since last file creation/renewing ; Version:          1.0.0 ; Syntax:           _CommunicateGetCommands($sHandle) ; ; Parameter(s):     $sHandle    = The handle returned from _CommunicateStartup ; Requirement(s):   - ; Return Value(s):  On Success - Returns all raw commands ;                   On Failure - Returns 0 or sets error to: ;                          @Error=1 $sHandle isn't an array ; Author(s):        Ludocus <ludovic1993@hotmail.com> ; Note(s):          Returns raw commands, for example: toApp->Command<-App ;=============================================================================== Func _CommunicateGetCommands($sHandle)     if not IsArray($sHandle) then return SetError(1)     $hFile = $sHandle[1]     $sApp = $sHandle[2]     $sData = FileRead($hFile)     Return $sData EndFunc ;============================================================================= ; Description:      Broadcasts a command to all programs ; Version:          1.0.0 ; Syntax:           _CommunicateBroadcast($sHandle, $xCommand) ; ; Parameter(s):     $sHandle    = The handle returned from _CommunicateStartup ;                   $xCommand   = The command you want to send ; Requirement(s):   - ; Return Value(s):  On Success - Returns 1 ;                   On Failure - Returns 0 or sets error to: ;                          @Error=1 $sHandle isn't an array ; Author(s):        Ludocus <ludovic1993@hotmail.com> ; Note(s):          ;=============================================================================== Func _CommunicateBroadcast($sHandle, $xCommand)     Return _CommunicateSend($sHandle, '=(++[-ALL-]++)=', $xCommand) EndFunc ;============================================================================= ; Description:      Renews the communication file (clears it) ; Version:          1.0.0 ; Syntax:           _CommunicateRenewFile($sHandle) ; ; Parameter(s):     $sHandle    = The handle returned from _CommunicateStartup ; Requirement(s):   - ; Return Value(s):  On Success - Returns 1 ;                   On Failure - Returns 0  = Was not able to FileDelete or FileWrite $hFile ;                              - Returns -1 = Was not able to FileDelete and FileWrite $hFile ; Author(s):        Ludocus <ludovic1993@hotmail.com> ; Note(s):          Use this function when you think the communication file is getting too big. ;                   This function will be called automaticly when the amount of lines of the file is higher than $yzlMaxLines ;=============================================================================== Func _CommunicateRenewFile($sHandle)     $hFile = $sHandle[1]     $sRet = _CommunicateBroadcast($sHandle, '--RENEWING FILE--')     $sRet -= FileDelete($hFile)     $sRet -= FileWrite($hFile, '-start communicate file-')     return $sRet EndFunc ;============================================================================= ; Description:      Gets the users using the communication right now ; Version:          1.0.0 ; Syntax:           _CommunicateGetUsers($sHandle) ; ; Parameter(s):     $sHandle    = The handle returned from _CommunicateStartup ; Requirement(s):   - ; Return Value(s):  On Success - Returns 1 ;                   On Failure - Returns 0 ; Author(s):        Ludocus <ludovic1993@hotmail.com> ; Note(s):          Could be wrong when a program did not call _CommunicateEnd at exit ;=============================================================================== Func _CommunicateGetUsers($sHandle)     return FileRead($xProgramFile) EndFunc ;============================================================================= ; Description:      Ends the communication ; Version:          1.0.0 ; Syntax:           _CommunicateEnd($sHandle) ; ; Parameter(s):     $sHandle    = The handle returned from _CommunicateStartup ; Requirement(s):   - ; Return Value(s):  On Success - Returns 1 ;                   On Failure - Returns 0 ; Author(s):        Ludocus <ludovic1993@hotmail.com> ; Note(s):          Call this function on exit. ;                   When this function is not called on exit the _CommunicateGetUsers will get the wrong users. ;=============================================================================== Func _CommunicateEnd($sHandle)     AdlibUnRegister($xyzAdlibFunc)     $hFile = $sHandle[1]     $sApp = $sHandle[2]     $ySplit = StringSplit(FileRead($xProgramFile), @CRLF, 1)     $sFileData = ''     For $i = 1 to $ySplit[0]         if $ySplit[$i] <> $sApp Then             if $sFileData = '' Then                 $sFileData = $ySplit[$i]             Else                 $sFileData &= @CRLF&$ySplit[$i]             EndIf         EndIf     Next     FileDelete($xProgramFile)     Return FileWrite($xProgramFile, $sFileData) EndFunc ;Do not use these functions: ;----------------------------------- Func _CommunicateListener($sHandle, $sSpeed=200)     if not IsArray($sHandle) then return SetError(1)     if $xyzAdlibFunc='' then return SetError(2)     if $sSpeed <= 10 then return SetError(3)     $lCommand = 0     $hFile = $sHandle[1]     $sApp = $sHandle[2]     if $sInit = '' Then         $sInit = TimerInit()         $sData1 = FileRead($hFile)     Else         $sDiff = TimerDiff($sInit)         if $sDiff >= $sSpeed Then             $sData2 = FileRead($hFile)             if $sData1 <> $sData2 Then                 $zSplit = StringSplit($sData2, @CRLF, 1)                 $zSplit2 = StringSplit($zSplit[$zSplit[0]], '->', 1)                 if $zSplit2[1] = $sApp or $zSplit2[1] = '=(++[-ALL-]++)=' then                     $zSplit3 = StringSplit($zSplit2[2], '<-', 1)                     if $zSplit3[2] <> '--RENEWING FILE--' Then                         $szgCommandings[1] = $zSplit3[1]                         $szgCommandings[2] = $zSplit3[2]                         Execute($xyzAdlibFunc&'($szgCommandings)')                     Else                         $sData2 = '-start communicate file-'                     EndIf                 EndIf             EndIf             $sData1 = $sData2         EndIf     EndIf     return $lCommand EndFunc Func _CommunicateAdlib()     if $yzlMaxLines <> -1 and __FileCountLines($rpdHandle[1]) > $yzlMaxLines then _CommunicateRenewFile($rpdHandle)     if $rpdHandle <> '' and $lrszSpeed <> '' Then         _CommunicateListener($rpdHandle, $lrszSpeed)     EndIf EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: __FileCountLines ; Description ...: Returns the number of lines in the specified file. ; Syntax.........: __FileCountLines($sFilePath) ; Parameters ....: $sFilePath - Path and filename of the file to be read ; Return values .: Success - Returns number of lines in the file. ;                  Failure - Returns a 0 ;                  @Error  - 0 = No error. ;                  |1 = File cannot be opened or found. ; Author ........: Tylo <tylo at start dot no> ; Modified.......: Xenobiologist, Gary ; Remarks .......: It does not count a final @LF as a line. ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func __FileCountLines($sFilePath)     Local $hFile = FileOpen($sFilePath, 0)     If $hFile = -1 Then Return SetError(1, 0, 0)     Local $sFileContent = StringStripWS(FileRead($hFile), 2)     FileClose($hFile)     Local $aTmp     If StringInStr($sFileContent, @LF) Then         $aTmp = StringSplit(StringStripCR($sFileContent), @LF)     ElseIf StringInStr($sFileContent, @CR) Then         $aTmp = StringSplit($sFileContent, @CR)     Else         If StringLen($sFileContent) Then             Return 1         Else             Return SetError(2, 0, 0)         EndIf     EndIf     Return $aTmp[0] EndFunc   ;==>_FileCountLines ;-----------------------------------


Example:
AutoIt         
#cs ----------------------------------------------------------------------------  AutoIt Version: 3.3.6.1  Author:         Ludocus  Script Function:     Explaining the Communicate UDF #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Communicate.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> $1 = '' $_ = _Stripe() $Handle = _CommunicateStartup('Example', '_GotCommand') ;Example = name of app, _GotCommand = Function that'll be called when we got a command! $Form1 = GUICreate("Example", 560, 310, 193, 125) $Label1 = GUICtrlCreateLabel("Program:", 16, 24, 46, 17) $Input1 = GUICtrlCreateInput("Leave blank for broadcast", 16, 48, 121, 21) $Label2 = GUICtrlCreateLabel("Command:", 16, 96, 54, 17) $Input2 = GUICtrlCreateInput("", 16, 120, 121, 21) $Button1 = GUICtrlCreateButton("Send", 32, 160, 75, 25, 0) $Edit1 = GUICtrlCreateEdit("Communication:"&@CRLF&$_, 200, 0, 361, 313) GUISetState(@SW_SHOW) $x = TimerInit() $y = 0 While 1     if TimerDiff($x) > $y + 200 Then         _Refresh()         $y = TimerDiff($x)     EndIf     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit                     Case $Button1             if GUICtrlRead($Input1) = '' Then                 _CommunicateBroadcast($Handle, GUICtrlRead($Input2))             Else                 _CommunicateSend($Handle, GUICtrlRead($Input1), GUICtrlRead($Input2))             EndIf             GUICtrlSetData($Input1, '')             GUICtrlSetData($Input2, '')     EndSwitch WEnd Func _Refresh()     if $1 = '' Then         $1 = _CommunicateGetCommands($Handle)     Else         $2 = _CommunicateGetCommands($Handle)         if $1 <> $2 then             $splz = StringSplit($2, @CRLF, 1)             GUICtrlSetData($Edit1, GUICtrlRead($Edit1)&@CRLF&$splz[$splz[0]]&@CRLF&$_)         EndIf         $1 = $2     EndIf EndFunc Func _GotCommand($command) ;This function will be called when you got a command!     ;$command[1] = Command     ;$command[2] = Program that send the command     GUICtrlSetData($Edit1, GUICtrlRead($Edit1)&@CRLF&'You got a command from: '&$command[2]&@CRLF&'The command is: '&$command[1]&@CRLF&$_) EndFunc Func _Exit()     Exit EndFunc Func _Stripe($x=112)     $p = ''     For $i = 1 to $x         $p &= '-'     Next     return $p EndFunc


I hope you like it and find it useful. ;)

Ludocus

Edited by ludocus, 20 September 2010 - 03:16 PM.






#2 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 20 September 2010 - 04:01 PM

I don't like the idea that my script will access the hard drive every time, i think it's wrong approach. There are much more efficient ways to interact between scripts.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image 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 ProgramPosted Image UDFs: 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 UDFPosted Image 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#3 ludocus

ludocus

    Possibly inventive crap going on right here

  • Active Members
  • PipPipPipPipPipPip
  • 664 posts

Posted 20 September 2010 - 04:07 PM

I don't like the idea that my script will access the hard drive every time

And why don't you like that idea?

#4 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 20 September 2010 - 04:11 PM

And why don't you like that idea?

Because i don't think that program should behave like this (maybe only if really neccessary, and this is definitly not the case).
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image 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 ProgramPosted Image UDFs: 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 UDFPosted Image 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#5 ludocus

ludocus

    Possibly inventive crap going on right here

  • Active Members
  • PipPipPipPipPipPip
  • 664 posts

Posted 20 September 2010 - 04:16 PM

Hmm.. You still haven't given the reason why this is negative for the script
If using fileread rapidly is bad for your computer or whatever than I would agree

Edited by ludocus, 20 September 2010 - 04:17 PM.


#6 ivan

ivan

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 398 posts

Posted 20 September 2010 - 04:28 PM

And why don't you like that idea?

First, I've not tested your script, and perhaps it would be a good idea to do so before placing a comment. However, I've done similar procedures in the past and found problems.

I see you created timers to co-ordinate the read/write to the file. I've run into slow CPU when doing this, but I actually use the same concept when reading logs that are being created via third party software, eg. wget. In this case, only one exe opens the file in write mode, while the other in read mode. Even then, I've had to increase timer speed up to 1000 ms to avoid the cpu overloading.

I'm quite interested in seeing if and how you resolved the issue.

Regards,
Ivan

#7 ludocus

ludocus

    Possibly inventive crap going on right here

  • Active Members
  • PipPipPipPipPipPip
  • 664 posts

Posted 20 September 2010 - 04:37 PM

Hmmm..
Doesn't give me a CPU more than 0 or 2.
Just check it out!

#8 Zibit

Zibit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 262 posts

Posted 20 September 2010 - 05:29 PM

I like the idea of the script but not how it's constructed. Communicated through a file is probably the most basic communication way there is. Did you know when a script writes a file then the file's content is deleted during the process.

Better way of communication is TCP/UDP Ports. Or creating a virtual network where they can communicate without writing files or anything.

#9 Zibit

Zibit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 262 posts

Posted 20 September 2010 - 05:30 PM

Another good communication way is memory writing or command lines.

#10 ludocus

ludocus

    Possibly inventive crap going on right here

  • Active Members
  • PipPipPipPipPipPip
  • 664 posts

Posted 20 September 2010 - 06:56 PM

I know I know,
I'll change it to TCP when I feel like it (probably tomorrow)

#11 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 20 September 2010 - 07:28 PM

You still haven't given the reason why this is negative for the script

It's bad for the hard drive, you are making a demage to the hardware!
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image 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 ProgramPosted Image UDFs: 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 UDFPosted Image 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#12 dmob

dmob

    Prodigy

  • Active Members
  • PipPipPip
  • 191 posts

Posted 21 September 2010 - 10:55 AM

I have found that trancexx's MailSlot UDF is much easier to use, is very fast,
almost no setting up, no external files, and can handle multiple communication
streams within the same script, and works across a network.

I use it extensively in my scripts, and it just works....

Edited by dmob, 21 September 2010 - 10:58 AM.


#13 ludocus

ludocus

    Possibly inventive crap going on right here

  • Active Members
  • PipPipPipPipPipPip
  • 664 posts

Posted 21 September 2010 - 12:14 PM

good for you dmob!
I think my script is easier to use though.
You only need _CommunicateStartup and _CommunicateSend, + it works onEvent.
but I'll make it TCP now.

#14 Zibit

Zibit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 262 posts

Posted 21 September 2010 - 05:54 PM

Although your not the first one with the idea a lot of programs use similar functions.
e.g dump files, internal logs ( often used in gaming ) and temp files but still not a good idea for script communication.

#15 Zibit

Zibit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 262 posts

Posted 21 September 2010 - 07:20 PM

I noticed that you cant do a Communication UDF using TCP becouse doing that you would just rename a function. It's directly Communication between script which is exactly the same thing as TCP/UDP becouse your script would do it locally but TCP/UDP can be local and global.

#16 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 21 September 2010 - 07:26 PM

I think, WM_COPYDATA is a good solution for event based communication ;)
*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#17 Spiff59

Spiff59

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,312 posts

Posted 21 September 2010 - 07:50 PM

I think, WM_COPYDATA is a good solution for event based communication ;)

I was waiting for someone to suggest that! I was suprised at how easily, and in how few lines of code, that a tweaked version of WM_COPYDATA, found in the forums, worked for my (apparently unpopular <sniff>) Battle Checkers program.

I don't really get the debate in this thread though... Minus a requirement for data retention, I dont understand the need to involve a slow mechanical process in what could be a simple electronic exchange.

#18 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 4,040 posts

Posted 21 September 2010 - 07:59 PM

For all my programs I write now I use WM_COPYDATA, and whenever a new instance of the program is run when there's already one running it sends the commandline to the program, allowing it to add an item if it's tabbed etc. I assume a similar method is used in proper text editors (I know SciTE has WM_COPYDATA behind it's director interface for example)

Files are only useful if the programs aren't running simultaneously IMO.

Mat

I don't know where I'm going, but I'm on my way.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users