Fork me on GitHub

Herr Knedel/Krótka historia: Sterowanie pulpitem za pomocą xDoTools i xClip

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

147 Words

W tym poradniku pokazuję, jak kontrolować pulpit systemu Linux za pomocą Basha. Do działania robota Bash potrzebne są następujące pakiety:

x
+
Terminal

$ apt-get install xdotool xclip

Następnie można używać wszystkich poleceń xdotool, np:

#!/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...

W poniższym przykładzie okno przeglądarki Firefox jest przeszukiwane i otwierana jest nowa karta z adresem 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 

Po co Ci xclip???

Za pomocą narzędzia xdotools/“ctrl c” można kopiować zawartość do pamięci podręcznej i odczytywać lub przetwarzać ją za pomocą xclip w skrypcie basha.