LoginSignup
0
0

Autokey フレーズとタスクのツール

Last updated at Posted at 2023-09-24
  • Linux Mint21.1
  • Python3

すべてが書かれいます。

AutoKeyについて

  • Wikipedia 翻訳
AutoKey を使用すると、ユーザーはホットキーとトリガー フレーズを定義して、
事前定義されたテキストに展開することができ、タイプミスや一般的なスペルミスの修正やテキストの定型セクションの挿入など、頻繁または反復的なタスクを自動化できます。

AutoKeyの2つの機能を持ちます。

変更したとき、Saveを忘れないこと。

テキスト置換

テキストエディタなどでユーザが、あらかじめ決めてある単語を入力します。
エンターキーを押下した時、登録していたテキスト文に置換してくれます。
Auto01.png

プログラミング

通常はAutokeyメニューから起動します。

  • Windowの指定は次を指定します。
window.activate('Thunar.Thunar', switchDesktop=True, matchClass=True)

サンプル Display Window infoを実行する。Classが実行しているWindowになります。

Active window information:
Title: 'Pictures'
Class: 'Thunar.Thunar'
  • 回数指定
prompt="Please..."
retCode, userInput = dialog.input_dialog(title="Input required", message=prompt, default="example")
  • マウスの座標

ターミナルからxdotoolを実行します。

xdotool getmouselocation

サンプルコード

ファイルマネージャーの複数のタブの操作

# Enter script code
# Active window information:
# Title: 'Downloads'
# Class: 'Thunar.Thunar'
#

window.activate('Thunar.Thunar', switchDesktop=True, matchClass=True)

keyboard.send_keys("<ctrl>+l")
keyboard.send_keys("/home/bomiura/Downloads/")
keyboard.send_keys("<enter>")

keyboard.send_keys("<ctrl>+t")
keyboard.send_keys("<ctrl>+t")
keyboard.send_keys("<ctrl>+t")

# Dvice
# mouse buttons: left=1, middle=2, right=3
mouse.click_absolute(60, 450, 1)
time.sleep(1.0)

#
# x:54 y:376 screen:0 window:21070347 
mouse.click_absolute(73, 264, 1)

Firework 複数のダウンロード

# Enter script code

# Enter script code
#Active window information:
#Title: 'Search | Hitomi.la — Mozilla Firefox'
#Class: 'Navigator.firefox'

window.activate('Navigator.firefox', switchDesktop=True, matchClass=True)

prompt="Please..."
# Ask for input, offer a default example, and check the exit code of the command:
retCode, userInput = dialog.input_dialog(title="Input required", message=prompt, default="example")

a = int(userInput)

for i in range(a):
    keyboard.send_keys("<ctrl>+<page_down>")
    keyboard.send_keys("<ctrl>+f")
    time.sleep(1.0)
    keyboard.send_keys("Download")
    keyboard.send_keys("<enter>")
    time.sleep(1.0)
    keyboard.send_keys("<escape>")
    keyboard.send_keys("<enter>")
0
0
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
0
0