#https://humanbenchmark.com/tests/aim
import pyautogui
from PIL import ImageGrab
import time
import keyboard
# 定义目标颜色
target_color = (149, 195, 232)
def find_color_position(target_color, step=10):
# 截取屏幕
screen = ImageGrab.grab()
# 获取屏幕尺寸
width, height = screen.size
# 遍历屏幕上的每个像素,步长为step
for x in range(0, width, step):
for y in range(0, height, step):
# 获取当前像素颜色
if screen.getpixel((x, y)) == target_color:
return x, y
return None
def move_and_click_on_color(target_color):
pos = find_color_position(target_color)
if pos:
print(f"找到目标颜色在位置: {pos}")
# 移动鼠标到目标颜色位置
pyautogui.moveTo(pos)
# 点击鼠标左键
pyautogui.click()
else:
print("未找到目标颜色")
if __name__ == "__main__":
print("开始检测,按 'g' 键结束检测")
try:
while True:
# 检查是否按下了 'g' 键
if keyboard.is_pressed('g'):
print("检测结束")
break
# 移动鼠标并点击目标颜色
start_time = time.time()
move_and_click_on_color(target_color)
elapsed_time = time.time() - start_time
print(f"检测耗时: {elapsed_time * 1000:.2f}ms")
# 减少延迟
#time.sleep(0.05) # 每 0.05 秒检测一次
except KeyboardInterrupt:
print("检测中断")