Python win32con 模块,VK_CONTROL 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用win32con.VK_CONTROL

项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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)
项目:PyUIA    作者:xiaoxiayu    | 项目源码 | 文件源码
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())
项目:PyF9    作者:Saren-Arterius    | 项目源码 | 文件源码
def type_char_worker():
    while True:
        char = type_char_queue.get()
        if char is None:
            break
        if platform.system() == 'Linux':
            if LINUX_USE_CLIPBOARD:
                was = None
                try:
                    was = root.clipboard_get()
                except:
                    pass
                root.clipboard_clear()
                root.clipboard_append(char)
                # call(["xdotool", "key", "CTRL+V"], False)
                linux_paste()
                if was is not None:
                    sleep(CLIPBOARD_WAIT_DELAY)
                    root.clipboard_clear()
                    root.clipboard_append(was)
            else:
                call(["xdotool", "key", "U" + hex(ord(char))[2:]], True)
        else:
            was = None
            try:
                was = win_get_clipboard_text()
            except:
                pass
            win_set_clipboard_text(char)
            win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0)
            win32api.keybd_event(0x56, 0, 0, 0)
            win32api.keybd_event(win32con.VK_CONTROL, 0,
                                 win32con.KEYEVENTF_KEYUP, 0)
            win32api.keybd_event(0x56, 0, win32con.KEYEVENTF_KEYUP, 0)
            if was is not None:
                sleep(CLIPBOARD_WAIT_DELAY)
                win_set_clipboard_text(was)
        type_char_queue.task_done()
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_PrintText(str):
    print "Send text = " + str.decode('gbk')
    QQ_setClipboardText(str)
    win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0);
    win32api.keybd_event(ord('V'), 0, 0, 0);
    win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0);

# AT a name.
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_Enter():
    win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0);
    win32api.keybd_event(win32con.VK_RETURN, 0, 0, 0);
    win32api.keybd_event(win32con.VK_RETURN, 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0);

# The interface function to send QQ a message.
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_SendTextWithAt(str):
    os.system(qq_shortcut)

    try_time = 0
    while True:
        time.sleep(0.5)
        hwnd = win32gui.FindWindow(None, '??&??')
        # hwnd = win32gui.FindWindow(None, 'OSVT?O?')
        print('try_time = %d, hwnd = %d' % (try_time, hwnd))
        if hwnd != 0:
            break
        elif try_time >= 60:
            print ('SendTextToQQ Error.')
            return
        else:
            try_time = try_time + 1

    win32gui.SetForegroundWindow(hwnd)

    QQ_PrintTextWithAt(str)
    QQ_Enter()

    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_RETURN, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('v'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('v'), 0)


    #win32gui.SendMessage(hwnd, win32con.WM_SETTEXT, None, 'aaa')
    #win32gui.SetWindowText(hwnd, 'aaa')
    #win32gui.ReplaceSel()
    #win32gui.PostMessage(hwnd, win32con.WM_CHAR, '', 3)

    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_CONTROL, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('V'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('V'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_CONTROL, 0)
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_CopyText():
    win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0);
    win32api.keybd_event(ord('C'), 0, 0, 0);
    win32api.keybd_event(ord('C'), 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0);

# Close the window.
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_PasteFile():
    win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0);
    win32api.keybd_event(ord('V'), 0, 0, 0);
    win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0);