diff --git a/key.py b/key.py index b9967f8..b6b1674 100644 --- a/key.py +++ b/key.py @@ -370,6 +370,7 @@ key[PERIOD] = 0x37 key[FORWARD_SLASH] = 0x38 + key[CAPS_LOCK] = 0x39 key[F1] = 0x3A @@ -496,7 +497,7 @@ key[LEFT_SHIFT] = 0xE1 key[SHIFT] = key[LEFT_SHIFT] -key[LEFT_ALT] = 0xE2 +key[LEFT_ALT] = 0x04 key[ALT] = key[LEFT_ALT] @@ -516,4 +517,183 @@ key[RIGHT_SHIFT] = 0xE5 key[RIGHT_ALT] = 0xE6 -key[RIGHT_GUI] = 0xE7 \ No newline at end of file +key[RIGHT_GUI] = 0xE7 + +key['A'] = 0x04 + +key['B'] = 0x05 + +key['C'] = 0x06 + +key['D'] = 0x07 + +key['E'] = 0x08 + +key['F'] = 0x09 + +key['G'] = 0x0A + +key['H'] = 0x0B + +key['I'] = 0x0C + +key['J'] = 0x0D + +key['K'] = 0x0E + +key['L'] = 0x0F + +key['M'] = 0x10 + +key['N'] = 0x11 + +key['O'] = 0x12 + +key['P'] = 0x13 + +key['Q'] = 0x14 + +key['R'] = 0x15 + +key['S'] = 0x16 + +key['T'] = 0x17 + +key['U'] = 0x18 + +key['V'] = 0x19 + +key['W'] = 0x1A + +key['X'] = 0x1B + +key['Y'] = 0x1C + +key['Z'] = 0x1D + +key['ONE'] = 0x1E + +key['TWO'] = 0x1F + +key['THREE'] = 0x20 + +key['FOUR'] = 0x21 + +key['FIVE'] = 0x22 + +key['SIX'] = 0x23 + +key['SEVEN'] = 0x24 + +key['EIGHT'] = 0x25 + +key['NINE'] = 0x26 + +key['ZERO'] = 0x27 + +key['ENTER'] = 0x28 + +key['RETURN'] = ENTER + +key['ESCAPE'] = 0x29 + +key['BACKSPACE'] = 0x2A + +key['TAB'] = 0x2B + +key['SPACEBAR'] = 0x2C + +key['SPACE'] = key['SPACEBAR'] + +key['MINUS'] = 0x2D + +key['EQUALS'] = 0x2E + +key['LEFT_BRACKET'] = 0x2F + +key['RIGHT_BRACKET'] = 0x30 + +key['BACKSLASH'] = 0x31 + +key['POUND'] = 0x32 + +key['SEMICOLON'] = 0x33 + +key['QUOTE'] = 0x34 + +key['GRAVE_ACCENT'] = 0x35 + +key['COMMA'] = 0x36 + +key['PERIOD'] = 0x37 + +key['FORWARD_SLASH'] = 0x38 + + +key['CAPS_LOCK'] = 0x39 + +key['F1'] = 0x3A + +key['F2'] = 0x3B + +key['F3'] = 0x3C + +key['F4'] = 0x3D + +key['F5'] = 0x3E + +key['F6'] = 0x3F + +key['F7'] = 0x40 + +key['F8'] = 0x41 + +key['F9'] = 0x42 + +key['F10'] = 0x43 + +key['F11'] = 0x44 + +key['F12'] = 0x45 + +key['PRINT_SCREEN'] = 0x46 + +key['SCROLL_LOCK'] = 0x47 + +key['PAUSE'] = 0x48 + +key['INSERT'] = 0x49 + +key['HOME'] = 0x4A + +key['PAGE_UP'] = 0x4B + +key['DELETE'] = 0x4C + +key['END'] = 0x4D + +key['PAGE_DOWN'] = 0x4E + +key['RIGHT_ARROW'] = 0x4F + +key['LEFT_ARROW'] = 0x50 + +key['DOWN_ARROW'] = 0x51 + +key['UP_ARROW'] = 0x52 + +key['KEYPAD_NUMLOCK'] = 0x53 + +key['KEYPAD_FORWARD_SLASH'] = 0x54 + +key['KEYPAD_ASTERISK'] = 0x55 + +key['KEYPAD_MINUS'] = 0x56 + +key['KEYPAD_PLUS'] = 0x57 + +key['KEYPAD_ENTER'] = 0x58 + +key['KEYPAD_ONE'] = 0x59 + +key['KEYPAD_TWO'] = 0x5A \ No newline at end of file diff --git a/keyserver.py b/keyserver.py index 82f6ec0..d03cf93 100644 --- a/keyserver.py +++ b/keyserver.py @@ -16,56 +16,55 @@ def press_key(keytype): def send_string(neededstring): stringlist = [*neededstring.upper()] for l in stringlist: - if l == "" or l == " ": - l = "SPACEBAR" + if l == '' or l == ' ': + l = 'SPACEBAR' press_key(l) @route('/marco/',method = 'POST') def process(path): - 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) + if path == 'linuxtowindows': + print('swtiching pc to windows') + write_report(chr(0x04)*2+chr(key['SPACE'])+NULL_CHAR*5) sleep(0.1) write_report(NULL_CHAR*8) # execute the shutdown reboot command for linux - send_string("reboot") - press_key("ENTER") + send_string('reboot') + press_key('ENTER') for x in range(10): - press_key("F9") + 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) + 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) + 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*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*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*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*2+chr(key['N'])+NULL_CHAR*5) write_report(NULL_CHAR*8) - press_key("ENTER") + press_key('ENTER') sleep(2) for x in range(10): - press_key("F9") + press_key('F9') sleep(0.3) - for x in range("2"): - press_key("DOWN_ARROW") - press_key("ENTER") - print("booting...") + for x in range('2'): + press_key('DOWN_ARROW') + press_key('ENTER') + print('booting...') @route('/presskey/',method = 'POST') def process(path): @@ -75,7 +74,7 @@ def process(path): @route('/presswithoutrelease/',method = 'POST') def process(path): - if path == "release": + if path == 'release': write_report(NULL_CHAR*8) else: newpath = eval(path)