本文整理汇总了Python中pykeyboard.PyKeyboard.type_string方法的典型用法代码示例。如果您正苦于以下问题:Python PyKeyboard.type_string方法的具体用法?Python PyKeyboard.type_string怎么用?Python PyKeyboard.type_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykeyboard.PyKeyboard
的用法示例。
在下文中一共展示了PyKeyboard.type_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: typeString
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
def typeString(s):
#m = PyMouse()
k = PyKeyboard()
#print args
#k.press_keys(args)
k.type_string(s)
示例2: sendMessage
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
def sendMessage(message):
if Var.locked:
return
if not (type(message) is str):
try:
message = str(message)
except Exception:
pass
try:
message = message.encode('ascii', 'ignore')
except Exception:
message = message.encode('utf-8', 'ignore')
Var.locked = True
k = PyKeyboard()
try:
k.type_string(message)
except Exception:
k.press_key(k.control_l_key)
k.tap_key('A')
k.release_key(k.control_l_key)
k.tap_key(k.backspace_key)
k.type_string("Message Contains Unknown Characters")
k.tap_key(k.enter_key)
Var.locked = False
示例3: Keyboard
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
class Keyboard(object):
def __init__(self):
super(Keyboard, self).__init__()
self.k = PyKeyboard()
def write(self,text):
self.k.type_string(text)
示例4: type_msg
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
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)
示例5: run
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
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))
示例6: run
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
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("")
示例7: main
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
def main():
#Get an instance of PyKeyboard, and our custom PyMouseEvent
keyboard = PyKeyboard()
mouse = AbortMouse()
input('Press Enter when ready.')
print('Typing will begin in {0} seconds...'.format(opts['--pause']))
time.sleep(opts['--pause'])
mouse.start()
with open(opts['<file>'], 'r') as readfile:
for line in readfile:
if not mouse.state:
print('Typing aborted!')
break
keyboard.type_string(line, opts['--interval'])
示例8: type_unicode
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
def type_unicode(symbol):
k = PyKeyboard()
hexval = symbol.encode("unicode_escape")
print hexval
if hexval[:2] == '\u': # if the value is a hex number
k.press_key('Control_L') # press the control
k.press_key('Shift_L') # the left shift
k.tap_key('u') # and the u key
k.release_key('Control_L') # release the control
k.release_key('Shift_L') # and shift keys
hexval = hexval[2:] # remove the unicode escape character
k.type_string(hexval) # type the unicode string
k.tap_key('Return') # tap the return key
else: # if the given string isnt a unicode character
k.type_string(hexval) # just type the string
示例9: pLabel
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
def pLabel(pep,spec,gene,row_no):
m = PyMouse()
k = PyKeyboard()
# ALL button
m.click(1243,204)
sleep(2)
m.click(362,762)
sleep(1)
m.click(362,762)
sleep(0.3)
m.click(362,762)
sleep(1)
for n in range(30):
k.press_key(k.backspace_key)
sleep(1)
k.type_string(spec)
sleep(1)
k.press_key(k.enter_key)
sleep(1)
capture(pep,spec,gene,row_no,0)
sleep(1)
m.click(609,182)
sleep(1)
# peptide
m.click(132,728)
sleep(1)
m.click(132,728)
sleep(0.3)
m.click(132,728)
sleep(1)
k.press_key(k.backspace_key)
sleep(1)
k.type_string(pep)
sleep(1)
k.press_key(k.enter_key)
sleep(1)
capture(pep,spec,gene,row_no,1)
sleep(1)
示例10: main
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
def main():
"""
Retrieves the ID of the attached Card and returns it as keyboard-presses
"""
while True:
try:
# define the apdus used in this script
apdu = [0xFF, 0xCA, 0x00, 0x00, 0x00]
# request card insertion
card_request = CardRequest(timeout=None, cardType=AnyCardType(), newcardonly=True)
card_service = card_request.waitforcard()
# connect to the card and perform a few transmits
card_service.connection.connect()
response, sw1, sw2 = card_service.connection.transmit(apdu)
rfid_string = '_'.join([str(id_val) for id_val in response])
keyboard = PyKeyboard()
keyboard.type_string('<U>RFID_ID_'+rfid_string)
except:
continue
示例11: runScript
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
def runScript(delay, SCRIPT_PATH, SCRIPT_NAME):
screen = wnck.screen_get(0)
#screen = wnck.screen_get_default()
while gtk.events_pending():
gtk.main_iteration()
windowTitle = re.compile('.*Board.*')
for window in screen.get_windows():
if windowTitle.match(window.get_name()):
window.activate(int(time.time()))
window.maximize()
#MOUSE CLICK TO ACTUALLY FOCUS EAGLE BOARD
m = PyMouse()
x, y = m.screen_size()
#m.click(x/4, y/4, 1)
#KEYBOARD INPUT
k = PyKeyboard()
caps_flag = 0
if int(commands.getoutput('xset q | grep LED')[65]) % 2:
k.tap_key(k.caps_lock_key)
caps_flag = 1
#BRING UP ALT-FILE MENU
k.press_key(k.alt_key)
k.type_string('f')
k.release_key(k.alt_key)
#PRESS T TO RUN SCRIPT FROM ALT-FILE MENUs
k.type_string('t')
time.sleep(delay)
#TYPE IN SCRIPT NAME TO DIALOG BOX
k.type_string(SCRIPT_PATH + SCRIPT_NAME)
time.sleep(delay)
time.sleep(delay)
k.tap_key(k.enter_key)
if caps_flag:
k.tap_key(k.caps_lock_key)
示例12: runScript
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
def runScript(delay, SCRIPT_NAME):
#screen = wnck.screen_get_default()
screen = wnck.screen_get(0)
while gtk.events_pending():
gtk.main_iteration()
windowTitle = re.compile('.*Board.*')
for window in screen.get_windows():
if windowTitle.match(window.get_name()):
window.activate(int(time.time()))
window.maximize()
#MOUSE CLICK TO ACTUALLY FOCUS EAGLE BOARD
m = PyMouse()
x, y = m.screen_size()
#m.click(x/4, y/4, 1)
#KEYBOARD INPUT
k = PyKeyboard()
#BRING UP ALT-FILE MENU
k.press_key(k.alt_key)
k.type_string('f')
k.release_key(k.alt_key)
#PRESS T TO RUN SCRIPT FROM ALT-FILE MENU
k.type_string('t')
time.sleep(delay)
#TYPE IN SCRIPT NAME TO DIALOG BOX
k.type_string('/home/anton/Documents/st/st-py/' + SCRIPT_NAME)
time.sleep(delay)
time.sleep(delay)
k.tap_key(k.enter_key)
示例13: range
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
print " [email protected]@@0o. [email protected]@@0o."
time.sleep(0.02)
print " [email protected]@@@0o.. [email protected]@@@0."
time.sleep(0.02)
print " [email protected]@@@0oo.. [email protected]@@@00o."
time.sleep(0.02)
print " [email protected]@@@@[email protected]@@@@00o."
time.sleep(0.02)
print " [email protected]@@@@@@@@@@@@@@@@@@@000oo."
time.sleep(0.02)
print " ...oooooooooooooo..."
for i in range(rows):
time.sleep(0.03)
print ""
k.type_string('htop -d 50')
time.sleep(0.1)
k.tap_key('Return')
time.sleep(0.01)
k.press_keys(['Alt_L', '\\'])
time.sleep(0.1)
k.press_keys(['Alt_L', 'h'])
time.sleep(0.01)
k.press_keys(['Alt_L', '-'])
time.sleep(0.1)
k.type_string('mutt')
time.sleep(0.01)
k.tap_key('Return')
time.sleep(0.01)
k.press_key('Alt_L')
k.tap_key(character='Up', n=8)
示例14: range
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
time.sleep(0.1)
m.click(x_dim / 2, y_dim / 2, 1)
time.sleep(0.1)
k.press_key(k.alt_key)
time.sleep(0.1)
k.tap_key(k.tab_key)
time.sleep(0.1)
k.release_key(k.alt_key)
time.sleep(0.1)
for _ in range(50):
m.click(x_dim * 0.95, y_dim / 2, 1)
time.sleep(0.1)
k.press_key(k.control_key)
time.sleep(0.1)
k.type_string("a")
time.sleep(0.1)
k.release_key(k.control_key)
time.sleep(0.1)
k.press_key(k.control_key)
time.sleep(0.1)
k.type_string("c")
time.sleep(0.1)
k.release_key(k.control_key)
time.sleep(0.1)
k.press_key(k.alt_key)
time.sleep(0.1)
k.tap_key(k.tab_key)
time.sleep(0.1)
k.release_key(k.alt_key)
time.sleep(0.1)
示例15:
# 需要导入模块: from pykeyboard import PyKeyboard [as 别名]
# 或者: from pykeyboard.PyKeyboard import type_string [as 别名]
k.press_key(k.control_key)
k.tap_key('t')
k.release_key(k.control_key)
# Getting an element where Keys can be passed
# Opening a NEW TAB
browser.get('http://hck.re/qcKgO4')
time.sleep(11)
m.click(598L,798L,1,1)
mail='monkeydluffy'+str(i)+'@superrito.com'
k.type_string(mail)
k.tap_key(k.return_key)
time.sleep(15)
m.click(444L,378L,1,1)
m.click(654L,514L,1,1)
m.click(723L,641L,1,1)