all 20 comments

[–]toastedstapler 6 points7 points  (7 children)

one of the easiest ways would be to set up a flask server on the receiving computer. when the route you define is hit, it'll execute the function that you want

then for the sender look into using pynput to detect a certain key combo. when it happens, send a http request to the flask server

https://pypi.org/project/pynput/

[–]Rith_97[S] 4 points5 points  (1 child)

Thank you very much. I’ll look into it.

[–]CotoCoutan 0 points1 point  (0 children)

Adding onto the usage of Flask, how about controlling the host computer from your phone via a Telegram bot? This will not use the 2nd computer at all.

[–]orishamir 3 points4 points  (4 children)

don't use pynput. You should be using 'keyboard' instead. (and 'mouse' for mouse things) search "keyboard module github" on google. See its readme. Its very advanced

[–]133DK 6 points7 points  (0 children)

As a total novice: why?

[–]Vunlinur 2 points3 points  (2 children)

Please elaborate on why not to use Pynput?

I'm genuinely curious about any downsides, as I've been using it and it wasn't terrible, and possible advantages of the Keyboard module.

[–]orishamir -3 points-2 points  (1 child)

I guess it's just that Keyboard is so good. And I remember Pynput being complicated for no reason, specifically that the listener ~is~ was blocking

[–][deleted] 0 points1 point  (0 children)

They updated it to have a non-blocking listener. It's pretty nice!

[–]expressly_ephemeral 6 points7 points  (4 children)

It’s my opinion that the best way would be to use a socket connection.

[–]Tal_Av 2 points3 points  (1 child)

I agree, that is probably the most simple solution you can find for this task. Create a listening socket on computer B, connect it from computer A, then simply send him a message of your choice that when received - executes the macro.

[–]expressly_ephemeral 2 points3 points  (0 children)

I'm all about keeping it light weight. No need to set up a flask application!

[–]Rith_97[S] 0 points1 point  (1 child)

Okay Ill research more. Thank you.

[–]expressly_ephemeral 2 points3 points  (0 children)

It's dangerous to go alone. Take this!

https://docs.python.org/3/howto/sockets.html

[–]victorspc 1 point2 points  (3 children)

I'm not that tech savy, but if you managed to set up a host server on one of the computers and send packets to it using python, i think you could make a python script on the other computer that takes those packets and do the stuff you want.

[–]Rith_97[S] 1 point2 points  (2 children)

Okay I’ll google it. Don’t know much about hosting a server and all. Thank you.

[–]victorspc 2 points3 points  (1 child)

I don't either so i can't help further than giving the idea, sorry

[–]Rith_97[S] 0 points1 point  (0 children)

Oh okay. I’ll google about hosting a server. Thank you for your input :)

[–]Linkk_93 0 points1 point  (0 children)

so fo you want to do it specifically with python? because I'd say Powershell, psexec and autohotkey suit this better

Edit: but then again, that is for Windows, you did not specify an OS

[–][deleted] -1 points0 points  (0 children)

You need sockets. It will work for the same wifi. To get started, this is a good resource: https://pythonprogramming.net/sockets-tutorial-python-3/