如何在Windows上覆盖鼠标按下?

2021-11-29 23:37:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python编程一个自动点击器,当我启动它的时候,有一个程序,它会阻止我在python自动点击器程序中执行的所有点击。 我不知道如何绕过它,我需要做什么?你知道吗

自动点击器工作正常100%好,我在点击速度测试中测试过,但当我启动另一个程序时,它会取消自动点击器程序的点击,但其他一切都正常,打印方法,更改变量都很好,只是禁用了点击

这段代码在python上(有点乱——这是我朋友的代码)

import win32api, win32con
import time
import random
from pynput.mouse import Button, Controller
from pynput.keyboard import Listener, KeyCode
print("Welcome To The Best Undtected AutoClicker To Activate Preess Z And To Activate Press Mouse 3 For Toggle And Mouse 4 For While Clicked")
state_left = win32api.GetKeyState(0x06)  # Left button down = 0 or 1. Button up = -127 or -128
state_right = win32api.GetKeyState(0x5A)  # Right button down = 0 or 1. Button up = -127 or -128
clicked = False
zclicked = False
button = Button.left
mouse = Controller()
clicked1 = False


def click():
    i = random.randint(2, 15)
    i = i / 100
    mouse.click(button)
    time.sleep(i)


while True:
    a = win32api.GetKeyState(0x06)
    b = win32api.GetKeyState(0x5A)
    if a != state_left:  # Button state changed
        state_left = a
        if a < 0:
            clicked = True
        else:
            clicked = False

    if b != state_right:  # Button state changed
        state_right = b
        if b < 0:
            if (zclicked == True):
                zclicked = False
                print("Z Button Is Off")
            elif (zclicked == False):
                zclicked = True
                print("Z Button Is On")
    if (clicked == True and zclicked == True and clicked1==False):
        click()
    if zclicked == True and win32api.GetKeyState(0x05) == 1:
        clicked1 = True
    elif (win32api.GetKeyState(0x5) == -0 and zclicked == True and clicked==False):
        clicked1 = False
    if (clicked1 == True):
        click()

    time.sleep(0.001)

另一个程序禁用了click()方法中的代码mouse.click(button),我需要以某种方式绕过它。你知道吗