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


Python win32con.KEYEVENTF_KEYUP属性代码示例

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


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

示例1: __init__

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def __init__(self, virtual_keycode, down, scancode=-1, layout=None):
        """Initialize structure based on key type."""
        if scancode == -1:
            if not layout:
                scancode = windll.user32.MapVirtualKeyW(virtual_keycode, 0)
            else:
                # Assume that 'layout' is a keyboard layout (HKL).
                scancode = windll.user32.MapVirtualKeyExW(virtual_keycode,
                                                          0, layout)

        flags = 0
        if virtual_keycode == 0:
            flags |= 4  # KEYEVENTF_UNICODE
        else:
            if virtual_keycode not in self.soft_keys:
                flags |= 8  # KEYEVENTF_SCANCODE
            if virtual_keycode in self.extended_keys:
                flags |= win32con.KEYEVENTF_EXTENDEDKEY
        if not down:
            flags |= win32con.KEYEVENTF_KEYUP
        

        extra = pointer(c_ulong(0))
        # print(virtual_keycode, scancode, flags, 0, extra)
        Structure.__init__(self, virtual_keycode, scancode, flags, 0, extra) 
开发者ID:dictation-toolbox,项目名称:dragonfly,代码行数:27,代码来源:sendinput.py

示例2: sample_one_person

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def sample_one_person(n, num_x=5, num_y=5):
    save_path = 'D:/UnityEyes_Windows/imgs'
    if os.path.exists(save_path) == False:
        os.mkdir(save_path)

    # reset
    win32gui.SendMessage(handle, win32con.WM_ACTIVATE, win32con.WA_ACTIVE, 0)
    center_x = (clt_left + clt_right) // 2
    center_y = (clt_top + clt_bottom) // 2
    win32api.SetCursorPos([center_x, center_y])

    # press 'L'
    win32api.keybd_event(KEY_LIGHT, 0, 0, 0)  # key down
    time.sleep(1)
    win32api.keybd_event(KEY_LIGHT, 0, win32con.KEYEVENTF_KEYUP, 0)  # key up
    # press 'R'
    win32api.keybd_event(KEY_RANDOM, 0, 0, 0)  # key down
    time.sleep(1)
    win32api.keybd_event(KEY_RANDOM, 0, win32con.KEYEVENTF_KEYUP, 0)  # key up

    # number of points for vertical and horizontal
    # num_x, num_y = 5, 5

    step_x, step_y = width // (num_x + 1), height // (num_y + 1)
    for i in range(1, num_y+1):
        for j in range(1, num_x+1):
            x = clt_left + j * step_x
            y = clt_top + i * step_y
            print('{},{}'.format(x, y))
            win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
            win32api.SetCursorPos([x, y])
            win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
            time.sleep(0.5)
            win32api.keybd_event(KEY_SAVE, 0, 0, 0) # key down
            win32api.keybd_event(KEY_SAVE, 0, win32con.KEYEVENTF_KEYUP, 0)  # key up 
开发者ID:BlueWinters,项目名称:DeepWarp,代码行数:37,代码来源:sampler.py

示例3: push_button

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def push_button(self, button):
        win32api.keybd_event(self.button_to_key(button), 0, 0, 0)
        time.sleep(.15)
        win32api.keybd_event(self.button_to_key(button), 0, win32con.KEYEVENTF_KEYUP, 0) 
开发者ID:aidanrwt,项目名称:twitch-plays,代码行数:6,代码来源:game.py

示例4: f2

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def f2(self):
        key_f2 = 113  # f2对应的键盘输入值
        keybd_event(key_f2, 0, 0, 0)
        keybd_event(key_f2, 0, KEYEVENTF_KEYUP, 0)

    # 截图 
开发者ID:buaazyc,项目名称:Automatic-minesweeping,代码行数:8,代码来源:use_keyboard_and_mouse.py

示例5: key_release

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def key_release(key):
    """Simulates a key release event.

    Sends a scancode to the computer to report which key has been released.
    Some games use DirectInput devices, and respond only to scancodes, not
    virtual key codes. You can simulate DirectInput key releases using this
    method. A call to the key_release(...) method usually follows a call to
    the key_press(..) method of the same key.

    :param key: A string indicating which key to be released.
    """
    try:
        key_name = key.upper()
    except AttributeError:
        raise ValueError('invalid literal for key_release(): {}'.format(key))
    try:
        hex_code = KEYS[key_name]
    except KeyError:
        pass
    else:
        flags = KEYEVENTF_SCANCODE | win32con.KEYEVENTF_KEYUP
        send_keyboard_input(hex_code, flags)
        return
    try:
        hex_code = EXTENDED_KEYS[key_name]
    except KeyError:
        raise ValueError('invalid literal for key_release(): {}'.format(key))
    else:
        flags = (win32con.KEYEVENTF_EXTENDEDKEY | KEYEVENTF_SCANCODE |
                 win32con.KEYEVENTF_KEYUP)
        send_keyboard_input(hex_code, flags) 
开发者ID:AirtestProject,项目名称:Airtest,代码行数:33,代码来源:ctypesinput.py

示例6: pressKey

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def pressKey(self, key):
		keybd_event(self.virtualKeyMap[key], self.hardwareKeyMap[key], 0, 0)
		keybd_event(self.virtualKeyMap[key], self.hardwareKeyMap[key], win32con.KEYEVENTF_KEYUP, 0) 
开发者ID:blurstudio,项目名称:cross3d,代码行数:5,代码来源:rescaletime.py

示例7: __init__

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def __init__(self, virtual_keycode, down):
        scancode = windll.user32.MapVirtualKeyA(virtual_keycode, 0)

        flags = 0
        if not down:
            flags |= win32con.KEYEVENTF_KEYUP
        if virtual_keycode in self.extended_keys:
            flags |= win32con.KEYEVENTF_EXTENDEDKEY

        extra = pointer(c_ulong(0))
        Structure.__init__(self, virtual_keycode, scancode, flags, 0, extra) 
开发者ID:t4ngo,项目名称:dragonfly,代码行数:13,代码来源:sendinput.py

示例8: type

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def type(self, text):
        ''' Type text into device '''
        
        for c in text:
            if c in ShiftCodes:  #judge the character is a capital letter or not; 16 is the value of shift
                win32api.keybd_event(16,win32api.MapVirtualKey(16,0),0,0)
                win32api.keybd_event(ShiftCodes[c],win32api.MapVirtualKey(ShiftCodes[c],0),0,0)
                win32api.keybd_event(16,win32api.MapVirtualKey(16,0),win32con.KEYEVENTF_KEYUP,0)
                win32api.keybd_event(ShiftCodes[c],win32api.MapVirtualKey(ShiftCodes[c],0),win32con.KEYEVENTF_KEYUP,0)
            elif c in OriginalCodes:    #judge the character is a capital letter or not
                win32api.keybd_event(OriginalCodes[c],win32api.MapVirtualKey(OriginalCodes[c],0),0,0)
                win32api.keybd_event(OriginalCodes[c],win32api.MapVirtualKey(OriginalCodes[c],0),win32con.KEYEVENTF_KEYUP,0) 
开发者ID:NetEase,项目名称:airtest,代码行数:14,代码来源:windows.py

示例9: do_key_event

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def do_key_event(self, keys, is_group):
        for key in keys:
            win32api.keybd_event(int(key), 0, 0, 0)
            if not is_group:
                win32api.keybd_event(int(key), 0, win32con.KEYEVENTF_KEYUP, 0)

        if not is_group:
            return
        keys.reverse()
        for key in keys:
            win32api.keybd_event(int(key), 0, win32con.KEYEVENTF_KEYUP, 0)


# 常规函数 
开发者ID:epolestar,项目名称:equant,代码行数:16,代码来源:code_editor.py

示例10: button_event

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def button_event(content):
	key_table = {'BACKSPACE':8, 'TAB':9, 'TABLE':9, 'CLEAR':12, 'ENTER':13, 'SHIFT':16, 'CTRL':17, 
		'CONTROL':17, 'ALT':18, 'ALTER':18, 'PAUSE':19, 'BREAK':19, 'CAPSLK':20, 'CAPSLOCK':20, 'ESC':27, 
		'SPACE':32, 'SPACEBAR':32, 'PGUP':33, 'PAGEUP':33, 'PGDN':34, 'PAGEDOWN':34, 'END':35, 'HOME':36, 
		'LEFT':37, 'UP':38, 'RIGHT':39, 'DOWN':40, 'SELECT':41, 'PRTSC':42, 'PRINTSCREEN':42, 'SYSRQ':42, 
		'SYSTEMREQUEST':42, 'EXECUTE':43, 'SNAPSHOT':44, 'INSERT':45, 'DELETE':46, 'HELP':47, 'WIN':91, 
		'WINDOWS':91, 'F1':112, 'F2':113, 'F3':114, 'F4':115, 'F5':116, 'F6':117, 'F7':118, 'F8':119, 
		'F9':120, 'F10':121, 'F11':122, 'F12':123, 'F13':124, 'F14':125, 'F15':126, 'F16':127, 'NMLK':144, 
		'NUMLK':144, 'NUMLOCK':144, 'SCRLK':145, 'SCROLLLOCK':145, 'LEFTCLICK':999, 'RIGHTCLICK':1000}
	unrecognized = ''
	key_values = []
	keys = content.split('+')
	for key in keys:
		raw_key = key
		key = key.strip().replace(' ','').upper()
		if key in key_table:
			key_values.append(key_table.get(key))
		elif len(key) == 1:
			key_values.append(ord(key))
		else:
			if key != '':
				unrecognized = raw_key
	for key_value in key_values:
		if key_value == 999:
			win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
		elif key_value == 1000:
			win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
		else:
			win32api.keybd_event(key_value, 0, 0, 0)
		time.sleep(1)
	for i in range(len(key_values)-1, -1, -1):
		if key_value == 999:
			win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
		elif key_value == 1000:
			win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
		else:
			win32api.keybd_event(key_values[i], 0, win32con.KEYEVENTF_KEYUP, 0)
		time.sleep(1)
	return unrecognized

#设置开机启动快捷方式 
开发者ID:Jackeriss,项目名称:Email_My_PC,代码行数:43,代码来源:Email My PC.py

示例11: importFBX

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import KEYEVENTF_KEYUP [as 别名]
def importFBX(self, path, showUI=False, **kwargs):

		# Setting up presets.
		presetPaths = self._fbxIOPresetPaths(action='import')
		templatePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'fbx_import_preset.pytempl'))

		# Setting up the FBX presets.
		self._setupFBXIOPresets(presetPaths, templatePath, **{'user': getpass.getuser()})

		# We always show UI in debug mode.
		showUI = True if cross3d.debugLevel >= cross3d.constants.DebugLevels.Mid else showUI

		# If the preset has been modified since the last export, we make sure to reload ours by showing the UI.
		if showUI or (presetPaths and os.path.getmtime(presetPaths[0]) > self._fbxIOPresetModifiedTime + 100):

			# If the user did not want to see the UI, we prepare some callbacks that will press the enter key for him.
			if not showUI:

				# Creating a method that presses enter.
				def pressEnter():
					win32api.keybd_event(0x0D, 0x0D, 0, 0)
					win32api.keybd_event(0x0D, 0x0D, win32con.KEYEVENTF_KEYUP, 0)

				# There will be a prompt for the FBX options.
				QTimer.singleShot(200, pressEnter)

				# There might be a second prompt if the file needs to be overwritten.
				if os.path.exists(path):
					QTimer.singleShot(400, pressEnter)

			# Exporting showin the UI.
			mxs.importfile(path)

		else:
			# Calling the FBX exporter without GUI.
			mxs.importfile(path, mxs.pyhelper.namify("noPrompt"))

		# Restoring presets.
		self._restoreFBXIOPresets()

		# TODO: Softimage returns a model. Here we return a boolean. Do we want to make imported FBX into models or maybe return a list of objects?
		return True 
开发者ID:blurstudio,项目名称:cross3d,代码行数:44,代码来源:studiomaxscene.py


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