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

Post your working scripts, libraries and tools
GeekDude
Posts: 879
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: 1561
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: 7698
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

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

21 Nov 2017, 21:20

I absolutely love it! :+1:
blue83
Posts: 117
Joined: 11 Apr 2018, 06:38

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

23 May 2020, 04:54

Hi @GeekDude and @tmplinshi ,

How can I send only string or variable back and forth without gui?

Also not only one varible, but one, two or more?

Also this is not working when I am outside of company. Why?
Is there command for timeout if client can not be connected to server?

Thanks,
Blue
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

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

25 May 2020, 11:15

@blue83 I'd assume that using the Socket.ahk (linked above) is all you need in your case.
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
blue83
Posts: 117
Joined: 11 Apr 2018, 06:38

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

26 May 2020, 03:09

Hi @BNOLI ,

Ok, looks promising, but I can not find any example of just sending string and another example of accepting that string.
I need straith client-server relation.

Can you help?

Thanks,
Blue
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

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

26 May 2020, 03:20

@blue83 Not really, I'd also be interested to see a working sample of a UDP(/TCP) server/client connection using Socket.ahk
Maybe 'the magician' AKA @GeekDude himself can shed some light on this?? :angel:
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
User avatar
haichen
Posts: 486
Joined: 09 Feb 2014, 08:24

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

26 May 2020, 05:40

I once something, but because my answer is only to the socket I moved the code there.
https://www.autohotkey.com/boards/viewtopic.php?p=331506#p331506
blue83
Posts: 117
Joined: 11 Apr 2018, 06:38

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

26 May 2020, 08:34

Hi @GeekDude ,

This is working fine when I am connected with VPN to my company network, but I need this to work from any network and computer with my company computer on company network?

Any idea?

Thanks,
Blue
User avatar
haichen
Posts: 486
Joined: 09 Feb 2014, 08:24

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

26 May 2020, 09:12

I think this will only work in your local net.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 33 guests