Skip to content

Instantly share code, notes, and snippets.

@skyrocknroll
Last active January 6, 2023 11:01
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save skyrocknroll/5319172 to your computer and use it in GitHub Desktop.
Save skyrocknroll/5319172 to your computer and use it in GitHub Desktop.
screenshot linux automation , xdotool , xwininfo
#!/usr/bin/python
import subprocess
subprocess.call(["sh","./screenshot.sh","11","www.canvera.com"])
#!/bin/bash
#Start a xserver using vncserver
#vncserver :$1 -geometry 1024x768 -SecurityTypes None
#xserver is running at $1
#Start firefox in the $1 vncserver window
#firefox --display=:$1 &
DISPLAY=:$1 #Connect to the another xserver
#xdotool search "Mozilla Firefox" windowactivate --sync
WID=`xdotool search --name "Mozilla Firefox" | head -1`
xdotool windowactivate $WID
echo $WID
xdotool key ctrl+l
xdotool type $2
xdotool key Return
sleep 5
#xdotool key Page_Down # To handle floating footer . May need to send some more Page_Down
#sleep 1
xdotool key shift+F2
#Following command will take full page including the part which is not right now displayed
#xdotool type "screenshot /home/yuva/hobby/$2.img --fullpage"
#Take only what is shown in the page
xdotool type "screenshot /home/yuva/hobby/$2.img"
echo "done screenshot"
xdotool key Return
xdotool key shift+F2
@DenverChess
Copy link

Cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment