Closed AWPelican closed 7 years ago
same here, when i tried to use "Ctrl + a" as pyautogui.hotkey('ctrl', 'a')
nothing happened, is there any particular way of using it?
Both Ctrl+C and Ctrl+A work out of the box for me on Windows 7 with Python 3.5.
Does it make a difference if your script is running as administrator?
I can confirm that pyautogui.hotkey('ctrl', 'c')
works for me on Windows 7 64-bit with Python 3.4.4, 3.5.2, and 3.6.0.
This person seems to have this same problem on Python 3, Windows 7 64 bit: https://stackoverflow.com/questions/41683334/doesnt-works-ctrlv-in-pyautogui-python-3-on-windows
I'm going to close this issue and combine it with https://github.com/asweigart/pyautogui/issues/93
I had the same problem trying to use both hotkey() and the separated keyDown(), press() and keUp() methods. I discovered that the methods did not work in Idle3 (running on MacOS Sierra 10.12.4) but they did work when executed via the terminal in a .py file.
So the problem might be with idle, strangely it's not even possible to type a backslash \ in idle (with alt, shift, 7), at least not on my german keyboard...
I had this issue as well. Solved by using the python 64bit libraries (Python35-64 vs Python35-32). Check your system environment variables.
Using the 64 bit installation of Python actually does work for me as well. Thanks for pointing this out.
None of the hotkeys work in Spyder 3.2.6, Python 3.6.4 64bits on windows 10: import pyautogui as pat import pyperclip import webbrowser
webbrowser.open('https://www.digitalocean.com/community/tutorials/how-to-scrape-web-pages-with-beautiful-soup-and-python-3')
pos=(50,1000) pat.moveTo(pos) pat.hotkey('ctrl','u') pat.hotkey('ctrl','a') pat.hotkey('ctrl','c') print(pos)
Sorry for digging up an old thread but it appeared to most relevant place to post.
Windows 10 (64bit) Python 3.6.3 (Anaconda) (I appreciate that this is beyond the versions listed as tested)
There appears to be a bug where by hotkeys involving the clipboard do not work (ie. Ctrl-C and Ctrl-V). In addition, and more worryingly, if a script using pyautogui is running, the clipboard becomes non-functional in its entirety. I cant copy and paste in other applications whilst the script is running.
To add, other hotkeys work fine. Ctrl-A, Ctrl-R work as expected in each case ive tested. It appears to be an issue with the clipboard not hotkeys in general.
I had the same issue but I've got around it using: pyautogui.keyDown('ctrl') pyautogui.press('c') pyautogui.keyUp('ctrl')
"Ctrl-C" hotkey combination will work when you run your script from Command Prompt
I found the solution!
pyautogui.keyDown('ctrl') pyautogui.keyDown('c') pyautogui.keyUp('c') pyautogui.keyUp('ctrl')
In my script I had to use root.update() after.
I found the solution!
pyautogui.keyDown('ctrl') pyautogui.keyDown('c') pyautogui.keyUp('c') pyautogui.keyUp('ctrl')
In my script I had to use root.update() after.
Does not feel any of them works for my Ubuntu 22: #93
pyautogui.keyDown('alt')
time.sleep(0.2)
pyautogui.keyDown('tab')
time.sleep(0.2)
pyautogui.keyUp('tab')
time.sleep(0.2)
pyautogui.keyUp('alt')
or
time.sleep(2)
pyautogui.hotkey('alt','tab',interval = 0.1)
Putting this here because it might help someone out; I was trying to figure out why pyautogui.hotkey('ctrl', 'c', interval=0.2) wasn't working with win32clipboard and I figured out that if I already had the clipboard open (i.e. win32clipboard.OpenClipboard()), the data wouldn't get copied to the clipboard. My solution was to close the clipboard, copy the data using pyautogui, then reopen it and extract the copied data, something like:
pyautogui.hotkey('ctrl', 'c', interval=0.2)
time.sleep(0.1)
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
Putting this here because it might help someone out; I was trying to figure out why pyautogui.hotkey('ctrl', 'c', interval=0.2) wasn't working with win32clipboard and I figured out that if I already had the clipboard open (i.e. win32clipboard.OpenClipboard()), the data wouldn't get copied to the clipboard. My solution was to close the clipboard, copy the data using pyautogui, then reopen it and extract the copied data, something like:
pyautogui.hotkey('ctrl', 'c', interval=0.2) time.sleep(0.1) win32clipboard.OpenClipboard() data = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard()
This solution worked. Note, to get win32clipboard you need to install pywin32. But you still import it as win32clipboard
EDIT: It's now back to exactly the same issue. Windows clipboard is fundamentally broken.
I've been searching for a solution to this for several days, but am beginning to wonder if I'm just looking at a bug.
I have a script that needs to copy to the clipboard using Ctrl + C, but somehow sending this key combination has lost functionality in pyautogui.
There is no exception thrown, and it appears everything is executing as it should be. However, the desired text is not copied to the clipboard. Copying the text manually using Ctrl + C (on my actual keyboard) does cause the desired text to be copied. However, when running pyautogui the clipboard remains unchanged.
I found this question on Stack Overflow that verifies the issue: http://stackoverflow.com/questions/38899566/python-pyautogui-and-ctrl-c?newreg=4a6bdd511c314b129438d6d79f427600
I am also running Windows 7 and Python 3.5, as is Todd Lewden, the author of the Stack Overflow question.
The "Cheat Sheet" on Read the Docs indicates that this functionality should be present in pyautogui:
I'm not sure at what point sending the "Ctrl + C" combination became broken, but it looks like it worked at some point, according to the above reference to the documentation.
I had a thought that perhaps it has to do with "Ctrl + C" being a Python keyboard interrupt, but I don't know that that is the case. If it were, Python should come to a screeching halt when the Ctrl + C is sent. It appears to execute without error, except that it doesn't work.