Skip to content

click theRunIsStuck #613

@chenyuxingkong

Description

@chenyuxingkong
from pynput import mouse
from pynput.mouse import Button

isRun = False
ctr = pynput.mouse.Controller()


def g36k():
    global isRun
    isRun = True
    print("start")
    # 运行卡死
    # theRunIsStuck
    ctr.click(Button.left)
    print("end")


def on_click(x, y, button, pressed):
    print(f'鼠标按下: {button} at ({x}, {y})')
    global isRun
    # 鼠标松开时触发
    if not pressed:
        if button == Button.x1 and not isRun:
            # 将 g36k 的调用调度到事件循环
            g36k()
            isRun = False


if __name__ == '__main__':
    # 创建鼠标监听器
    listener = mouse.Listener(on_click=on_click)
    listener.start()
    listener.join()

The above is my py code. When I run to ctr.click(Button.left), I can't output print("end "), and my mouse is stuck.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions