Page 1 of 1

Connection between 2 PC with AHK ?

Posted: 16 Oct 2019, 12:14
by eL Tux

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 ?

Sorry for my poor english.

Re: Connection between 2 PC with AHK ?

Posted: 17 Oct 2019, 15:46
by Kobaltauge
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:
There is a messenger with this solution. Take a look if you can use some code.

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

So why not try to do the same. Push your variables to pastebin on the one side and pull them from the other side.

Re: Connection between 2 PC with AHK ?

Posted: 18 Oct 2019, 10:48
by eL Tux
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 ?

Re: Connection between 2 PC with AHK ?

Posted: 18 Oct 2019, 12:05
by Kobaltauge
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.

Re: Connection between 2 PC with AHK ?

Posted: 18 Oct 2019, 12:32
by Kobaltauge
It's an interesting riddle. =)

Googleing I found this:
This two scripts are communication on one PC with the OnMessage function. Very nice documentation:
At the end of the documentation is a link to the WinLIRC client 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.

Re: Connection between 2 PC with AHK ?

Posted: 18 Oct 2019, 12:52
by MannyKSoSo
Telegram may be a solution to the problem. The following post talk about the automation and use of Telegram

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.

Re: Connection between 2 PC with AHK ?

Posted: 19 Oct 2019, 11:30
by eL Tux
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 ?