2021-05-08から1日間の記事一覧

PythonのPyAutoGUIで画面キャプチャを取得する

コマンドで画面キャプチャを取得するツールのscrotをインストールしておく必要がある $ sudo apt install scrot>>> import pyautogui 画面キャプチャを取得する >>> im = pyautogui.screenshot() >>> im <PIL.PngImagePlugin.PngImageFile image mode=RGB size=1366x768 at 0x7F310D68EFD0> >>> type(im) <class 'PIL.PngImagePlugin.PngImageFile'> >>> im.size (1366, 768) …</class></pil.pngimageplugin.pngimagefile>

PythonのPyAutoGUIでマウスの座標を取得する

>>> import pyautogui >>> pos = pyautogui.position() >>> pos Point(x=229, y=342) >>> type(pos) <class 'pyautogui.Point'> >>> pos[0] 229 >>> pos[1] 342 >>> pos.x 229 >>> pos.y 342</class>

PythonのPyAutoGUIでマウスを動かす

画面の座標(200, 100)にマウスカーソルを移動するプログラム 座標は左上が(0, 0) durationを小さくすると速く動く >>> import pyautogui >>> pyautogui.moveTo(200, 100, duration=0.5) 移動量を指定して動かすプログラム 今の位置から右にどれだけ下にどれ…

PythonのPyAutoGUIで画面サイズを取得する方法

>>> import pyautogui >>> wh = pyautogui.size() >>> wh Size(width=1366, height=768) >>> wh[0] 1366 >>> wh[1] 768 >>> wh.width 1366 >>> wh.height 768