Python3 - Globally capture key presses while stopping other programs receiving them
I want some Python3 that captures real key presses globally (regardless of focus on a window) but stops the focused window getting the real key presses. An end goal example: A user types "apple" while focused on a text editor window, the script is logging all key presses and detects the user has typed one of its trigger words "apple", so it then sends virtual keys typing "orange". The text editor now reads only "orange"; it never received the real key presses ("apple"), only those sent by the script ("orange"). I need it to not just delete the actually typed characters afterwards.
I have been using the "keyboard" module. I have it detecting real key presses and sending virtual key presses when it detects certain strings of real key presses, but currently everything receives the real and virtual key presses. I only want them receiving the virtual ones. (Using the terms from the example: The text editor reads "appleorange" not just "orange".)
See also questions close to this topic
remove unwanted information from entries in a list of numpy arrays
I have this list of arrays and I don't want my end result to contain stuff like "dtype" etc. My question is: how do I acquire the desired result?
[[0, 1, 3], [2, 4, 5], [6, 7]]
[array([0, 1, 3], dtype=int64), array([2, 4, 5], dtype=int64), array([6, 7], dtype=int64)]
and this is my code:
res =  for i in np.unique(column): res.append(np.where(column == i)) return res, np.unique(column)
where the input is always an array of integers
ImportError: cannot import name 'Pdb' from 'IPython.core.debugger'
It seems I can't use Jupyter notebook at all. I've already tried to uninstall and install again but this error persists.
[I 19:33:14.916 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "/usr/local/lib/python3.7/site-packages/ipykernel/init.py", line 2, in from .connect import * File "/usr/local/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in from IPython.core.profiledir import ProfileDir File "/usr/local/lib/python3.7/site-packages/IPython/init.py", line 54, in from .core.application import Application File "/usr/local/lib/python3.7/site-packages/IPython/core/application.py", line 25, in from IPython.core import release, crashhandler File "/usr/local/lib/python3.7/site-packages/IPython/core/crashhandler.py", line 27, in from IPython.core import ultratb File "/usr/local/lib/python3.7/site-packages/IPython/core/ultratb.py", line 115, in from IPython.core import debugger File "/usr/local/lib/python3.7/site-packages/IPython/core/debugger.py", line 47, in from pdb import Pdb as OldPdb File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pdb.py", line 76, in import code File "/Users/robot/Dropbox/coding/ytautomator/temp/testing_code/code.py", line 17, in fig, ax = plt.subplots(figsize=(15, 8)) File "/usr/local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 1209, in subplots fig = figure(**fig_kw) File "/usr/local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 545, in figure **kwargs) File "/usr/local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 3251, in new_figure_manager fig = fig_cls(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/matplotlib/figure.py", line 367, in init FigureCanvasBase(self) # Set self.canvas. File "/usr/local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 1582, in init self._fix_ipython_backend2gui() File "/usr/local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 1609, in _fix_ipython_backend2gui ip = IPython.get_ipython() File "/usr/local/lib/python3.7/site-packages/IPython/core/getipython.py", line 22, in get_ipython from IPython.core.interactiveshell import InteractiveShell File "/usr/local/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 46, in from IPython.core.debugger import Pdb ImportError: cannot import name 'Pdb' from 'IPython.core.debugger' (/usr/local/lib/python3.7/site-packages/IPython/core/debugger.py)
I'm using Python 3.7.4 with Anaconda in Mac OS 10.14.6
My pip free is the following:
appnope==0.1.0 attrs==19.3.0 backcall==0.1.0 bleach==3.1.0 cycler==0.10.0 decorator==4.4.0 defusedxml==0.6.0 entrypoints==0.3 importlib-metadata==0.23 ipdb==0.12.2 ipykernel==5.1.2 ipython==7.8.0 ipython-genutils==0.2.0 jedi==0.15.1 Jinja2==2.10.3 json5==0.8.5 jsonschema==3.1.1 jupyter-client==5.3.4 jupyter-core==4.6.0 jupyterlab==1.1.4 jupyterlab-server==1.0.6 kiwisolver==1.1.0 MarkupSafe==1.1.1 matplotlib==3.1.1 mistune==0.8.4 more-itertools==7.2.0 nbconvert==5.6.0 nbformat==4.4.0 notebook==6.0.1 numpy==1.17.2 pandas==0.25.1 pandocfilters==1.4.2 parso==0.5.1 pexpect==4.7.0 pickleshare==0.7.5 prometheus-client==0.7.1 prompt-toolkit==2.0.10 ptyprocess==0.6.0 Pygments==2.4.2 pyparsing==2.4.2 pyrsistent==0.15.4 python-dateutil==2.8.0 pytz==2019.3 pyzmq==18.1.0 Send2Trash==1.5.0 six==1.12.0 terminado==0.8.2 testpath==0.4.2 tornado==6.0.3 traitlets==4.3.3 wcwidth==0.1.7 webencodings==0.5.1 zipp==0.6.0
I'd be glad if anyone can help
Don't understand why inserting result from a function is causing this tkinter.TclError
Cost of cab for 1st km is Rs 8 and for the rest of the kilometer it is Rs 5.
Make a equation out of this information:
x = 10 (x is the distance travelled) y = (10*5)+3 (y is the cost of travel)
Make a simple but functional gui with this information:
import tkinter as tk window = tk.Tk() window.title("my maths project") window.geometry("500x500") #FUNCTIONS def fare_calculater(): distance = int(entry_km.get()) fare = 3+(distance*5) print(fare) def fare_display(): showup = fare_calculater() fare_display = tk.Text(master=window, height=10 , width=30) fare_display.grid(column=0, row=5) fare_display.insert(tk.NONE ,showup) #LABEL label_head = tk.Label(text="Hello User!. welcome to the app", font=("The New Roman", 25)) label_head.grid() label_enter = tk.Label(text="Enter the distence commuted by the passanger below") label_enter.grid(column=0, row=1) #ENTRY entry_km = tk.Entry() entry_km.grid(column=0, row=2) #button button_submit = tk.Button(text="submit", bg="green", command=fare_display) button_submit.grid(column=0, row=3)
Here's The Error
Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\swadeshi\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:\Users\swadeshi\Desktop\math project 1.py", line 22, in fare_display fare_display.insert(tk.NONE ,showup) File "C:\Users\swadeshi\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 3272, in insert self.tk.call((self._w, 'insert', index, chars) + args) _tkinter.TclError: wrong # args: should be ".!text insert index chars ?tagList chars tagList ...?"
Sending custom emojis using a custom keyboard
I have been googling all weekend and I have a question. Can I send custom emojis using a custom keyboard through messaging apps. I know my keyboard uses unicode to send standard emojis to other users and that's how messaging apps recognize what is being input and outputted.
I have custom emojis that I want my keyboard to have the ability to send with it showing up on the other end.
Is there a work around without sending it as a sticker or picture?
I was looking into emoticomp and a few others I found through searching. I dont want to create an app that each user has to download either.
Change Windows keyboard layout using c#
Is it possible to change the Windows OS keyboard layout (from azerty to querty for example) using C# ? (for the entire OS, not just the process of the current application)
Do i have to use PInvoke or is there a simpler api/way to do so?
how to simulate keypess event when click some element in js or vue not jquery
The information you should know to understand what i want to do:
There was used ui-element (multi select ) in vue.
This website's features will use on monoblock with touchscreen (no keyboards ). And user's using windows virtual keyboard to fill up the some forms
There are some reasons i don't want use windows virtual keyboard. And want to create custom keyboard( already created and styled with css) enter image description here
What i came across with:
when i try to set value of input enter image description here
when i type some character from my keyboard enter image description here. (this is what i really want to do with my custom keyboard)
- How can i simulate keypress event when i click some character from my custom keyboard?