Jump to content

_Communicate UDF


ludocus
 Share

Recommended Posts

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:

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

#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
Link to comment
Share on other sites

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.

 

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

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).

 

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

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

 

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

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

*GERMAN* [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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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