本文整理汇总了Python中pyautogui.typewrite方法的典型用法代码示例。如果您正苦于以下问题:Python pyautogui.typewrite方法的具体用法?Python pyautogui.typewrite怎么用?Python pyautogui.typewrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyautogui
的用法示例。
在下文中一共展示了pyautogui.typewrite方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: type
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def type(self, *keys_or_text):
'''Type text and keyboard keys.
See valid keyboard keys in `Press Combination`.
Examples:
| Type | separated | Key.ENTER | by linebreak |
| Type | Submit this with enter | Key.enter | |
| Type | key.windows | notepad | Key.enter |
'''
for key_or_text in keys_or_text:
key = self._convert_to_valid_special_key(key_or_text)
if key:
ag.press(key)
else:
ag.typewrite(key_or_text)
示例2: open_firefox
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def open_firefox():
# Printing basic message
msg(1,'Opening Firefox...')
# Location the start button
_start_button_=pyautogui.locateOnScreen('images/start_button.png')
_location_=pyautogui.center(_start_button_)
# Clicking the start button
if not pyautogui.click(_location_):
msg(1,'Opened start menu successfully!')
else:
msg(3,'Failed to open start menu!')
ext()
time.sleep(2)
# Search for Firefox in the menu search
pyautogui.typewrite('firefox')
pyautogui.typewrite('\n')
# Print message
msg(1,'Firefox is now open and running.')
# Function used to locate GMail
示例3: type_with_keys_down
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def type_with_keys_down(self, text, *keys):
'''Press keyboard keys down, then write given text, then release the
keyboard keys.
See valid keyboard keys in `Press Combination`.
Examples:
| Type with keys down | write this in caps | Key.Shift |
'''
valid_keys = self._validate_keys(keys)
for key in valid_keys:
ag.keyDown(key)
ag.typewrite(text)
for key in valid_keys:
ag.keyUp(key)
示例4: run
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def run(self):
"""Start running the test after a brief pause to allow
the window or dialog to show on the screen
"""
time.sleep(1.5)
pyautogui.typewrite(self.msg, self.interval)
示例5: locate_gmail
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def locate_gmail():
#Sleep for a while and wait for Firefox to open
time.sleep(3)
# Printing message
msg(1,'Opening Gmail...')
# Typing the website on the browser
pyautogui.keyDown('ctrlleft'); pyautogui.typewrite('a'); pyautogui.keyUp('ctrlleft')
pyautogui.typewrite('https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F<mpl=default')
pyautogui.typewrite('\n')
# Wait for a while until the website responds
time.sleep(6)
# Print a simple message
msg(1,'Locating the form...')
# Locate the form
pyautogui.press('tab')
time.sleep(2)
_gmail_ = pyautogui.locateOnScreen('images/gmail_form.png')
formx, formy = pyautogui.center(_gmail_)
pyautogui.click(formx, formy)
# Check and print message
if not pyautogui.click(formx, formy):
msg(1,'Located the form.')
else:
msg(3,'Failed to locate the form.')
ext()
# Function used to randomize credentials
示例6: generate_info
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def generate_info():
# Print message
msg(1,'Generating credentials...')
# First and last name
_first_name_=randomize('-l',7)
pyautogui.typewrite(_first_name_)
pyautogui.typewrite('\t')
_last_name_=randomize('-l',8)
pyautogui.typewrite(_last_name_)
pyautogui.typewrite('\t')
msg(2,'\x1b[0;33;40mName:\x1b[0m %s %s' % (_first_name_,_last_name_))
# Username
_username_=randomize('-l',10)
pyautogui.typewrite(_username_)
pyautogui.typewrite('\t')
msg(2,'\x1b[0;33;40mUsername:\x1b[0m %s' % _username_)
# Password
_password_=randomize('-p',16)
pyautogui.typewrite(_password_+'\t'+_password_+'\t')
msg(2,'\x1b[0;33;40mPassword:\x1b[0m %s' % _password_)
# Date of birth
_month_=randomize('-m',1)
_day_=randomize('-d',1)
_year_=randomize('-y',1)
pyautogui.typewrite(_month_+'\t'+str(_day_)+'\t'+str(_year_)+'\t')
msg(2,'\x1b[0;33;40mDate of birth:\x1b[0m %s/%d/%d' % (_month_,_day_,_year_))
# Gender (set to 'Rather not say')
pyautogui.typewrite('R\t')
msg(2,'\x1b[0;33;40mGender:\x1b[0m Rather not say')
# Skip the rest
pyautogui.typewrite('\t\t\t\t\n')
# Main function
示例7: run
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def run(self):
time.sleep(0.25) # NOTE: BE SURE TO ACCOUNT FOR THIS QUARTER SECOND FOR TIMING TESTS!
pyautogui.typewrite(self.msg, self.interval)
示例8: send_message
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def send_message(contact, message):
"""Sends message to an active slack contact
Args:
contact (str): contacts name on slack
message (str): message to send to friend
Returns:
None
"""
try:
print('5 seconds to navigate to slack app..')
time.sleep(5)
# Use JumpTo slack feature
pyautogui.hotkey('command', 'k')
time.sleep(1)
# Enter contact name in search box, click enter
pyautogui.typewrite(contact)
time.sleep(1)
pyautogui.typewrite(['enter'])
time.sleep(1)
active = pyautogui.locateOnScreen('active_identifier.png')
if not active:
print(f'{contact} is not active, skipped contact')
return
print('Contact is active, sending message...')
pyautogui.typewrite(['tab'])
pyautogui.typewrite(message)
pyautogui.typewrite(['enter'])
except KeyboardInterrupt:
print('Process was cancelled..')
示例9: auto_message
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def auto_message(name, message):
"""Searches for friend on Google Hangouts and messages them."""
print("Make sure the Google Hangout 'Conversations' page is visible and "
"your cursor is not currently on the page.")
time.sleep(3)
search_bar = pyautogui.locateOnScreen('search.png')
pyautogui.click(search_bar)
pyautogui.typewrite(name)
time.sleep(1)
online_select = pyautogui.locateOnScreen('online-friend.png')
if online_select is None:
print('Friend not found or currently offline.')
return
else:
pyautogui.doubleClick(online_select)
attempts = 3
while attempts > 0:
message_box = pyautogui.locateOnScreen('message.png')
pyautogui.click(message_box)
pyautogui.typewrite(message)
# If it can no longer be found it is because the message was entered.
if pyautogui.locateOnScreen('message.png') is None:
pyautogui.press('enter')
pyautogui.press('esc')
print('Message sent to {}'.format(name))
break
else:
if attempts == 1:
print('Unable to send message to {}.'.format(name))
pyautogui.press('esc')
else:
print('Sending message to {} failed. Another {} attempts will '
'be made before moving on.'.format(name, attempts))
attempts -= 1
示例10: type
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def type(text: Key or str = None, modifier=None, interval: int = None):
"""Keyboard type.
:param text: String or Key pressed
:param modifier: Key modifier.
:param interval: The number of seconds in between each press. By default it is 0 seconds.
:return: None.
"""
if modifier is None:
if isinstance(text, Key):
logger.debug("Type Method: [Reserved key: {}]".format(text))
key_down(text)
key_up(text)
time.sleep(Settings.key_shortcut_delay)
else:
if interval is None:
interval = Settings.type_delay
logger.debug("Type Method: [Text: {}]".format(text))
pyautogui.typewrite(text, interval)
else:
from moziris.api.keyboard.keyboard_util import get_active_modifiers
modifier_keys = get_active_modifiers(modifier)
num_keys = len(modifier_keys)
logger.debug(
"Type Method: [Modifiers ({}): {}] + [Text: {}]".format(
num_keys, " ".join(key.name for key in modifier_keys), text
)
)
if num_keys == 1:
key_down(modifier_keys[0])
time.sleep(Settings.key_shortcut_delay)
key_down(text)
time.sleep(Settings.key_shortcut_delay)
key_up(text)
time.sleep(Settings.key_shortcut_delay)
key_up(modifier_keys[0])
elif num_keys == 2:
key_down(modifier_keys[0])
time.sleep(Settings.key_shortcut_delay)
key_down(modifier_keys[1])
time.sleep(Settings.key_shortcut_delay)
key_down(text)
time.sleep(Settings.key_shortcut_delay)
key_up(text)
time.sleep(Settings.key_shortcut_delay)
key_up(modifier_keys[1])
time.sleep(Settings.key_shortcut_delay)
key_up(modifier_keys[0])
else:
logger.error("Returned key modifiers out of range.")
if Settings.type_delay != Settings.DEFAULT_TYPE_DELAY:
Settings.type_delay = Settings.DEFAULT_TYPE_DELAY
示例11: __call__
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import typewrite [as 别名]
def __call__(self):
args = [self.exe, "--user", self.user]
if not self.netplay:
args += ["--exec", self.iso]
if self.movie is not None:
args += ["--movie", self.movie]
print(args)
process = subprocess.Popen(args)
if self.netplay:
import time
time.sleep(2) # let dolphin window spawn
import pyautogui
#import ipdb; ipdb.set_trace()
pyautogui.click(150, 150)
#pyautogui.click(50, 50)
time.sleep(0.5)
pyautogui.hotkey('alt', 't') # tools
time.sleep(0.5)
pyautogui.hotkey('n') # netplay
time.sleep(1) # allow netplay window time to spawn
#return process
#pyautogui.hotkey('down') # traversal
#for _ in range(3): # move to textbox
# pyautogui.hotkey('tab')
#pyautogui.typewrite(self.netplay) # write traversal code
#return process
time.sleep(0.1)
# connect
#pyautogui.hotkey('tab')
pyautogui.hotkey('enter')
#import ipdb; ipdb.set_trace()
return process