Connection between 2 PC with AHK ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
eL Tux
Posts: 66
Joined: 06 Nov 2015, 07:52

Connection between 2 PC with AHK ?

16 Oct 2019, 12:14

Hi,

I want to send some variables over internet to another PC, i know how to do it with WinHttp.Winhttprequest.5.1 and some PHP code on my server, but in this way I need to send a permanent requests to get the new variable. I think this is not a good solution for the Server bandwidth, so what I can use to send and get new variable over internet between 2 PC ?

Thanks,
Sorry for my poor english.
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: Connection between 2 PC with AHK ?

17 Oct 2019, 15:46

If you want to communicate between two PCs you need something like a server and a client. In Python, I would use sockets (if they are not blocked by firewalls) and there is a AHK implementation:
https://autohotkey.com/board/topic/53827-ahksock-a-simple-ahk-implementation-of-winsock-tcpip/
There is a messenger with this solution. Take a look if you can use some code.
https://autohotkey.com/board/topic/86063-ahkmessenger-a-winsock-based-chat-serverclient-download/

But I have another idea. This AHKv2 script uses pastebin as a file exchange.

https://www.autohotkey.com/boards/viewtopic.php?f=6&t=63375&hilit=pastebin

So why not try to do the same. Push your variables to pastebin on the one side and pull them from the other side.
eL Tux
Posts: 66
Joined: 06 Nov 2015, 07:52

Re: Connection between 2 PC with AHK ?

18 Oct 2019, 10:48

I already tried winsocket method, but the problem we need to open some ports in firewall, so this is not a good solution for me.

About pastebin, this is maybe a good idea but how we can get the new varable automatiquely and fastly without doing permanente requests ?
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: Connection between 2 PC with AHK ?

18 Oct 2019, 12:05

Do I understand right? You have a script that runs all the time. And this script has to get the new variable a soon there is one. But this script should not check permanently the source.
So it's not a pull, it's a push from the other side. Therefore, the pastebin solution is not the best. And to be honest, at the moment I don't know how to trigger the script from another side without sockets.
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: Connection between 2 PC with AHK ?

18 Oct 2019, 12:32

It's an interesting riddle. =)

Googleing I found this: https://autohotkey.com/board/topic/92898-need-help-with-communicating-between-scripts/#entry585770
This two scripts are communication on one PC with the OnMessage function. Very nice documentation: https://www.autohotkey.com/docs/commands/OnMessage.htm
At the end of the documentation is a link to the WinLIRC client https://www.autohotkey.com/docs/scripts/WinLIRC.htm. This seems to be a solution for you.

BUT! To enable this, there must be a direct connection through the internet from one PC to the other. Or the receiving PC must have a public address and the port it's providing must be accessible through the firewall. So it's the same problem with the socket connection. This is the main problem, not how to get two script to communicate.

Why not check in intervals like 10 minutes and only if there is a new variable pull it. I can't imagine that this cost so much bandwidth.
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: Connection between 2 PC with AHK ?

18 Oct 2019, 12:52

Telegram may be a solution to the problem. The following post talk about the automation and use of Telegram
https://www.autohotkey.com/boards/viewtopic.php?t=24919
https://www.autohotkey.com/boards/viewtopic.php?&t=42031&start=20

I believe what others have done is be able to send variables over via the Telegram api which triggers the Telegram bots to run processes on that computer. It has been a while since I have done it, but it should be possible. Also with this you shouldn't need to worry about the firewall since its coming from a browser.

If both of your computers have access to the same folder you could also just read from a specific folder connection, and just check it every so often.
eL Tux
Posts: 66
Joined: 06 Nov 2015, 07:52

Re: Connection between 2 PC with AHK ?

19 Oct 2019, 11:30

well... so there is no good solution, i can't open ports and i can't use telegram because ill need a phone number.

But maybe i found something good, what about using a server with some PHP code and Ajax code like Comet/Ajax push to push new variables.
I probably need to use a hidden web page or maybe using ActiveX ?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: scriptor2016 and 324 guests