Fork me on GitHub

Herr Knedel/ショートストーリー:xDoToolsとxClipによるデスクトップコントロール

Created Sun, 04 Apr 2021 00:00:00 +0000 Modified Sat, 02 Apr 2022 15:19:26 +0000 Schwierigkeitsgrad: Es kann etwas länger dauern

311 Words

このチュートリアルでは、Bashを使用してLinux - デスクトップを制御する方法を紹介します。Bashロボットに必要なパッケージは以下の通りです。

x
+
Terminal

$ apt-get install xdotool xclip

その後、例えば、すべての xdotool コマンドを使用することができます。

#!/bin/bash

#mouse bewegen
xdotool mousemove 100 200 

#Mouse - Koordinaten erfassen
xdotool getmouselocation 

#Mouse-klick
xdotool click 1 

Mouse-Klick auf Koordinaten
xdotool mousemove 100 200 click 1 

#usw...

次の例では、Firefoxのウィンドウを検索して、Ubuntuのアドレスで新しいタブを開いています。

WID=$(xdotool search firefox | head -n1)     ## Window-ID von Firefox ermitteln
xdotool windowactivate $WID
xdotool key "ctrl+t"                         ## neuen Reiter öffnen
xdotool key "ctrl+l"                         ## Fokussieren der Adressleiste
xdotool type --delay 100 "ubuntuusers.de"    ## Internetadresse eintippen
xdotool key "Return"                         ## Internetadresse aufrufen 

なぜxclipが必要なのか?

xdotools/“ctrl c “でキャッシュに内容をコピーし、bashスクリプトのxclipで読み込んだり処理したりすることができます。