Skip to content

Instantly share code, notes, and snippets.

@beordle
Created February 19, 2013 07:21
Show Gist options
  • Save beordle/4983752 to your computer and use it in GitHub Desktop.
Save beordle/4983752 to your computer and use it in GitHub Desktop.
圣堂改建 一键大招(削弱前有用)
#coding:utf-8
import ctypes,win32ui,win32con,pyHook,pythoncom,time,win32api
WAR3_WINDOW_CLASS=None
WAR3_WINDOW_NAME="Warcraft III"
def click():
x,y=win32api.GetCursorPos()
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
def clickright():
x,y=win32api.GetCursorPos()
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,x,y,0,0)
def pressmutichar(hwnd,char):
for i in char:
presschar(hwnd,char)
def presschar(hwnd,char):
pressint(hwnd,ord(char))
def pressint(hwnd,int):
print "Runtest"
hwnd.PostMessage( win32con.WM_KEYDOWN, int)
hwnd.PostMessage( win32con.WM_CHAR , int)
hwnd.PostMessage( win32con.WM_KEYUP , int)
skills=('E')
#36 38 33
#37 12 39
#35 40 34
def hookhandle(event):
key,id=chr(event.KeyID),event.KeyID
print "key", chr(event.KeyID) ,id,
hwnd=win32ui.FindWindow(WAR3_WINDOW_CLASS,WAR3_WINDOW_NAME)
if key=="Q":
presschar(hwnd,'C')
click()
time.sleep(0.2)
clickright()
time.sleep(0.4)
pressint(hwnd,9)
time.sleep(0.1)
presschar(hwnd,'T')
return False
print u"Fail"
return True
if key=="N":
exit()
hm = pyHook.HookManager()
hm.KeyDown=hookhandle
hm.HookKeyboard()
pythoncom.PumpMessages()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment