Last active
April 20, 2017 18:44
-
-
Save Keridos/28fb408df82cae3b6b259e05f666b314 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
import keyboard | |
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
down = False | |
def onKeyboardDownEvent(): | |
global down | |
if not down: | |
message = "down".encode("ascii") | |
s.sendto(message, remote) | |
down = True | |
def onKeyboardUpEvent(): | |
global down | |
if down: | |
message = "up".encode("ascii") | |
s.sendto(message, remote) | |
down = False | |
remote = (socket.gethostbyname("keridos"), 12455) | |
keyboard.hook_key('f13', onKeyboardDownEvent, onKeyboardUpEvent) | |
try: | |
while True: | |
sleep(1) | |
finally: | |
print("error or quit") | |
keyboard.unhook_all() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyautogui | |
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
host = socket.gethostname() | |
port = 12455 | |
s.bind((host, port)) | |
try: | |
while True: | |
msg, addr = s.recvfrom(1024) | |
if msg.decode("ascii") == "down": | |
pyautogui.keyDown('scrolllock') | |
print("down") | |
elif msg.decode("ascii") == "up": | |
pyautogui.keyUp('scrolllock') | |
print("up") | |
finally: | |
s.shutdown(2) | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment