0

我希望在您按下时单击暂停,xbutton1并在按下时继续单击xbutton2

这是我的代码:

import win32api
import win32con
import pyautogui

click = True


def clicking():
    get = win32api.GetKeyState(win32con.VK_LBUTTON)
    if get < 1:
        pyautogui.click()


def stop():
    if win32api.GetKeyState(win32con.VK_XBUTTON1):
        click = False


def continue_program():
    if win32api.GetKeyState(win32con.VK_XBUTTON2):
        click = True


while True:
    if click == True:
        clicking()

    else:
        stop()
4

1 回答 1

-1
import win32api
import win32con
import pyautogui

click = True


def clicking():
    get = win32api.GetKeyState(win32con.VK_LBUTTON)
    if get < 1:
        pyautogui.click()


def check():
    if win32api.GetKeyState(win32con.VK_XBUTTON1):
        click = False
    if win32api.GetKeyState(win32con.VK_XBUTTON2):
        click = True
    # Actually, here still has some contitions to check.
    return click


while True:
    if not check():
        continue
    # The things you want the loop to do. 
    clicking()
于 2021-02-24T02:49:36.970 回答