python - Use pyhook to monitor keystrokes and delete specified characters, but an error will be reported the second time you run it. What is the reason?
習慣沉默
習慣沉默 2017-05-18 10:50:39
0
1
483
#coding=utf-8
import pyHook
import pythoncom

list = [4,0,5,0,6,4,0]

def del_zero(array):
    for i in array:
        if i == 0:
            array.remove(i)
            array.append(int(0))
    return array


def onKeyboardEvent(event):
    # 监听键盘事件
    lit = []
    if event.Key == "Down":
        lit = del_zero(list)
        print lit
    return (event.Key)

def main():
    # 创建一个“钩子”管理对象
    hm = pyHook.HookManager()
    # 监听所有键盘事件
    hm.KeyDown = onKeyboardEvent
    # 设置键盘“钩子”
    hm.HookKeyboard()
    # 监听所有鼠标事件
    pythoncom.PumpMessages()

if __name__ == "__main__":
    main()
習慣沉默
習慣沉默

reply all(1)
某草草

The error message was not posted and no one answered you

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!