A thing only I need
This commit is contained in:
parent
24ee2b3c12
commit
503f52bb2f
1 changed files with 55 additions and 4 deletions
59
keyserver.py
59
keyserver.py
|
@ -8,13 +8,64 @@ def write_report(report):
|
|||
with open('/dev/hidg0', 'rb+') as fd:
|
||||
fd.write(report.encode())
|
||||
|
||||
def press_key(keytype):
|
||||
write_report(NULL_CHAR*2+chr(key[keytype])+NULL_CHAR*5)
|
||||
sleep(0.1)
|
||||
write_report(NULL_CHAR*8)
|
||||
|
||||
def send_string(neededstring):
|
||||
stringlist = [*neededstring.upper()]
|
||||
for l in stringlist:
|
||||
if l == "" or l == " ":
|
||||
l = "SPACEBAR"
|
||||
press_key(l)
|
||||
|
||||
|
||||
@route('/marco/<path>',method = 'POST')
|
||||
def process(path):
|
||||
if path == "wake":
|
||||
print("waking pc")
|
||||
write_report(NULL_CHAR*2+chr(44)+NULL_CHAR*5)
|
||||
sleep(0.2)
|
||||
if path == "linuxtowindows":
|
||||
print("swtiching pc to windows")
|
||||
write_report(NULL_CHAR*2+chr(key["LEFT_ALT"])+NULL_CHAR*5)
|
||||
write_report(NULL_CHAR*2+chr(key["SPACEBAR"])+NULL_CHAR*5)
|
||||
sleep(0.1)
|
||||
write_report(NULL_CHAR*8)
|
||||
# execute the shutdown reboot command for linux
|
||||
send_string("reboot")
|
||||
press_key("ENTER")
|
||||
for x in range(10):
|
||||
press_key("F9")
|
||||
sleep(0.3)
|
||||
for x in range("3"):
|
||||
press_key("DOWN_ARROW")
|
||||
press_key("ENTER")
|
||||
print("booting...")
|
||||
elif path == "windowstolinux":
|
||||
print("swtiching pc to linux")
|
||||
write_report(NULL_CHAR*2+chr(key["APPLICATION"])+NULL_CHAR*5)
|
||||
write_report(NULL_CHAR*2+chr(key["R"])+NULL_CHAR*5)
|
||||
sleep(0.1)
|
||||
write_report(NULL_CHAR*8)
|
||||
# execute the shutdown reboot command for windows
|
||||
send_string("shutdown")
|
||||
write_report(NULL_CHAR*2+chr(key["FORWARD_SLASH"])+NULL_CHAR*5)
|
||||
write_report(NULL_CHAR*8)
|
||||
write_report(NULL_CHAR*2+chr(key["R"])+NULL_CHAR*5)
|
||||
write_report(NULL_CHAR*8)
|
||||
write_report(NULL_CHAR*2+chr(key["SPACEBAR"])+NULL_CHAR*5)
|
||||
write_report(NULL_CHAR*8)
|
||||
write_report(NULL_CHAR*2+chr(key["FORWARD_SLASH"])+NULL_CHAR*5)
|
||||
write_report(NULL_CHAR*8)
|
||||
write_report(NULL_CHAR*2+chr(key["N"])+NULL_CHAR*5)
|
||||
write_report(NULL_CHAR*8)
|
||||
press_key("ENTER")
|
||||
sleep(2)
|
||||
for x in range(10):
|
||||
press_key("F9")
|
||||
sleep(0.3)
|
||||
for x in range("2"):
|
||||
press_key("DOWN_ARROW")
|
||||
press_key("ENTER")
|
||||
print("booting...")
|
||||
|
||||
@route('/presskey/<path>',method = 'POST')
|
||||
def process(path):
|
||||
|
|
Loading…
Reference in a new issue