with pyautogui, how can I send a press key event to another window?
Jump to turn (12)
- 1with pyautogui, how can I send a press key event to another window?
- 2pyautogui.press("s") isn't sending the letter to the window, it does change focu
- 3still doesn't send the keystroke even with focus on the window
- 4both methods didn't worked, any other alternative?
- 5didn't work, another alternative?
- 6inputs.send(Keycode.fromvk(0x1f), Keycode.fromvk(0x1f)) NameError: name 'inputs'
- 7in the terminal it installed correctly: Successfully installed inputs-0.5, but t
- 8it says ImportError: cannot import name 'KeyEvent' from 'inputs', it is because
- 9now it is: ImportError: cannot import name 'EventQueue' from 'inputs' (C:\Users\
- 10evdev doesn't even install is there another alternative?
- 11it works in another window but not in the window I want, is there another altern
- 12events.append(win32api.INPUT( AttributeError: module 'win32api' has no attribute
- User
with pyautogui, how can I send a press key event to another window?
- Assistant
To send a press key event to another window using PyAutoGUI, you can follow these steps:
-
Get the window's handle using the
win32guimodule. You can usewin32gui.FindWindow()orwin32gui.FindWindowEx()function to get the handle. -
Activate the window using the
win32gui.SetForegroundWindow()function. This will bring the window to the front and give it focus. -
Use the
pyautogui.press()function to send the key press event to the active window.
Here's an example code:
python -