当前位置: 首页>>代码示例>>Python>>正文


Python win32con.WM_KEYDOWN属性代码示例

本文整理汇总了Python中win32con.WM_KEYDOWN属性的典型用法代码示例。如果您正苦于以下问题:Python win32con.WM_KEYDOWN属性的具体用法?Python win32con.WM_KEYDOWN怎么用?Python win32con.WM_KEYDOWN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在win32con的用法示例。


在下文中一共展示了win32con.WM_KEYDOWN属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HookHandlers

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def HookHandlers(self):	# children can override, but should still call me!
#		self.HookAllKeyStrokes(self.OnKey)
		self.HookMessage(self.OnCheckExternalDocumentUpdated,MSG_CHECK_EXTERNAL_FILE)
		self.HookMessage(self.OnRClick,win32con.WM_RBUTTONDOWN)
		self.HookMessage(self.OnSetFocus, win32con.WM_SETFOCUS)
		self.HookMessage(self.OnKeyDown, win32con.WM_KEYDOWN)
		self.HookKeyStroke(self.OnKeyCtrlY, 25)	# ^Y
		self.HookKeyStroke(self.OnKeyCtrlG, 7)	# ^G
		self.HookKeyStroke(self.OnKeyTab, 9)	# TAB
		self.HookKeyStroke(self.OnKeyEnter, 13) # Enter
		self.HookCommand(self.OnCmdLocateFile, ID_LOCATE_FILE)
		self.HookCommand(self.OnCmdGotoLine, ID_GOTO_LINE)
		self.HookCommand(self.OnEditPaste, afxres.ID_EDIT_PASTE)
		self.HookCommand(self.OnEditCut, afxres.ID_EDIT_CUT)

	# Hook Handlers 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:editor.py

示例2: ctrl_click

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def ctrl_click(x :int, y :int) -> None:
        """Clicks at pixel x, y while simulating the CTRL button to be down."""
        x += Window.x
        y += Window.y
        lParam = win32api.MAKELONG(x, y)
        while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
               win32api.GetKeyState(wcon.VK_SHIFT) < 0 or
               win32api.GetKeyState(wcon.VK_MENU) < 0):
            time.sleep(0.005)

        win32gui.PostMessage(Window.id, wcon.WM_KEYDOWN, wcon.VK_CONTROL, 0)
        win32gui.PostMessage(Window.id, wcon.WM_LBUTTONDOWN,
                             wcon.MK_LBUTTON, lParam)
        win32gui.PostMessage(Window.id, wcon.WM_LBUTTONUP,
                             wcon.MK_LBUTTON, lParam)
        win32gui.PostMessage(Window.id, wcon.WM_KEYUP, wcon.VK_CONTROL, 0)
        time.sleep(userset.MEDIUM_SLEEP) 
开发者ID:kujan,项目名称:NGU-scripts,代码行数:19,代码来源:inputs.py

示例3: CreateWindow

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def CreateWindow(self, parent):
		list = self
		style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | commctrl.LVS_EDITLABELS | commctrl.LVS_REPORT
		self._obj_.CreateWindow(style, self.GetDefRect(), parent, win32ui.IDC_LIST1)
		self.HookMessage(self.OnKeyDown, win32con.WM_KEYDOWN)
		self.HookMessage(self.OnKeyDown, win32con.WM_SYSKEYDOWN)
		list = self
		title, width = self.columns[0]
		itemDetails = (commctrl.LVCFMT_LEFT, width, title, 0)
		list.InsertColumn(0, itemDetails)
		col = 1
		for title, width in self.columns[1:]:
			col = col + 1
			itemDetails = (commctrl.LVCFMT_LEFT, width, title, 0)
			list.InsertColumn(col, itemDetails)
		parent.HookNotify(self.OnListEndLabelEdit, LVN_ENDLABELEDIT)
		parent.HookNotify(self.OnItemRightClick, commctrl.NM_RCLICK)
		parent.HookNotify(self.OnItemDoubleClick, commctrl.NM_DBLCLK) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:debugger.py

示例4: send_arrow_press

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def send_arrow_press(left :bool) -> None:
        """Sends either a left or right arrow key press"""
        if left: key = wcon.VK_LEFT
        else   : key = wcon.VK_RIGHT
        
        win32gui.PostMessage(Window.id, wcon.WM_KEYDOWN, key, 0)
        time.sleep(0.05)
        win32gui.PostMessage(Window.id, wcon.WM_KEYUP, key, 0)
        time.sleep(0.05) 
开发者ID:kujan,项目名称:NGU-scripts,代码行数:11,代码来源:inputs.py

示例5: send_string

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def send_string(string :str) -> None:
        """Send one or multiple characters to the Window."""
        # Ensure it's a string by converting it to a string
        if isinstance(string, float):
            string = int(string)
        for c in str(string):
            # Make sure no key modifier is pressed
            while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
                   win32api.GetKeyState(wcon.VK_SHIFT)   < 0 or
                   win32api.GetKeyState(wcon.VK_MENU)    < 0):
                time.sleep(0.005)
            
            vkc = win32api.VkKeyScan(c)  # Get virtual key code for character c
            # Only one keyup or keydown event needs to be sent
            win32gui.PostMessage(Window.id, wcon.WM_KEYDOWN, vkc, 0) 
开发者ID:kujan,项目名称:NGU-scripts,代码行数:17,代码来源:inputs.py

示例6: HookHandlers

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def HookHandlers(self):
		# Create events for all the menu names.
		for name, val in event_commands:
#			handler = lambda id, code, tosend=val, parent=parent: parent.OnCommand(tosend, 0) and 0
			self.bindings.bind(name, None, cid=val)

		# Hook commands that do nothing other than send Scintilla messages.
		for command, reflection in command_reflectors:
			handler = lambda id, code, ss=self.SendScintilla, tosend=reflection: ss(tosend) and 0
			self.HookCommand(handler, command)

		self.HookCommand(self.OnCmdViewWS, win32ui.ID_VIEW_WHITESPACE)
		self.HookCommandUpdate(self.OnUpdateViewWS, win32ui.ID_VIEW_WHITESPACE)
		self.HookCommand(self.OnCmdViewIndentationGuides, win32ui.ID_VIEW_INDENTATIONGUIDES)
		self.HookCommandUpdate(self.OnUpdateViewIndentationGuides, win32ui.ID_VIEW_INDENTATIONGUIDES)
		self.HookCommand(self.OnCmdViewRightEdge, win32ui.ID_VIEW_RIGHT_EDGE)
		self.HookCommandUpdate(self.OnUpdateViewRightEdge, win32ui.ID_VIEW_RIGHT_EDGE)
		self.HookCommand(self.OnCmdViewEOL, win32ui.ID_VIEW_EOL)
		self.HookCommandUpdate(self.OnUpdateViewEOL, win32ui.ID_VIEW_EOL)
		self.HookCommand(self.OnCmdViewFixedFont, win32ui.ID_VIEW_FIXED_FONT)
		self.HookCommandUpdate(self.OnUpdateViewFixedFont, win32ui.ID_VIEW_FIXED_FONT)
		self.HookCommand(self.OnCmdFileLocate, win32ui.ID_FILE_LOCATE)
		self.HookCommand(self.OnCmdEditFind, win32ui.ID_EDIT_FIND)
		self.HookCommand(self.OnCmdEditRepeat, win32ui.ID_EDIT_REPEAT)
		self.HookCommand(self.OnCmdEditReplace, win32ui.ID_EDIT_REPLACE)
		self.HookCommand(self.OnCmdGotoLine, win32ui.ID_EDIT_GOTO_LINE)
		self.HookCommand(self.OnFilePrint, afxres.ID_FILE_PRINT)
		self.HookCommand(self.OnFilePrint, afxres.ID_FILE_PRINT_DIRECT)
		self.HookCommand(self.OnFilePrintPreview,
			win32ui.ID_FILE_PRINT_PREVIEW)
		# Key bindings.
		self.HookMessage(self.OnKeyDown, win32con.WM_KEYDOWN)
		self.HookMessage(self.OnKeyDown, win32con.WM_SYSKEYDOWN)
		# Hook wheeley mouse events
#		self.HookMessage(self.OnMouseWheel, win32con.WM_MOUSEWHEEL)
		self.HookFormatter() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:38,代码来源:view.py

示例7: sendkeypress

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def sendkeypress(self, key):
        hwnd = self.Console_hwnd[0]

        # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, key, 0)
        win32gui.PostMessage(hwnd, win32con.WM_KEYUP, key, 0) 
开发者ID:turingsec,项目名称:marsnake,代码行数:7,代码来源:winpty.py

示例8: sendKey

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def sendKey(hwnd, key_code):
    '''
    模拟按键
    :param hwnd: 窗体句柄
    :param key_code: 按键码,在win32con下,比如win32con.VK_F1
    :return:
    '''
    win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, key_code, 0)  # 消息键盘
    time.sleep(.2)
    win32gui.PostMessage(hwnd, win32con.WM_KEYUP, key_code, 0) 
开发者ID:ynzheng,项目名称:pyautotrade_tdx,代码行数:12,代码来源:winguiauto.py

示例9: pressKey

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def pressKey(hwnd, key_code):
    '''
    模拟按键
    :param hwnd: 窗体句柄
    :param key_code: 按键码,在win32con下,比如win32con.VK_F1
    :return:
    '''
    win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, key_code, 0)  # 消息键盘
    time.sleep(.2)
    win32gui.PostMessage(hwnd, win32con.WM_KEYUP, key_code, 0)
    time.sleep(.2) 
开发者ID:bluestinger,项目名称:PyAutoTrading,代码行数:13,代码来源:winguiauto.py

示例10: sendKeyMsg

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import WM_KEYDOWN [as 别名]
def sendKeyMsg(hwnd, key_code):
    """
    模拟按键
    :param hwnd: 窗体句柄
    :param key_code: 按键码,在win32con下,比如win32con.VK_F1
    :return:
    """
    win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, key_code, 0)  # 消息键盘
    time.sleep(0.2)
    win32gui.PostMessage(hwnd, win32con.WM_KEYUP, key_code, 0)
    time.sleep(0.2) 
开发者ID:drongh,项目名称:pyAutoTrading,代码行数:13,代码来源:winguiauto.py


注:本文中的win32con.WM_KEYDOWN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。