How to make a keybind involving xdotool in Openbox

openbox

I'm running Openbox 3.5.2 (on Lubuntu 13.10) by logging into Openbox session.

In an Openbox session, if I run xdotool mousemove 1000 5 click 3 from a terminal, the mouse cursor moves to the specified blank position on the desktop; then a mouse right-click is executed to open the right-click menu of Openbox.

So I made the following keybind in ~/.config/openbox/rc.xml:

<keybind key="W-space">
  <action name="Execute">
    <command>xdotool mousemove 1000 5 click 3</command>
  </action>
</keybind>

and reconfigured Openbox. But when I press super+spacebar all I see is that the mouse cursor moves to the designated position; the right-click menu doesn't appear.

How can I cause the right-click menu to appear?

Best Answer

You should try and wait until the mousemove has completed, sometimes things get out of sync if your system is slow. You can put in a delay ( with sleep or xdotool's own --delay. That always delays and slows down things. You should therefore first try:

xdotool mousemove --sync 1000 5 click 3

As --sync doesn't wait if nothing needs to be done. If that doesn't help you can alwasy put in an extra delay with sleep:

xdotool mousemove --sync 1000 5
sleep 0.2
xdotool click 3
Related Question