I am seeing a conflict between pyautogui and tkinter. When I run a program without tkinter, pyautogui can control the keyboard & mouse as expected. However, if I first get input (e.g. a user-selected directory) through tkinter, I get this error:
File "C:\Users\Test_Lab\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyautogui\__init__.py", line 362, in click
platformModule._click(x, y, 'left')
File "C:\Users\Test_Lab\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyautogui\_pyautogui_win.py", line 437, in _click
_sendMouseEvent(MOUSEEVENTF_LEFTCLICK, x, y)
File "C:\Users\Test_Lab\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyautogui\_pyautogui_win.py", line 480, in _sendMouseEvent
raise ctypes.WinError()
FileNotFoundError: [WinError 2] The system cannot find the file specified.
I can verify that tkinter gets a valid directory by printing it out first. Versions: Python= 3.5.1, tkinter.TkVersion
=8.6, pyautogui.__version__
='0.9.33', running on Windows 7 Pro.
Here is a minimal example that reproduces my issue:
import pyautogui
import tkinter
root=tkinter.Tk()
dirname = tkinter.filedialog.askdirectory(parent=root, initialdir="C:\\",
title='Please select a directory')
dname=dirname.replace('/',os.sep)
print(dname)
root.quit()
root.destroy()
pyautogui.moveTo(35, 5)
pyautogui.click(pause=.1)