本文整理汇总了Python中pykeyboard.PyKeyboard.tap_key方法的典型用法代码示例。如果您正苦于以下问题:Python PyKeyboard.tap_key方法的具体用法?Python PyKeyboard.tap_key怎么用?Python PyKeyboard.tap_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykeyboard.PyKeyboard
的用法示例。
在下文中一共展示了PyKeyboard.tap_key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_End_analog
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def on_End_analog():
logging.info(30*'_' + " on_End_analog")
k = PyKeyboard()
#抬起功能按键Ctrl,否则End效果会变为Ctrl+End效果
k.release_key(k.control_key)
k.tap_key(k.end_key)
return False
示例2: previous_focus
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def previous_focus():
print('*_* next_focus')
k = PyKeyboard()
k.press_key(k.shift_key)
k.tap_key(k.tab_key)
k.release_key(k.shift_key)
示例3: switch_to_highlayer
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def switch_to_highlayer(outName, frameNumber, segNumber):
#totalIdx = len(inputList)
'''
timeInterval defines the print frequency of the frame number in the terminal.
'''
timeInterval = 0.4
frameStep = timeInterval*25
k = PyKeyboard()
logName = outName + ".log"
tmpIdx = 1
while True:
text = subprocess.check_output(["tail", "-1", logName])
#tmpIdx = totalIdx - len(inputList)+1
if "PAUSE" in text and "===== PAUSE =====\rV:" not in text:
sleep(timeInterval)
continue
elif "Exiting" in text:
break
else:
print text
sleep(timeInterval)
frameIdx = parse_frame_idx(text)
if frameIdx >= frameNumber*tmpIdx and frameIdx < frameNumber*tmpIdx + frameStep:
print "======================================"
print "currentFrame is: "+str(frameIdx)+".\n"
if bool(stepList):
tmpIdx = tmpIdx +1
value = stepList.pop(0)
if value >0:
for t in range(value):
k.tap_key('b')
print "switch to higher layer"
sleep(0.1)
else:
break
示例4: change_window_start
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def change_window_start():
print('*_* change_window_start')
k = PyKeyboard()
k.release_key(k.alt_key)
k.press_key(k.alt_key)
k.tap_key(k.tab_key)
示例5: xdomenu
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def xdomenu():
"""interacts with a simple menu."""
char_to_bin = {'s': 'srmenu',
'j': 'jmenu',
'c': 'clipmenu',
't': 'terminal',
'u': 'urxvt',
'p': 'pomodoro',
' ': 'moveempty'}
keybrd = PyKeyboard()
k_menu = keybrd.menu_key
persistent = False
print_menu(persistent)
while True:
sleep(0.1)
stdout.flush()
char = getchar()
try:
cmd = char_to_bin[char]
print_flush(cmd)
if persistent:
sleep(0.2)
keybrd.tap_key(k_menu)
except KeyError:
if char == '\t':
persistent = not persistent
print_menu(persistent)
else:
keybrd.tap_key(k_menu)
示例6: faceTracker
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def faceTracker():
print "Face Track running"
k = PyKeyboard()
faceCascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
video_capture = cv2.VideoCapture(0)
centerX = 0;
while True:
# Capture frame-by-frame
ret, frame = video_capture.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(gray,scaleFactor=1.1,minNeighbors=5,minSize=(150, 150), )
#Draw a rectangle around the face
if len(faces) >= 1:
(x,y,w,h) = faces[0]
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
centerNew = x + w/2
if centerNew > centerX + 10:
print('left')
k.tap_key('Left')
if centerNew < centerX - 10:
print('right')
k.tap_key('Right')
centerX = centerNew
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()
示例7: key_combo
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def key_combo(key0, key1):
k = PyKeyboard()
if key0 == 'ctrl':
key0 = k.control_key
k.press_key(key0)
k.tap_key(key1)
k.release_key(key0)
示例8: KLKeyboard
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
class KLKeyboard(object):
def __init__(self):
self.keyboard = PyKeyboard()
pass
def hitKey(self, key):
self.keyboard.tap_key(key)
示例9: close_tab
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def close_tab():
print('*_* new_tab')
k = PyKeyboard()
k.release_key(k.control_l_key)
k.press_key(k.control_l_key)
k.tap_key(k.function_keys[4])F
k.release_key(k.control_l_key)
示例10: new_tab
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def new_tab():
print('*_* new_tab')
k = PyKeyboard()
k.release_key(k.control_l_key)
k.press_key(k.control_l_key)
k.tap_key('t')
k.release_key(k.control_l_key)
示例11: next_tab
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def next_tab():
print('*_* next_tab')
k = PyKeyboard()
k.press_key(k.control_l_key)
# k.press_key(k.shift_key)
k.tap_key(k.tab_key)
k.release_key(k.control_l_key)
示例12: previous_tab
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def previous_tab():
print('*_* previous_tab')
k = PyKeyboard()
k.press_key(k.control_l_key)
k.press_key(k.shift_key)
k.tap_key(k.tab_key)
k.release_key(k.control_l_key)
k.release_key(k.shift_key)
示例13: runExp
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def runExp(self):
k = PyKeyboard()
# Resetting both gammas
k.type_string('s')
k.type_string('d')
for i in xrange(self.SWEEP_STEP_SIZE):
if (self.running):
# Resetting gammaSta
k.type_string('s')
for j in xrange(self.SWEEP_STEP_SIZE):
if (self.running):
self.currTrial = i*self.SWEEP_STEP_SIZE + j + 1
# Reset and cool-down
for nagging in xrange(5):
k.type_string('0')
sleep(0.3)
self.strong_damper.damping = 0.0
# Perturbation
k.type_string('j')
sleep(3)
# Increasing gammaSta
k.type_string('w')
sleep(1.0)
# Add a strong damper to stop any motion
self.strong_damper.damping = 100.0
# attmept to remove the residual torque.
bitVal = convertType(0.0, fromType = 'f', toType = 'I')
xem_spindle_bic.SendPara(bitVal = bitVal, trigEvent = 1) # Ia gain
xem_spindle_tri.SendPara(bitVal = bitVal, trigEvent = 1)
xem_spindle_bic.SendPara(bitVal = bitVal, trigEvent = 10) # II gain
xem_spindle_tri.SendPara(bitVal = bitVal, trigEvent = 10)
sleep(2.0)
bitVal = convertType(1.2, fromType = 'f', toType = 'I')
xem_spindle_bic.SendPara(bitVal = bitVal, trigEvent = 1) # Ia gain
xem_spindle_tri.SendPara(bitVal = bitVal, trigEvent = 1)
bitVal_II = convertType(2.0, fromType = 'f', toType = 'I')
xem_spindle_bic.SendPara(bitVal = bitVal_II, trigEvent = 10) # II gain
xem_spindle_tri.SendPara(bitVal = bitVal_II, trigEvent = 10)
# Increasing gammaDyn
k.type_string('e')
k.tap_key(k.escape_key)
示例14: keypress
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def keypress(key):
"""
Simulates a key press
Args:
key (str) : the key [a-zA-Z0-9] to enter. Use 'enter' for the
return key
"""
k = PyKeyboard()
if key == 'enter':
key = k.return_key
k.tap_key(key)
示例15: fill_board
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import tap_key [as 别名]
def fill_board(start_board, solution_board, x,y,width,height):
cell_width = width / 9
cell_height = height / 9
mouse = PyMouse()
keyboard = PyKeyboard()
for i in range(0,9):
for j in range(0,9):
# insert only empty cell
if start_board.values[j][i] == 0:
sleep(0.1)
mouse.click(x + cell_width*(j+0.5), y+cell_height*(i+0.5))
sleep(0.01)
keyboard.tap_key(str(solution_board.values[j][i]))