AutoHotkey Community

It is currently May 27th, 2012, 11:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: August 18th, 2005, 3:18 am 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
Terminal Script:
Code:
;Msg Terminal Script, used for passing msgs with
;ControlSetText
;ControlGetText
#NoTrayIcon
;Port Amount, How many ports should this terminal have?
P_Amt = 300
TerminalName = Msg_Terminal

;Text used as for Identifying the script
gui, add, text, , %TerminalName%

Loop, %P_Amt%
{
   Gui, Add, Edit, vMsg%A_Index% -wantreturn
}

SetTimer, WatchExit
Return

WatchExit:
Gui, Submit
If Msg1 = Exit
   ExitApp
If Msg1 = Reload
   Reload
Return



Function for sending and retrieving from the terminal script.
Code:
DetectHiddenWindows, On
SetTitleMatchMode, 3

Var := Msg("s", 2, "Msg_Terminal", "SomeTextToSendToTheTerminal")
MsgBox %Var%
Return

; Dir = Direction of msg, S for Send, R for Recieve
; Port = The number of the port to call upon.
; Terminal Name = The name of the terminal to accept call
; MsgText = The Text to be sent.
Msg(Dir,Port,TerminalName,MsgText)
{
   ;Checks if terminal window exists
   IfWinNotExist, ahk_class AutoHotkeyGUI, %TerminalName%
      MsgBox Error! `nTerminal does not exist.   
   ;Checks if port exists
   ControlGetPos, Xpos_,,,, Edit%Port%, ahk_class AutoHotkeyGUI, %TerminalName%
   If XPos_ =
      Msgbox Error! `nPort may not exist.
   ;Send
   If Dir = S
      ControlSetText, Edit%Port%, %MsgText%, ahk_class AutoHotkeyGUI, %TerminalName%
   ;Recieve
   If Dir = R
      ControlGetText, ReturnText, Edit%Port%, ahk_class AutoHotkeyGUI, %TerminalName%
   Return %ReturnText%
}


Function Syntax
Msg("S/R", PortNumber, "TerminalName", "Text")

The Terminal script has two options, the amount of ports that will hold information(Text only) and the name of the Terminal. The name of the terminal is used when calling it in the function, so that multiple terminals may exist, each must have a seperate name. The amount of ports affects the size of the script. This one has 300, and you may not need that many. The maximum is 10,999, and use caution with amounts greater than 4999.

The First port is reserved for handling 'commands' sent to the terminal via the function. The following are supported and explained. More may be added later on.

Exit -exits the terminal and closes it.
Reload - Restarts the terminal(clearing the contents of all ports)

Example For Closing the Terminal Script
Msg("s", 1, "Msg_Terminal", "Exit")

The terminal script should be run alone, while its calling function can be used in any seperate script. I find this method useful for notifying other scripts of status changes among themselves. It also seems to be an easy way for a new user to communicate between script as I have so many threads asking about it.

_________________
my lame sig :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2007, 11:03 am 
intresting idea, i will look into it once i get into it :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2007, 12:51 pm 
Offline

Joined: February 5th, 2007, 12:19 pm
Posts: 192
Location: Osnabrück, Germany
Wow..
Beautiful idea and easy to understand. I like it!
:D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2007, 12:44 pm 
Offline

Joined: July 15th, 2005, 3:19 pm
Posts: 140
Location: Denmark
I love the creativity behind this solution. Easy and simple. One could probably solve this problem in ways that are amazingly complex, but there is no reason to.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2007, 2:08 pm 
A possible gotcha could be concurrent access/update, but I don't know if that's really an issue.
Anyway, it is a very creative idea!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2007, 2:19 pm 
Hmm, that could be very useful at work. I will check it out in more details tomorrow.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2008, 2:38 pm 
I want to revive this topic.... IThe basic question is, besides (1) Clipboard (2) Write to File and (3) ControlSet on a hidden window, is there any other "Memory" where all scripts can access -- since we don't have access to direct memory? I'm sure there are more ways out there.

It seems like a nice idea to include into the next implementation of autohotkey -- virtual clipboards, registers, whatever.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2008, 2:44 pm 
Offline

Joined: October 26th, 2005, 5:11 pm
Posts: 28
Really, the storage is no big deal. Any script can handle the storage as an array. But I don't know of any way to send like a long text string to another script, besides the above named methods.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 20th, 2009, 10:47 pm 
Offline

Joined: February 20th, 2007, 1:37 pm
Posts: 198
Location: D.C.
So if I have a script that I want to use to control four other scripts, would I want to use 5 teminals or can I have all the receiving scripts watch the same terminal? Part of my issue is having them execute the commands they receive from the sending script as synced as possible.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot], nomissenrojb and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group