Jump to content

Recommended Posts

Posted

Well I'm trying to get a script a.au3 and b.au3 to communicate via console instead of TCP.

Problem is I can't understand the console and stdin stuff. Can someone explain it?

Lol - never thought I'd be in a "dumbstuck" situation.

Posted

Yes. On the same computer. b.au3 is compiled and ran by a.au3.

I need to know how I can communicate without using tcp/udp between the scripts.

Posted (edited)

  AutoIt Smith said:

Yes. On the same computer. b.au3 is compiled and ran by a.au3.

I need to know how I can communicate without using tcp/udp between the scripts.

I usually use RegWrite and RegRead and so using the Windows system registry. You can store an almost unlimited number of bits of information there, even binary data.

Most kids new to programming might start out using IniWrite and IniRead, perhaps because it is a little easier, you don't need to know the language of the Windows registry, and the file involved is a very small and simple .ini file you might store in the same folder with your script.

Another way to go is to use the FileWrite and FileRead functions, etc., and this is just a little more involved. But with these, you can pass very large volumes of information between applications.

Then there is the $CmdLine array you can read about in the AutoIt help file go to:

AutoIt help file > AutoIt > Using AutoIt > Comman Line Parameters

And lastly, you can read there about StdoutRead and StdErrRead

Edited by Squirrely1

Das Häschen benutzt Radar

Posted

  Squirrely1 said:

I usually use RegWrite and RegRead and so using the Windows system registry. You can store an almost unlimited number of bits of information there, even binary data.

Most kids new to programming might start out using IniWrite and IniRead, perhaps because it is a little easier, you don't need to know the language of the Windows registry, and the file involved is a very small and simple .ini file you might store in the same folder with your script.

Another way to go is to use the FileWrite and FileRead functions, etc., and this is just a little more involved. But with these, you can pass very large volumes of information between applications.

Then there is the $CmdLine array you can read about in the AutoIt help file go to:

AutoIt help file > AutoIt > Using AutoIt > Comman Line Parameters

And lastly, you can read there about StdoutRead and StdErrRead

Wow. That is extremely inefficient and slow - not to meantion just plain weird especially when I will be sending mainly single characters. I need COMMUNICATION between the two scripts. Not saving information.

I need someone a little bit more experienced to help.

Posted

  AutoIt Smith said:

Wow. That is extremely inefficient and slow - not to meantion just plain weird especially when I will be sending mainly single characters. I need COMMUNICATION between the two scripts. Not saving information.

I need someone a little bit more experienced to help.

What about having a hidden window of the script that needs to access the data containg an edit control? A simple Control Send from the other script would be your easiest bet. Gimme 10 for an example... :D
Posted (edited)

  AutoIt Smith said:

Wow. That is extremely inefficient and slow - not to meantion just plain weird especially when I will be sending mainly single characters. I need COMMUNICATION between the two scripts. Not saving information.

I need someone a little bit more experienced to help.

These are the only ways we have which at all native to the compilable scripting language AutoIt - perhaps you usually write programs in C++ or VB.

There is EnvSet and EnvGet for in the case that one script is a "child process" of the other.

There is at least one other way, but I forget what that is just now.

Edit 1:With Bert's mention, that makes it to be at least two other ways, one of them being found here:

AutoIt help file > AutoIt > Function Reference > Window Management > Controls

Edited by Squirrely1

Das Häschen benutzt Radar

Posted (edited)

How's this go??

Could have a lot more done to refine... Oh well!

Save and compile all of the scripts into the same folder. To start, run Receive.exe then send.exe. To exit, close receive.ece

Console.au3

;Script 1

$GUI = GUICreate ("App Name- Hidden Window", 200, 200)
$edit = GUICtrlCreateEdit ("", 0, 0, 200, 200)
GUISetState (@SW_SHOW)

While 1
    Sleep (10)
WEnd

Send.au3

; Script 2 (Sends data to console)
Dim $arr[6] = ["@ComputerName = " & @ComputerName, "@IPAddress1 = " & @IPAddress1, "@OSBuild = " & @OSBuild, "@OSLang = " & @OSLang, "@OSTYPE = " & @OSTYPE]

While 1
    If Not ProcessExists ("console.exe") Then Run ("console.exe")
    WinWait ("App Name- Hidden Window")
    $data = $arr[Random (0, 5)]
    ControlSend ("App Name- Hidden Window", "", "[CLASSNN:Edit1]", $data & "<[]>" & @LF)
WEnd

Recieve.au3

; Receive.au3
Dim $last
#Include <GuiEdit.au3>

$gui = GUICreate ("App Name", 500, 300)
$edit = GUICtrlCreateEdit ("", 0, 0, 500, 300)
GUISetState (@SW_SHOW)

While 1
    If GUIGetMsg () = -3 Then CloseScript ()
    If Not WinExists ("App Name- Hidden Window") Then
; Do Nothing
    Else
        $controltext = ControlGetText ("App Name- Hidden Window", "", "[CLASSNN:Edit1]")
        $split = StringSplit ($controltext, "<[]>")
        $text = $split[$split[0] -1]
        If $text <> $Last And $text <> "" Then 
            GUIWrite ($text)
            $last = $text
        EndIf
    EndIf
WEnd

Func GUIWrite ($text)
    _GUICtrlEdit_AppendText ($edit, $text & @LF)
EndFunc

Func CloseScript ()
    ProcessClose ("console.exe")
    ProcessClose ("send.exe")
    Exit
EndFunc
Edited by Bert
Posted

With Env Vars.

Compile, and run send.exe first. :D

Send.au3

#include <GUIConstants.au3>
Run ("Recv.exe")
Dim $arr[6] = ["@ComputerName = " & @ComputerName, "@IPAddress1 = " & @IPAddress1, "@OSBuild = " & @OSBuild, "@OSLang = " & @OSLang, "@OSTYPE = " & @OSTYPE]

$Form1 = GUICreate("Send.au3", 179, 80, 193, 125)
$Button1 = GUICtrlCreateButton("Get EnvVar1", 16, 16, 147, 25, 0)
$Button2 = GUICtrlCreateButton("Set EnvVar1", 16, 43, 147, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            CloseScript ()
        Case $Button1
            _GetVar ("[!EnvVar1!]")
        Case $button2
            EnvSet ("[!EnvVar1!]", $arr[Random (0, 5)])
    EndSwitch
WEnd

Func _GetVar ($var)
    $res = EnvGet($var)
    MsgBox(4096, $var & " is:", $res)
EndFunc

Func CloseScript ()
    ProcessClose ("send.exe")
    Exit
EndFunc

Recv.au3

#include <GUIConstants.au3>
Dim $arr[6] = ["@ComputerName = " & @ComputerName, "@IPAddress1 = " & @IPAddress1, "@OSBuild = " & @OSBuild, "@OSLang = " & @OSLang, "@OSTYPE = " & @OSTYPE]

$Form1 = GUICreate("Recv.au3", 179, 80, 193, 125)
$Button1 = GUICtrlCreateButton("Get EnvVar1", 16, 16, 147, 25, 0)
$Button2 = GUICtrlCreateButton("Set EnvVar1", 16, 43, 147, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            CloseScript ()
        Case $Button1
            _GetVar ("[!EnvVar1!]")
        Case $button2
            EnvSet ("[!EnvVar1!]", $arr[Random (0, 5)])
    EndSwitch
WEnd

Func _GetVar ($var)
    $res = EnvGet($var)
    MsgBox(4096, $var & " is:", $res)
EndFunc

Func CloseScript ()
    ProcessClose ("send.exe")
    Exit
EndFunc
Posted

@Bert Thx I'll fiddle around with this. Might be exactly what I need. The point in my direction.

@Squirel. All of those options (and I was being nice before) are utterly STUPID as a means of communications. No offense but it's not I was looking for - quit posting. Thx.

Posted

  AutoIt Smith said:

@Bert Thx I'll fiddle around with this. Might be exactly what I need. The point in my direction.

@Squirel. All of those options (and I was being nice before) are utterly STUPID as a means of communications. No offense but it's not I was looking for - quit posting. Thx.

Thats ok. I was learning too :D

@Squirel- I agree with Smithy... Quite while your ahead, or to quote your Valik Cannon, before you start to do this:

  Quote

Yet he continued to defend his flawed views until such time as every point he tried to make was blown away by multiple people.

Posted (edited)

Okay, now I know where you guys are coming from - you both are somewhat conspicuously refraining from dis-inviting me to address communications in society these days, in a more general way.

I'll bite.

On commnications:

Chapter 1, "@ Terrestrial Aliens"

My species is not innately or considerably lacking in intuition, imagination or intelligence, just like your expert epistemologists and socialogists concluded.

Chapter 2, "@ Terrestrial Native Species"

You deserve the governors God places over you, and you get the government you deserve. Knowledge is power. Don't be so powerless.

Chapter 3, "@ Everyone"

I still feel bad about so many young people going to libraries both school libraries and public ones, only to find only mostly useless books, and waste their time with so many useless pieces of literature, and so waste their whole lives, living surrounded by so much engineered misunderstanding.

Edited by Squirrely1

Das Häschen benutzt Radar

Posted (edited)

@Bert: I get it now. I have studied philosophy more than I have programming, so I hope you guys can forgive me a few transgressions I mean digressions when things aren't going so well for me - either with my social/political station or with my scripting.

Open response to Swift: No ... the Hayley Mills avatar on every one of my posts is a picture of a British actress who can't natively speak any of Isabella's proper Spanish at all, as she appeared in the B & W 1959 American movie called "Tiger Bay". Hayley Mills is the head angel - a lot prettier than LocoDarwin's avatar, which is closer to what I really look like.

Edited by Squirrely1

Das Häschen benutzt Radar

Posted

Try the Script Communication in my sig.

Posted

  AutoIt Smith said:

@Bert Thx I'll fiddle around with this. Might be exactly what I need. The point in my direction.

@Squirel. All of those options (and I was being nice before) are utterly STUPID as a means of communications. No offense but it's not I was looking for - quit posting. Thx.

Alright, I get that he was suggesting ideas that you didn't want to utilize, though they would actually do what you were asking for (asking for without providing any code even), and i will even agree that his response to this same post lost me a bit, but i really don't see why you're being so harsh as to call his help stupid. Way to encourage people to try to help others or give ideas when the OP hasn't said what he's tried already, dick. -No offense
Posted (edited)

  cameronsdad said:

Alright, I get that he was suggesting ideas that you didn't want to utilize, though they would actually do what you were asking for (asking for without providing any code even), and i will even agree that his response to this same post lost me a bit, but i really don't see why you're being so harsh as to call his help stupid. Way to encourage people to try to help others or give ideas when the OP hasn't said what he's tried already, dick. -No offense

I'm going to take BIG offense at that.

I asked for COMMUNICATION not passing data. Those ideas are criminally inefficient, don't accomplish the task without massive amounts of scripting, aren't flexible, or plug-n-play. Spotlight is about plug and play. Using Inis - Files - etc are not. Dick - offense meant.

Edited by AutoIt Smith
Posted

  AutoIt Smith said:

I'm going to take BIG offense at that.

I asked for COMMUNICATION not passing data. Those ideas are criminally inefficient, don't accomplish the task without massive amounts of scripting, aren't flexible, or plug-n-play. Spotlight is about plug and play. Using Inis - Files - etc are not. Dick - offense meant.

Hahahahaha... LOL!

@Chip- Thanks! I'm taking a look at that when my Physics homework, chemistry, maths and enlish homework is done! Yay! :D

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...