简体   繁体   English

Pyautogui cursor 在选择文本框并单击其他 object 后无法正常工作

[英]Pyautogui cursor not working after seclect a text box and click at other object

I'm currently having trouble with pyautogui's cursor我目前在使用 pyautogui 的 cursor 时遇到了问题

When I execute the code, it click the text box and write text there.当我执行代码时,它单击文本框并在那里写入文本。 But after its done writitng and move to another object I aslo want it to click but the cursor didn't change, make the cursor stay text cursor and it cannot click anything after that despite the cursor moved to the object that I need to click.但是在它完成写入并移动到另一个 object 之后我也希望它点击但是 cursor 没有改变,使 cursor 保持文本 cursor 之后它不能点击任何东西尽管 cursor 移动到 8808228985 需要点击Pydirectinput didn't work aslo, can anybody help me? Pydirectinput 没有工作,有人可以帮助我吗? Thank you谢谢

code here:代码在这里:

import random as r
import pyautogui as pg
import pydirectinput as pg2
import time as t
pg.FAILSAFE = False
letter="1234567890QWERTYUIOPASDFGHJKLZXCVBNM"
generated=None
def gen():
    code=''.join(r.sample(letter,12))
    print("Generated code: ",code)
    return code
def redeem():
    pass
def check():
    pass
def mine():
    empty = pg.locateCenterOnScreen('empty.png', confidence=.9)
    redeem = pg.locateCenterOnScreen('redeem.png',confidence=.9)
    codeis = None
    ok = None
    x=None
    print(empty)
    if empty != None:
        print(empty)
        pg.moveTo(empty)
        t.sleep(0.001)
        pg2.click()
        t.sleep(0.001)
        x=gen()
        t.sleep(0.1)
        pg.write(x)
        t.sleep(.1)
        pg2.press('esc')
        if redeem != None:
            print(redeem)
            t.sleep(0.1)
            pg.moveTo(redeem)
            t.sleep(.1)
            pg2.click()
            t.sleep(0.1)
        
    else:
        pass
#main
if __name__ == '__main__':
    while True:
        mine()

光标在这里,它保持这样,不能点击那个“兑换”按钮

If you are trying to click on Roblox, there are issues with Pyautogui clicking the mouse in Roblox but i've found a workaround for that:如果您尝试单击 Roblox,Pyautogui 在 Roblox 中单击鼠标会出现问题,但我找到了解决方法:

import autoit
    if empty != None:
    print(empty)
    pg.moveTo(empty)
    t.sleep(0.001)
    autoit.mouse_click("left") #Instead of using pyautogui to click, we are gonna use autoit
    t.sleep(0.001)
    x=gen()
    t.sleep(0.1)
    pg.write(x)
    t.sleep(.1)
    pg2.press('esc')
    if redeem != None:
        print(redeem)
        t.sleep(0.1)
        pg.moveTo(redeem)
        t.sleep(.1)
        autoit.mouse_click("left") #Instead of using pyautogui to click, we are gonna use autoit
        t.sleep(0.1)
    
else:
    pass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM