-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXPlane_delay_using_keystrokes.py
48 lines (41 loc) · 1.1 KB
/
XPlane_delay_using_keystrokes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pyautogui
import socket
import time
import subprocess
def keypress_shift_v():
subprocess.call(['wmctrl', '-a', 'X-System'])
time.sleep(1)
pyautogui.keyDown('shift')
pyautogui.press('v')
pyautogui.keyUp('shift')
def keypress_shift_b():
subprocess.call(['wmctrl', '-a', 'X-System'])
time.sleep(1)
pyautogui.keyDown('shift')
pyautogui.press('b')
pyautogui.keyUp('shift')
def delay_for_me(duration):
if duration != 10000:
if duration == 1:
keypress_shift_v()
else:
time.sleep(duration-1)
keypress_shift_b()
else:
keypress_shift_b()
if __name__ == "__main__":
#ToDo: Change from pyautogui to xdotool to allow multitasking
pyautogui.FAILSAFE = False
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('localhost', 50000))
s.listen(5)
while 1:
conn, addr = s.accept()
data = conn.recv(1024)
if not data:
pass
else:
delay_time = int(data)
delay_for_me(delay_time)
# conn.send("ack")
conn.close()