2

xdotool click --clearmodifiers 3 works as right-click in firefox and chromium-browser, but not in all programs such as Thunar file manager and xfce4-terminal. Why is that?

In terminal, if I run the command by entering it there, context menu appears, but if I run the command by keyboard shortcut (set in Xfce's keyboard settings), it does not work.

Anyway, shift + F10 seems to work (though I have to use Fn key in my Macbook keyboard).

jarno
  • 5,600

1 Answers1

2

xdotool simulates you moving or clicking the mouse, or pressing the keyboard. You trigger the xdotool script with the keyboard, but before you are releasing the key, xdotool already issues the mouse click. For some situations, xdotool may be too fast. The precise reason why it sometimes works, the other time not, is probably only to be found out by experts.

Anyway, try introducing a few ms delay by prepending the xdotool command with a sleep command, e.g.

sleep 0.2 && xdotool click --clearmodifiers 3

would introduce a 200 ms delay before executing the xdotool command.

vanadium
  • 88,010
  • In this case xdotool simulates mouse event. – jarno Jan 13 '19 at 14:22
  • I still do not understand why it does not work without the delay with all applications, but anyway the main thing is that I can make it work now. – jarno Jan 13 '19 at 14:28
  • +1 can confirm this. Related: This older answer also suggested a workaround to add delay for making xdotool work properly in Unity/Compiz (cause not known). So not just Xfce issue apparently. –  Jan 13 '19 at 16:53
  • Understand or not: computers are complex systems. Input may not yet be registered if something else is busy, which is why mouse movements and keystrokes are not coming through if not issued on the right moment. I changed my answer because indeed your question is on mouse input. The principle remains, however. – vanadium Jan 13 '19 at 17:23
  • The command seems to corrupt mouse: Bug – jarno Jan 18 '19 at 09:58
  • Many thanks for this post. Using xdotool to emulate the middle button on an Nvidia Jetson (uses LXDE) required nearly one second delay to get reliable behavior and avoid this erratic bug. This approach to generating the middle button was necessary when using a Microsoft "all in one" keyboard which inhibits 1+3 clicks , preventing "emulate3buttons" with Xorg. – Greg Mar 27 '22 at 02:06