------------------------------------------------------------------------------- XDoTool Notes... Examples of using it to automate things ------------------------------------------------------------------------------- Search and delete mail from outlook in a chrome window Outlook only deletes 75 mails at a time! Which makes it very time consuming to delete thousands of mails. This repeats a search, and delete, action... Using whatever folder & search you have setup... The delays is to allow the search to finish, AND to give opptunity to move pointer, so as to kill the command, when it is finished. id=$(xwin_find 'Mail - .*') && echo "Window at $id" repeat 100 xdotool \ mousemove -window $id 500 100 click 1 sleep 0.1 key Return \ sleep 2 \ mousemove -window $id 250 170 click 1 sleep 0.3 key Return \ sleep 3 ------------------------------------------------------------------------------- Automated Minecraft Crafting (bamboo to sticks)... Example use of "visgrep" to locate what to click... and the ability to move the mouse relative to a specific window. In this case look for a 'stick' image on left, move to it & shift-click it. Now look for the 'craft it' stick image, and move-to/shift-click it. The image was previously extracted, with the top left corner 'clickable'. See https://antofthy.gitlab.io/info/apps/visgrep.txt for more on "visgrep". NOTE: "xwin_find" is a script to find the minecraft window (using "xwininfo"). See https://antofthy.gitlab.io/software/#xwin_find https://antofthy.gitlab.io/info/X/WindowID.txt =======8<--------CUT HERE---------- #!/bin/bash # # mc_make_sticks # # The program assumes 'wood planks' have been removed from inventory, and we # are in a expanded crafting mode, when a hot key executing this is pressed. # # It should be attached to a 'hotkey' that the user can press. id=$( xwin_find 'Minecraft.*' ) xdotool mousemove -window $id 10 10 # move into window # While sticks are found do... while true; do # First first Stick on left image_cmd="convert x:$id -crop 50x50%+0+0 +page png:24:-" position=$( visgrep <(image_cmd) $PROGDIR/mc_stick.png | head -n1 ) # check we found a stick if [[ -z $position ]]; then notify_message "no sticks found" exit 1 fi read x y z <<<${position/,/ } xdotool mousemove -window $id $x $y \ sleep 0.1 keydown Shift click 1 keyup Shift sleep 0.5 # That stick is now covered by a label (mouse over) # so find the next first stick (execute trade) and shift click it options="-crop 100x50%+0+0 +page -depth 8" position=$( visgrep <(convert x:$id $options png:-) $PROGDIR/mc_stick.png | head -n1 ) # check we found a stick if [[ -z $position ]]; then notify_message "no sticks found" exit 1 fi read x y z <<<${position/,/ } xdotool mousemove -window $id $x $y \ sleep 0.1 keydown Shift click 1 keyup Shift sleep 0.3 done =======8<--------CUT HERE---------- If the above is looped, we can preserve the location of the second 'craft' image, and not search for it after the first time. A more complex crafting methd could look for stacks of bamboo in the inventory, and move them to the crafting area, rather than rely on crafting recipe. This can avoid problems with the recipe, like it trying to make sticks from something else, like wood planks. Also if we can crop the area of the window for search, then adjust the mouse move (adding the image crop info), it can be made even LOT faster. -------------------------------------------------------------------------------