Python win32api keybd_event: How do I input a string of characters? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python win32api keybd_event: How do I input a string of characters? (/thread-30374.html) |
Python win32api keybd_event: How do I input a string of characters? - JaneTan - Oct-18-2020 Hi, I used the below to get the Window Handle of an app and bring it to be the focus. I want to type in a string of characters into the app. But using win32api.keybd_event, I am able to type in only single characters? Is there a way to type in a string of characters? Eg, "I am happy" Thank you import win32gui import win32api import win32con hld = win32gui.FindWindow (None, "UNTITLED") # Returns the handle of the window titled UNTITLED if hld>0: win32gui.SetForegroundWindow(hld) win32api.keybd_event(0x46, 0, ) # F RE: Python win32api keybd_event: How do I input a string of characters? - Larz60+ - Oct-18-2020 I don't believe there has been a build for python 3, and as such, would render win32gui obsolete. If all you need to do is input a string of characters, you can use: hld = input("Please enter a string of characters: ") # to show results: print(hld) # or better format print(f"You typed: {hld}") RE: Python win32api keybd_event: How do I input a string of characters? - JaneTan - Oct-19-2020 Hi Thanks for the reply. But I don't think u understand my query. I want to input a string of characters into an app. Not ask users to provide an input. If key.event can't do then. How about SendInput function? Thank you RE: Python win32api keybd_event: How do I input a string of characters? - deanhystad - Oct-19-2020 https://stackoverflow.com/questions/64410701/python-win32api-keybd-event-how-do-i-input-a-string-of-characters |