def OnKeyDown(self, msg):
key = msg[2]
if win32api.GetKeyState(win32con.VK_CONTROL) & 0x8000:
modList = MODIFYING_VK_KEYS_CTRL
elif win32api.GetKeyState(win32con.VK_MENU) & 0x8000:
modList = MODIFYING_VK_KEYS_ALT
else:
modList = MODIFYING_VK_KEYS
if key in modList:
# Return 1 if we can make the file editable.(or it already is!)
return self.GetDocument().CheckMakeDocumentWritable()
return 1 # Pass it on OK
# def OnKey(self, key):
# return self.GetDocument().CheckMakeDocumentWritable()
python类VK_MENU的实例源码
def fire_key_event(self, msg):
key = msg[2]
keyState = 0
if win32api.GetKeyState(win32con.VK_CONTROL) & 0x8000:
keyState = keyState | win32con.RIGHT_CTRL_PRESSED | win32con.LEFT_CTRL_PRESSED
if win32api.GetKeyState(win32con.VK_SHIFT) & 0x8000:
keyState = keyState | win32con.SHIFT_PRESSED
if win32api.GetKeyState(win32con.VK_MENU) & 0x8000:
keyState = keyState | win32con.LEFT_ALT_PRESSED | win32con.RIGHT_ALT_PRESSED
keyinfo = key, keyState
# Special hacks for the dead-char key on non-US keyboards.
# (XXX - which do not work :-(
event = self.keymap.get( keyinfo )
if event is None:
return 1
return self.fire(event, None)
def OnKeyDown(self, msg):
key = msg[2]
if win32api.GetKeyState(win32con.VK_CONTROL) & 0x8000:
modList = MODIFYING_VK_KEYS_CTRL
elif win32api.GetKeyState(win32con.VK_MENU) & 0x8000:
modList = MODIFYING_VK_KEYS_ALT
else:
modList = MODIFYING_VK_KEYS
if key in modList:
# Return 1 if we can make the file editable.(or it already is!)
return self.GetDocument().CheckMakeDocumentWritable()
return 1 # Pass it on OK
# def OnKey(self, key):
# return self.GetDocument().CheckMakeDocumentWritable()
def fire_key_event(self, msg):
key = msg[2]
keyState = 0
if win32api.GetKeyState(win32con.VK_CONTROL) & 0x8000:
keyState = keyState | win32con.RIGHT_CTRL_PRESSED | win32con.LEFT_CTRL_PRESSED
if win32api.GetKeyState(win32con.VK_SHIFT) & 0x8000:
keyState = keyState | win32con.SHIFT_PRESSED
if win32api.GetKeyState(win32con.VK_MENU) & 0x8000:
keyState = keyState | win32con.LEFT_ALT_PRESSED | win32con.RIGHT_ALT_PRESSED
keyinfo = key, keyState
# Special hacks for the dead-char key on non-US keyboards.
# (XXX - which do not work :-(
event = self.keymap.get( keyinfo )
if event is None:
return 1
return self.fire(event, None)
def generateVirtualKey(self, key):
keyMap = {
"left": win32con.VK_LEFT,
"down": win32con.VK_DOWN,
"tab" : win32con.VK_TAB,
"up": win32con.VK_UP,
"right": win32con.VK_RIGHT,
"ctrl" : win32con.VK_CONTROL,
"esc" : win32con.VK_ESCAPE,
"enter" : win32con.VK_RETURN,
"alt" : win32con.VK_MENU,
";:" : 0xBA,
"\\|" : 0xDC,
".>" : 0xBE,
"-_" : 0xBD,
"win" : 0x5B,
"shift" : win32con.VK_SHIFT
}
if key in keyMap:
return keyMap[key]
else:
return ord(key.upper())
def game_reset(self):
#?? ?? ???????? ? ????
win32api.keybd_event(win32con.VK_MENU, 0, 0, 0) #alt down
time.sleep(self.interval_time)
win32api.keybd_event(win32con.VK_MENU, 0, win32con.KEYEVENTF_KEYUP, 0) #alt up
win32api.keybd_event(0x47, 0, 0, 0) # key'G' down
time.sleep(0.01)
win32api.keybd_event(0x47, 0, win32con.KEYEVENTF_KEYUP, 0) # key 'G' up
win32api.keybd_event(0x52, 0, 0, 0) # key 'R' down
time.sleep(0.01)
win32api.keybd_event(0x52, 0, win32con.KEYEVENTF_KEYUP, 0) # key 'R' up
self.game_start()
def QQ_ToggleMessageRecord():
win32api.keybd_event(win32con.VK_MENU, 0, 0, 0);
win32api.keybd_event(ord('H'), 0, 0, 0);
win32api.keybd_event(ord('H'), 0, win32con.KEYEVENTF_KEYUP, 0);
win32api.keybd_event(win32con.VK_MENU, 0, win32con.KEYEVENTF_KEYUP, 0);
# Copy the last message.
def QQ_CloseWindow():
win32api.keybd_event(win32con.VK_MENU, 0, 0, 0);
win32api.keybd_event(win32con.VK_F4, 0, 0, 0);
win32api.keybd_event(win32con.VK_F4, 0, win32con.KEYEVENTF_KEYUP, 0);
win32api.keybd_event(win32con.VK_MENU, 0, win32con.KEYEVENTF_KEYUP, 0);
# Get the clipboard into a str.