Jump to content

Communicate.au3


zcoacoaz
 Share

Recommended Posts

this is just a simple include that i wrote so you can send messages to scripts running on the same computer (example included)

Include:

Func _CommStart ( $sAppName, $sSend = '' )
    AutoItWinSetTitle ( $sAppName )
    $hwnd = WinGetHandle ( $sAppName )
    ControlSetText ( $hwnd, '', 1, $sSend )
    Return $hwnd
EndFunc

Func _CommSend ( $nHwnd, $sSend = '' )
    ControlSetText ( $nHwnd, '', 1, $sSend )
EndFunc

Func _CommGet ( $sName )
    $return = ControlGetText ( $sName, '', 1 )
    ControlSetText ( $sName, '', 1, '' )
    Return $return
EndFunc

Func _CommDebug ( $nHwnd, $nMode = 1 )
    If $nMode = 1 Then $nMode = @SW_SHOW
    WinShow ( $nHwnd, '', $nMode )
EndFunc

Part one of example:

#include <communicate.au3>
#include <guiconstants.au3>
$comm_handle = _CommStart ( "Communication 01" )
GUICreate ( "Communication Example", 300, 300 )
$edit = GUICtrlCreateEdit ( "", 0, 20, 300, 280, $ES_READONLY )
$input = GUICtrlCreateInput ( "", 0, 0, 250, 20 )
$button = GUICtrlCreateButton ( "Send", 250, 0, 50, 20, $BS_DEFPUSHBUTTON )
GUISetState ( )
Do
    Sleep ( 10 )
    $get = _CommGet ( "Communication 02" )
    If StringLen ( $get ) > 0 Then
        GUICtrlSetData ( $edit, GuiCtrlRead ( $edit ) & @CRLF & $get )
    EndIf
    If $get = "quit" Then ExitLoop
    If GUIGetMsg ( ) = $button Then
        _CommSend ( $comm_handle, GuiCtrlRead ( $input ) )
        If GuiCtrlRead ( $input ) = "quit" Then ExitLoop
        GUICtrlSetData ( $input, '' )
    EndIf
Until GUIGetMsg ( ) = -3

Part 2 of example:

#include <communicate.au3>
#include <guiconstants.au3>
$comm_handle = _CommStart ( "Communication 02" )
GUICreate ( "Communication Example", 300, 300 )
$edit = GUICtrlCreateEdit ( "", 0, 20, 300, 280, $ES_READONLY )
$input = GUICtrlCreateInput ( "", 0, 0, 250, 20 )
$button = GUICtrlCreateButton ( "Send", 250, 0, 50, 20, $BS_DEFPUSHBUTTON )
GUISetState ( )
Do
    Sleep ( 10 )
    $get = _CommGet ( "Communication 01" )
    If StringLen ( $get ) > 0 Then
        GUICtrlSetData ( $edit, GuiCtrlRead ( $edit ) & @CRLF & $get )
    EndIf
    If $get = "quit" Then ExitLoop
    If GUIGetMsg ( ) = $button Then
        _CommSend ( $comm_handle, GuiCtrlRead ( $input ) )
        If GuiCtrlRead ( $input ) = "quit" Then ExitLoop
        GUICtrlSetData ( $input, '' )
    EndIf
Until GUIGetMsg ( ) = -3

the example tends to hang, i think its partly the example and partly the functions i'm not really sure

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

What's an example use of this?

EDIT: Real-world use*

Edited by Insolence
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

no idea :)

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

lol

I was thinking the same thing :)

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

I guess it could be used if a script already has an adlib and needs something else at the same time, it can use this to share variables... Be creative and don't tell anyone it doesn't have a real good use :)

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Will do :)

But just to be a dick, I think you could do the same with command line stuff, for the most part.

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

For the most part, yes. But this can simplify doing some things

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Agreed. I suppose if you had to change something, you'd have to start that other program _all_ over again.

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

And there arose a great cheer, because with the new technology, a full restart of the 4 billion year program was not required. With only some minor directions, it became possible to correct the incorrectly thinking program, directing it to find the result we craved.

Actually might be usefull, in a large integrated environment, but the mind boggles at the thought of an implementation large enough to require it. AutoItOS? :)

601DisengageEnd Program

Link to comment
Share on other sites

Good idea, We will create the greatest OS ever! AutoItOS... Now to figure out how to port autoit to it :)

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Would you consider this sharing between programs similar to M$ Open Database Connectivity (ODBC) or ADO (ActiveX Data Objects)? This allows M$ programs to show data between them..

No. For one simple reason.

The ODBC/ADO models require a process to record information to an external medium (hard drive/server) which then may be accessed by another process.

The idea here is communication between processes without intermediary storage.

Say, for example, you wanted to run a test on 8 possibilites, and for some reason you wanted to run the test on two things at once, and do it all on one processor. (not that you ever would, but for the sake of argument lets say you might). You would want a interprocess communication protocol that goes something like this:

Process 1: working on example 1, start on example 2

Process 2: finished example 2, starting example 3, start on 4 next

Process 1: finished example 4, start on example 5

and so on and so forth

601DisengageEnd Program

Link to comment
Share on other sites

I'll look into it, i think i can do it with com. This was really just a simple script that i created for fun.

Can't i do it with com? http://www.developerfusion.com/show/23/1/ <---- im reading this

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

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