StopIteration during keyboard.write
See original GitHub issueOn Fedora 28 with Python 3.6.6 I get the following problem:
>>> text = "TESTAA"
>>> keyboard.write(text)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/some/path/venv/lib/python3.6/site-packages/keyboard/__init__.py", line 852, in write
scan_code, modifiers = next(iter(entries))
StopIteration
>>> TEST
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:15
Top Results From Across the Web
StopIteration error in python - Stack Overflow
StopIteration is raised when generator is exhausted and has no more values, it's totaly ok to get one. But you need to handle...
Read more >Developers - StopIteration during keyboard.write - - Bountysource
On Fedora 28 with Python 3.6.6 I get the following problem: >>> text = "TESTAA" >>> keyboard.write(text) Traceback (most recent call last): File...
Read more >Issue 31156: Stopiteration terminates while-loop - Python tracker
msg299982 ‑ (view) Author: Günter Rote (Günter Rote) Date: 2017‑08‑09 09:49
msg300005 ‑ (view) Author: R. David Murray (r.david.murray) * Date: 2017‑08‑09 13:37
msg300011 ‑...
Read more >Behaviors — Kivy 2.2.0.dev0 documentation
(internal) Used by the controller to get the node at the position indicated by key. The key can be keyboard inputs, e.g. pageup,...
Read more >Complete Guide to Python KeyboardInterrupt - eduCBA
There is no such specific syntax of KeyboardInterrupt exception in Python, it is handled in the normal try and except block inside the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi! I have exactly the same problem on Ubuntu 18.04, however I can use keyboard from pynput module for the same purposes, here is an example:
from pynput.keyboard import Controller
keyboard=Controller()
keyboard.type('TESTAA')
For doing so you need to download the pynput module, which can be downloaded from the terminal via pip with:pip install pynput
There is also a complete tutorial about simulating keypresses with pynput: https://nitratine.net/simulate-keypresses-in-python/Same issue on Centos 7 machine… script is simple
import keyboard keyboard.write(“Python Programming is kinda cool I should say!”, delay=0.3) keyboard.send(‘windows+l’)
Steps to repro:
$ sudo python3 test_keyboard.py Traceback (most recent call last): File “test_keyboard.py”, line 3, in <module> keyboard.write(“Python Programming is kinda cool I should say!”, delay=0.3) File “/usr/local/lib/python3.6/site-packages/keyboard/init.py”, line 854, in write scan_code, modifiers = next(iter(entries)) StopIteration
I’ve done research in SO but nothing… this appears the only place and the issue is Open.
If someone knows an alternative to the “keyboard” module that would be fantastic!
I am aware that something like this could be used(windows example):
import os os.system(‘rundll32.exe user32.dll,LockWorkStation’)
However something more high level that can work on most machines would be best.