本程序python2.7 http://pan.baidu.com/s/1gdILez5
用的win32模块控制键盘 http://pan.baidu.com/s/1o6wSgdW
#coding=GBK import threading import time import win32con, win32api #循环执行自动按键程序 def keyauto(): waitTimes = 5 perTimes = 0.8; print("run...") while True: #间隔5秒后开始自动按键 time.sleep(waitTimes) pressKey(1, 0.1) #鼠标左键,0.1秒后抬起 pressKey(2, 0.1) #R pressKey(9, 0.1) #table pressKey(32, 0.1) #space pressKey(67, 0.1) #c pressKey(86, 0.1) #v time.sleep(perTimes) pressKey(88, 0.1) pressKey(1, 0.1) #L pressKey(67, 0.1) #c pressKey(48, 0.1) #1 time.sleep(perTimes) pressKey(49, 0.1) #2 time.sleep(perTimes) pressKey(50, 0.1) #3 #按下某个键(key)后,second秒后再抬起这个键。所有键码:http://zhidao.baidu.com/question/266291349.html def pressKey(key, second): win32api.keybd_event(key, 0, 0, 0) if(second != 0): time.sleep(second) win32api.keybd_event(key, 0, win32con.KEYEVENTF_KEYUP, 0) #开启一个线程并运行 t = threading.Thread(target=keyauto()) t.start()