-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreaction_test.py
More file actions
37 lines (32 loc) · 1.33 KB
/
reaction_test.py
File metadata and controls
37 lines (32 loc) · 1.33 KB
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
from PIL import ImageGrab
from pynput.mouse import Button, Controller
from ctypes import windll
import time
mouse = Controller()
dc= windll.user32.GetDC(0)
gdi = windll.gdi32
print("Press Ctrl + C to terminate the program.")
screensize = windll.user32.GetSystemMetrics(
0), windll.user32.GetSystemMetrics(1)
# avoids importing sys
supportedScreenRes = False
print(windll.gdi32.GetPixel(windll.user32.GetDC(0), 950, 460))
if (screensize[0] == 1920 and screensize[1] == 1080):
mouse.position = (950, 460)
supportedScreenRes = True
elif (screensize[0] == 2560 and screensize[1] == 1440):
mouse.position = (950, 460)
supportedScreenRes = True
else:
print("Sorry, your resolution isn't supported.")
# click to start the test
mouse.click(Button.left, 1)
if (supportedScreenRes):
# we do not specifiy a break condition to maximize performance, program has to be quit with Ctrl + C
while True:
# different monitors have slightly different values for this green, 7002955 was the green value on my Laptop monitor
# From what I have found out windll is the fastest way to check a single pixel value (< 10ms)
if (abs(gdi.GetPixel(dc, 950, 460) - 7002955) <= 500000):
mouse.click(Button.left, 1)
time.sleep(0.1)
#mouse.click(Button.left, 1)