Last active
December 13, 2015 22:19
-
-
Save beordle/4983735 to your computer and use it in GitHub Desktop.
以前写的dota卡尔改建
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
"""卡尔,25级时神一样的英雄。因为DotA里最为拉风的英雄是卡尔,也就前期较为弱势。虽然没有后期DPS,但是并不是说他输出不行,只是站不住而已。不过它主要还是个大后期法师。 | |
具体的改建方案是 | |
'F':('EEQ','熔炉精灵'), | |
'G':('QQE','寒冰之墙'), | |
'V':('QQW','幽灵漫步'), | |
这三个技能需要连按技能键一次或两次(如果技能已经存于面板中,只需一次),而 | |
'Y':('QQQ','急速冷却'), | |
'B':('QWE','超震声波'), | |
'D':('EEW','混沌陨石'), | |
'Z':('WWE','灵动迅捷'), | |
'X':('WWQ','强袭飓风'), | |
'C':('WWW','电磁脉冲'), | |
'T':('EEE','阳炎冲击'), | |
这些技能只需要按技能键就可以了。极大的简化了卡尔对操作的要求(除了更换元素球以外,不需要QWE按键了。至于R键,更是没有了任何作用)。不过如果想要使用QWER的话,也是兼容的。""" | |
import win32ui,win32con,pyHook,pythoncom,time | |
#Setting | |
enable=True | |
history=(None,0) | |
WAR3_WINDOW_CLASS=None | |
WAR3_WINDOW_NAME="Warcraft III" | |
APPNAME="DotA卡尔技能智能重建工具 1.0" | |
skill_list={ | |
'Y':('QQQ','急速冷却'), | |
'B':('QWE','超震声波'), | |
'D':('EEW','混沌陨石'), | |
'F':('EEQ','熔炉精灵'), | |
'G':('QQE','寒冰之墙'), | |
'V':('QQW','幽灵漫步'), | |
'Z':('WWE','灵动迅捷'), | |
'X':('WWQ','强袭飓风'), | |
'C':('WWW','电磁脉冲'), | |
'T':('EEE','阳炎冲击'), | |
} | |
just_skill=('G','F','V') | |
def map(char): | |
pass | |
def press(hwnd,char): | |
for i in char: | |
time.sleep(0.02) | |
hwnd.SendMessage( win32con.WM_KEYDOWN, ord(i)) | |
# hwnd.SendMessage( win32con.WM_CHAR , ord(i)) | |
time.sleep(0.02) | |
hwnd.SendMessage( win32con.WM_KEYUP , ord(i)) | |
def hookhandle(event): | |
global enable | |
enable=True | |
if enable: | |
global history | |
key=chr(event.KeyID) | |
print "key",chr(event.KeyID),event.KeyID | |
if key in skill_list.keys(): | |
print "捕捉到技能",skill_list[chr(event.KeyID)][1], | |
skill=key | |
try: | |
print '尝试改键...', | |
hwnd=win32ui.FindWindow(WAR3_WINDOW_CLASS,WAR3_WINDOW_NAME) | |
if skill in just_skill: | |
print "非指向型技能..", | |
print skill | |
print history[0] | |
if skill==history[0] and time.time()-history[1]<0.5: | |
print "第2次", | |
press(hwnd,skill_list[skill][0]+'R') | |
time.sleep(0.2) | |
press(hwnd,skill) | |
history=('4',0) | |
else: | |
print "第1次", | |
press(hwnd,skill_list[skill][0]) | |
time.sleep(0.2) | |
press(hwnd,skill) | |
history=(skill,time.time()) | |
else: | |
press(hwnd,skill+skill_list[skill][0]+'R'+skill) | |
print '拦截原始键盘消息,OK.' | |
return False | |
except: | |
print "失败" | |
pass | |
return True | |
else: | |
pass | |
print APPNAME | |
print "初始化中..." | |
hm = pyHook.HookManager() | |
hm.KeyDown=hookhandle | |
hm.HookKeyboard() | |
print "初始化完成.正在监视..." | |
pythoncom.PumpMessages() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment