pythoncom

pythoncom crashes on KeyDown when used hooked to certain applications

喜欢而已 提交于 2019-11-27 13:44:39
I wrote this code on to observe the event of a keydown motion. The problem appears to be that when this script is run, certain programs will crash this program, spitting out this error message: TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk_ code', 'scan_code', 'ascii', 'flags', 'time', 'hwnd', and 'win_name' Some programs observed to crash are: Skype, Sublime Text 2 After a few trials at debugging it, the problem appears to be occurring on the final line but I can't seem to narrow it down. I also don't understand the meaning of KeyboardSwitch() as returned by

Ending a Program Mid-Run

…衆ロ難τιáo~ 提交于 2019-11-26 17:12:23
问题 pythoncom.PumpMessages() From what I understand this line basically tells the program to wait forever. For my purposes it seems to be working. However, I'd like to be able to end the program given the right stimulus. How would one go about ending the above line, or stopping the program from running any further. 回答1: According to these docs, pythoncom.PumpMessages() : Pumps all messages for the current thread until a WM_QUIT message. So one way to stop collecting messages is by posting a WM