6
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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

Last updated at Posted at 2021-05-04

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")

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

#参考
https://qiita.com/Ringa_hyj/items/db9adbe6afdc77d24bff

6
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?