《Python编程快速上手—让繁琐工作自动化》第18章

18.14.1 看起来很忙

import pyautogui,time

pyautogui.FAILFAFE = True

try:
    while True:
        time.sleep(5)
        pyautogui.moveRel(10, 10, duration=0.25)
        pyautogui.moveRel(-10, -10, duration=0.25)
except KeyboardInterrupt:
    print('Done')

即时通信机器人

import pyautogui as gui
import time, sys

gui.PAUSE = 0.2
picture = 'reciever.PNG'
text = 'Hello World!'

try:
    print('Locating the position...')
    gui.click(gui.locateCenterOnScreen(picture))
except TypeError:
    print('Fail to finding the position')
    sys.exit()
    
print('Ready for sending...')
gui.typewrite(text)

print('You have 5 seconds to check it before sending the message.\
Press CTRL-C to stop.')
try:
    time.sleep(5)
    gui.press('enter')
except KeyboardInterrupt:
    print('You have stop sending the message.')

print('Done')
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容