When pyautogui.prompt()
is called it displays a message box and it's always in the same spot. That box covers pictures I need to see, so I can write the right number. I need to move the box or make it invisible or minimize it or make it out of focus.
The problem is that you can't execute code while or after the message box is showing. The pyautogui.prompt is coded like this: pyautogui.prompt(text='', title='', default='', root=None, timeout=None)
. I know what each argument does, except root. The root argument doesn't accept boolean, integers, lists, strings, Point or tuple. It displays an error message: AttributeError: 'tuple' object has no attribute 'withdraw'
, if you put boolean, integers, lists, strings, Point or tuple in.
The only thing that root accepts is pyautogui.moveTo
, pyautogui.dragTo
and other mouse commands. Which are not that useful, because they execute before the box appears. Here is my code:
import pyautogui
selected_picture = int(pyautogui.prompt('Please write which picture to click on.',
'Select picture'))
if selected_picture == 1:
pyautogui.click(500,270)
if selected_picture == 2:
pyautogui.click(700,270)
if selected_picture == 3:
pyautogui.click(900,270)
Yes, I need to do it with pyautogui.prompt
or some other message box. The original documentation doesn't even mention the root or timeout attribute and I can't find that information anywhere. I was trying something with tkinter, but I have no idea what it does.
I couldn't find a way to move the prompt, so I did something easier. I just used IDLE.
import pyautogui
pyautogui.hotkey('alt','shift')
selected_picture = input()
pyautogui.hotkey('alt','shift')
if selected_picture == 1:
pyautogui.click(500,270)
if selected_picture == 2:
pyautogui.click(700,270)
if selected_picture == 3:
pyautogui.click(900,270)