millionart / PhotoshopBrushRotateTool

This is only used for Photoshop brush-rotate tool user feedback. Software purchase address:
https://gum.co/brotate
0 stars 0 forks source link

System zoom level must be 100%. #11

Closed Gnahsyu closed 6 months ago

Gnahsyu commented 1 year ago

I am using a 4K monitor, and if the interface is too small for 100% zoom, how can I solve it

millionart commented 1 year ago

Reduce screen resolution to 2k

Gnahsyu commented 1 year ago

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.

Gnahsyu commented 1 year ago

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()