imahitman
imahitman

Reputation: 71

Clicking on-screen keyboard with pyautogui

I am developing a bot to click the on-screen keyboard with pyautogui

The following is the code I am currently using to click 'a' on the keyboard.

import pyautogui

osk_filepath = os.path.abspath("assets")

osk_icon = pyautogui.locateCenterOnScreen(os.path.join(osk_filepath, "OSK_ICON.png"))

if not osk_icon:
    sys.exit("Unable to detect On-Screen Keyboard")

OSK_LOCATION = (osk_icon[0] - 25, osk_icon[1], 1000, 500)

a = pyautogui.locateCenterOnScreen(os.path.join(osk_filepath, "a.png"), region=OSK_LOCATION, grayscale=True)

pyautogui.click(a)

It moves the mouse to the position of the 'a' key but does not press down for it to output an 'a'.

Upvotes: 1

Views: 1086

Answers (1)

imahitman
imahitman

Reputation: 71

This issue can be solved by running the IDE as admin.

Upvotes: 5

Related Questions