本文整理汇总了Python中pykeyboard.PyKeyboard类的典型用法代码示例。如果您正苦于以下问题:Python PyKeyboard类的具体用法?Python PyKeyboard怎么用?Python PyKeyboard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PyKeyboard类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: Keyboard
class Keyboard(object):
def __init__(self):
super(Keyboard, self).__init__()
self.k = PyKeyboard()
def write(self,text):
self.k.type_string(text)
开发者ID:kmcnellis,项目名称:Rolling-Stone,代码行数:7,代码来源:controller.py
示例2: HIDremServerProtocol
class HIDremServerProtocol(com.LengthPrefixedReceiver):
"""The communication protocol."""
def setup(self):
self.k = PyKeyboard()
self.m = PyMouse()
def got_message(self, msg):
"""called when a message was received."""
if not msg:
return
idb, msg = msg[0], msg[1:]
if idb == common.ID_PING:
# echo message
self.send_message(idb + msg)
elif idb == common.ID_KEYBOARD:
action, keyname = msg[0], msg[1:]
if action == common.ACTION_PRESS:
self.k.press_key(keyname)
elif action == common.ACTION_RELEASE:
self.k.release_key(keyname)
else:
# protocol violation
self.close()
elif idb == common.ID_MOUSE:
pass
else:
# protocol violation
self.close()
开发者ID:bennr01,项目名称:HIDrem,代码行数:28,代码来源:HIDremServer.py
示例3: combo
def combo(*arg):
theCombo = arg[:-1]
theVelocity = arg[-1] # not used
k = PyKeyboard()
k.press_keys(theCombo)
开发者ID:jonathanlurie,项目名称:MidiCombo,代码行数:7,代码来源:keyboard.py
示例4: typeString
def typeString(s):
#m = PyMouse()
k = PyKeyboard()
#print args
#k.press_keys(args)
k.type_string(s)
开发者ID:jonathanlurie,项目名称:pythonStuff,代码行数:7,代码来源:keyboard.py
示例5: on_End_combo
def on_End_combo():
logging.info(30*'_' + " on_End_combo")
k = PyKeyboard()
#抬起功能按键Ctrl,否则End效果会变为Ctrl+End效果
k.release_key(k.control_key)
k.press_keys([k.end_key, ';', k.enter_key])
return False
开发者ID:gbwgithub,项目名称:g-py,代码行数:7,代码来源:hook_handler.py
示例6: on_End_analog
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
开发者ID:gbwgithub,项目名称:g-py,代码行数:7,代码来源:hook_handler.py
示例7: faceTracker
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()
开发者ID:bschmuck,项目名称:build18_2016,代码行数:33,代码来源:assistant.py
示例8: switch_to_highlayer
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
开发者ID:AlbertoBarraja,项目名称:svc_dash,代码行数:35,代码来源:client.py
示例9: xdomenu
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)
开发者ID:tulanthoar,项目名称:pygit,代码行数:29,代码来源:xmenu.py
示例10: Robot
class Robot(object):
def __init__(self):
self.mouse = PyMouse()
self.keyboard = PyKeyboard()
self.przyciskPSP2klawiatura = {'up': 'w', 'right': 'd', 'down': 's', 'left': 'a', 'triangle': self.keyboard.enter_key,
'circle': 'f', 'cross': 'g', 'square': 'h', 'l': self.keyboard.control_r_key, 'r': self.keyboard.shift_r_key, 'start': 'k', 'select': 'l'}
def reaguj(self, x, y, przyciskPSP2Stan):
self.reaguj_mysz(x, y)
self.reaguj_klawiatura(przyciskPSP2Stan)
def reaguj_mysz(self, x, y):
max_predkosc_kursora = 0.00000000000000000000000000000000000000000000000000001
x += int((x / float(128)) * max_predkosc_kursora +
self.mouse.position()[0])
y += int((y / float(128)) * max_predkosc_kursora +
self.mouse.position()[1])
x, y = min(self.mouse.screen_size()[0], x), min(
self.mouse.screen_size()[1], y)
x, y = max(0, x), max(0, y)
self.mouse.move(x, y)
def reaguj_klawiatura(self, przyciskPSP2Stan):
for przycisk_psp, czyWcisniety in przyciskPSP2Stan.iteritems():
przycisk_klawiaturowy = self.przyciskPSP2klawiatura[przycisk_psp]
if czyWcisniety == '1':
if przycisk_klawiaturowy == 'g':
self.mouse.click(*self.mouse.position())
break
self.keyboard.press_key(przycisk_klawiaturowy)
else:
self.keyboard.release_key(przycisk_klawiaturowy)
开发者ID:ILoveMuffins,项目名称:psp-rmt-ctrl,代码行数:33,代码来源:Robot.py
示例11: KLKeyboard
class KLKeyboard(object):
def __init__(self):
self.keyboard = PyKeyboard()
pass
def hitKey(self, key):
self.keyboard.tap_key(key)
开发者ID:chrisbenwar,项目名称:tappaio,代码行数:8,代码来源:klkeyboard.py
示例12: type_msg
def type_msg(string):
"""
Stimulates typing a string of characters
Args:
string (str) : A string of characters to enter
"""
k = PyKeyboard()
k.type_string(string)
开发者ID:boylea,项目名称:qtbot,代码行数:9,代码来源:robouser.py
示例13: run
def run(self):
# Set up the keyboard sim
K = PyKeyboard()
# Let the program start running
# Run till it's over.
if self.lines:
for i in lines:
K.type_string(str(i))
开发者ID:richardhob,项目名称:PythonWorks,代码行数:10,代码来源:KeyTest.py
示例14: keypress
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)
开发者ID:boylea,项目名称:qtbot,代码行数:12,代码来源:robouser.py
示例15: callSequence
def callSequence(*args):
m = PyMouse()
k = PyKeyboard()
print args
#k.press_keys(args)
#k.type_string(args[0])
keys = ["cmd", "a"]
#callArray(keys)
k.press_keys(keys)
开发者ID:jonathanlurie,项目名称:pythonStuff,代码行数:12,代码来源:test1.py
示例16: new_tab
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)
开发者ID:lucasgnavarro,项目名称:kamchatka-ws,代码行数:9,代码来源:peripheralUtils.py
示例17: close_tab
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)
开发者ID:lucasgnavarro,项目名称:kamchatka-ws,代码行数:9,代码来源:peripheralUtils.py
示例18: run
def run(self, some_input=[]):
# print("Run")
# How long to run for
counter = 0
# Remove "run" from the input
some_input.pop(0)
# Get the run number
for i in some_input:
if i == "cmd":
command(some_input)
elif i:
try:
counter = int(i)
except ValueError:
print("Value Error in Run")
pass
finally:
some_input.remove(i)
# If the counter didn't get defined.
if counter == 0:
counter = len(self.list_of_runs)
# NOW we can run. We should check the length of the
# command sequences, and the number of runs
i = 0 # times through
string = "" # string that will be printed
length = len(self.list_of_runs)
# Allow for 5 seconds to change windows
print("Please Change Windows Now.")
sleep(5)
some_keyboard = PyKeyboard()
# DO WORK YO
while i < counter and i < length:
string = self.list_of_runs.pop(0)
sys.stdout.write(string)
some_keyboard.type_string(string)
sleep(self.sleep_num)
i += 1
# Reset the variable if empty.
if not self.list_of_runs:
self.list_of_runs.append("")
开发者ID:richardhob,项目名称:PythonWorks,代码行数:49,代码来源:BS.py
示例19: keyboard
def keyboard(event):
if event.KeyID == 27:
key = PyKeyboard()
print "key1"
key.press_key(162) # ctrl
key.press_key(67) # c
key.release_key(67) # c
key.release_key(162) # ctrl
print "key2"
print event.KeyID
return True
开发者ID:xhyumiracle,项目名称:SyWorld,代码行数:11,代码来源:test.py
示例20: process_message
def process_message(in_msg, midi_to_shortcut):
""" processes message """
keyboard = PyKeyboard()
print(in_msg)
try:
if (in_msg.note, in_msg.channel) in midi_to_shortcut and in_msg.type != 'note_off':
shortcut = midi_to_shortcut[(in_msg.note, in_msg.channel)]
print('shortcut: ', shortcut)
for key in shortcut:
keyboard.press_key(key)
for key in shortcut:
keyboard.release_key(key)
except OSError:
print('note not recognized')
开发者ID:sebastianpfluegelmeier,项目名称:mitosho,代码行数:15,代码来源:mitosho.py
注:本文中的pykeyboard.PyKeyboard类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论