日曜日, 3月 29, 2009

"SendKeys" equivalent in Linux(シリーズⅡ)

Good article title Position active window using xwininfo and wmctrl


  • send a named key combination to X using strings
    xsendkeys(Source)
  • get a LIST of all windows needed
    xprop -root grep "_NET_CLIENT_LIST(WINDOW)"
  • Get specified window information
    xwininfo -id {{{Just_previously_aquired_Window-ID}}}
  • raise a window and give it focus
    wmctrl -a


Code Sample

import time
import subprocess
time.sleep(5)
subprocess.Popen(["gksudo", "nautilus"]); #could be more interesting
time.sleep(5)
subprocess.Popen(["xsendkeys", '"p+p+a+s+s+w+o+r+d+Return+Return"'])

0 件のコメント: