Closed Gnahsyu closed 6 months ago
Reduce screen resolution to 2k
I wrote a python script with similar functions, but I encountered a problem, that is, the influence of the tablet cannot be ignored when running this script.
from pynput import keyboard import pyautogui import math import time
origin = None
def on_press(key): global origin
# 判断按下的键是否为目标按键(目标键为'space'键)
if key == keyboard.Key.space:
# 记录鼠标指针当前位置作为原点坐标
origin = pyautogui.position()
def on_release(key): global origin
# 判断释放的键是否为目标按键
if key == keyboard.Key.space and origin is not None:
# 获取当前鼠标指针位置
current_pos = pyautogui.position()
original_position = pyautogui.position()
time.sleep(0.5)
# 计算向量差
dx = current_pos[0] - origin[0]
dy = current_pos[1] - origin[1]
# 计算向量的角度,并取相反数
angle = -1 * math.degrees(math.atan2(dy, dx))
# 获取相反数的整数位
integer_part = int(angle)
print(str(integer_part)) #目前还没找到禁用数位板的办法
pyautogui.PAUSE = 0.001
pyautogui.click(1609, 77)
pyautogui.hotkey('ctrl', 'a')
pyautogui.typewrite(str(integer_part), interval=0.01)
pyautogui.press('enter')
pyautogui.moveTo(original_position, duration=0.01)
origin = None
listener = keyboard.Listener(on_press=on_press, on_release=on_release)
listener.start()
listener.join()
I am using a 4K monitor, and if the interface is too small for 100% zoom, how can I solve it