How to simulate a HOLD keydown event using pywin32?
问题 I am trying to get this piece of python code to work on windows: import win32process, win32con, win32gui, win32api, time HWND = win32gui.GetActiveWindow() win32api.PostMessage(HWND, win32con.WM_KEYDOWN, win32con.VK_SPACE, 0) time.sleep(6) win32api.PostMessage(HWND, win32con.WM_KEYUP, win32con.VK_SPACE, 0) It is supposed to simulate someone holding down the space key, but it does not work and does not provide any sort of error message. I believe I may be doing something wrong with HWND, but I