Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
15
Help us understand the problem. What is going on with this article?
@TTOM

Pythonのpyautoguiを使ったGUI操作の自動化(はじめの一歩)

pyautogui はマウスの位置,クリック,キーボード入力などができる.さらに画像マッチングによりアイコンの位置を取得できる.
pyperclipはクリップボードに文字列を入力できる.

サンプルコード

hello_autogui.py
import pyautogui as pg
import pyperclip as pc
import time
#for i in range(1,100):
posx,posy = pg.position()
print(posx,posy)
time.sleep(0.01)
#pg.click(x=posx, y=posy, button="left")
#pg.typewrite("hello pyautogui!")
#pg.hotkey("ctrl","a")
#pg.hotkey("ctrl","c")
#pg.hotkey("ctrl","v")
#pg.hotkey("ctrl","v")
#pg.hotkey("Enter")
#pc.copy("どうもこんにち は!")
#pg.hotkey("ctrl","v")


# #image process
img = "target.png"
sc = pg.screenshot()
sc.save("sss.png")
locx, locy = pg.locateCenterOnScreen(img)
print(locx,locy)
pg.click(x=locx, y=locy, button="right")

さて何につかおうか...

参考

15
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
TTOM

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
15
Help us understand the problem. What is going on with this article?