【发布时间】:2016-01-07 07:14:14
【问题描述】:
以下代码的循环会在 10 分钟后自动中断,我想手动中断此循环,这意味着我想发送键盘事件(ctrl + shift + x)来中断。我该怎么做?感谢您花时间阅读本文。
def mouseerr():
timeout = time.time() + 60*10
while 1:
ctypes.windll.user32.SetCursorPos(0,0)
if time.time() > timeout:
break
【问题讨论】:
-
会this idea 帮忙吗?Curses 包有助于检索键盘输入。另一种方法是使用tkinter 制作一个小型 GUI,并在其中绑定your desired key combination!
-
也许
msvcrt会有所帮助? -
@NanderSpeerstra 寻找基于windows的解决方案。
标签: python