How can I move application windows using Autokey?

Question:

I’m attempting to resize and relocate various windows I use for work using Autokey to make my morning a little faster. From what I’ve googled, Autokey uses python to run its scripts. I’ve also seen half a dozen programs that could do the job for me, but I’m trying to do this with only the tools I have available to me.

I don’t necessarily need it spelled out to me. Any direction to the right documentation would help, or a link to a similar script. I’m currently running fedora 20, and open my windows with a little shell script:

google-chrome "http://google.com/"&
google-chrome  "http://leafdns.com/"&
pidgin&
konsole --noclose -e &
autokey-gtk&
gedit "test"&

As far as I can tell, there’s nothing I can do in this shell script that can handle window movement.

Asked By: Azord

||

Answers:

I believe wmctrl is what you’re looking for. An example using gedit and a script to get the window id:

gedit --new-window &
sleep 1
get_window_id gedit
wmctrl -i -r "$window_id" -e 0,1025,0,953,1000

(example pulled from here, which also shows you how to create the get_window_id script)

To understand how to get the window id, run the following

wmctrl -l

You will get a list of all detected windows and their names (some will be named by the program’s actual name, but not all; in Google Chrome’s case it is the name of the currently open website, at least for me)

The first value (something like 0x03a00006) is the window’s id. It might not be the easiest solution, but it is one. As for how to invoke it through python, read up on system commands here.

The alternatives to wmctrl would have to be either xdotool or xprop, but I doubt they would be any easier to operate. You can also look into tiling window management, which might be a good alternative to all this trouble.

Answered By: Cestarian

this online manual describes the resize_move command:

resize_move(self, title, xOrigin=-1, yOrigin=-1, width=-1, height=-1, matchClass=False)

( https://autokey.github.io/lib.scripting.Window-class.html )

i use it into autoKey like so ( a example ):

window.resize_move('0 A.D.', xOrigin=1908, yOrigin=-27, width=1922, height=1089, matchClass=False)
Answered By: SL5net
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.