RemoteObj.ahk - Access objects remotely over a TCP/IP network

Post your working scripts, libraries and tools
GeekDude
Posts: 844
Joined: 02 Oct 2013, 22:13

RemoteObj.ahk - Access objects remotely over a TCP/IP network

30 Jul 2017, 19:10

RemoteObj.ahk

Access objects remotely over a TCP/IP network. See it in action on Imgur!

Dependencies
Usage

Publishing an Object to the Network

Code: Select all

ObjToPublish := new Test() ; This is the object that will be published
Bind_Addr := "127.0.0.1" ; Only accept connections from localhost
Bind_Port := 1337 ; Listen for connections on port 1337

Server := new RemoteObj(ObjToPublish, [Bind_Addr, Bind_Port])

class Test {
	InputBox(Prompt) {
		InputBox, Out, % this.Title, %Prompt%
		return Out
	}
}
Connecting to a Published Object

Code: Select all

Remote_Addr := "127.0.0.1" ; Connect to local host
Remote_Port := 1337 ; Connect to port 1337

Remote := new RemoteObjClient([Remote_Addr, Remote_Port])

Remote.Title := "Hello World!"
MsgBox, % Remote.InputBox("Type something!")
Related Projects
  • GeekBot uses RemoteObj.ahk for its plugins, and for integration with PHP and Python

Download
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: RemoteObj.ahk - Access objects remotely over a TCP/IP network

27 Aug 2017, 03:43

Thank you! Very easy to use.

An example of connecting to server using computer name:

Server:

Code: Select all

ObjToPublish := new Test() ; This is the object that will be published
Bind_Addr := A_IPAddress1 ; Local IP (it looks like 192.168.1.xxx)
Bind_Port := 1337 ; Listen for connections on port 1337

Server := new RemoteObj(ObjToPublish, [Bind_Addr, Bind_Port])

class Test {
	InputBox(Prompt) {
		InputBox, Out, % this.Title, %Prompt%
		return Out
	}
}
Client:

Code: Select all

Ping4("The_Server_Computer_Name", Result) ; Ping4 by just me -- https://autohotkey.com/boards/viewtopic.php?f=6&p=167334
If (ErrorLevel) {
	MsgBox, 16, Ping4, Error:`r`n%ErrorLevel%
	ExitApp
}

Remote_Addr := Result.IPAddr
Remote_Port := 1337 ; Connect to port 1337

Remote := new RemoteObjClient([Remote_Addr, Remote_Port])

Remote.Title := "Hello World!"
MsgBox, % Remote.InputBox("Type something!")
User avatar
joedf
Posts: 6605
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: RemoteObj.ahk - Access objects remotely over a TCP/IP network

21 Nov 2017, 21:20

I absolutely love it! :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 24 guests