PDA

View Full Version : [SOLVED] how to send a keycode to X?



iBART
May 1st, 2012, 06:21 PM
source of discussion: http://ubuntuforums.org/showthread.php?p=11894568#post11894568

how to send a keycode to X?

12.04 here! thanks :)

iBART
May 2nd, 2012, 06:56 AM
up? :(

LewisTM
May 2nd, 2012, 01:45 PM
Install xdottool
Then execute for example

xdotool key F5
Done!

iBART
May 3rd, 2012, 01:22 PM
thanks but i need to "send" F5 to desktop to refresh it but xdotool sends "F5" to... itself! :(

LewisTM
May 3rd, 2012, 02:00 PM
Well it depends what captures the key and which application is focused when invoking the command. Are you using this as a keyboard shortcut?

What could help you switch to the target window is wmctrl.
A command like this would call the command interpreter, switch to the desktop, wait a fraction of a second for it to come into focus, and send an F5.

sh -c "wmctrl -a Desktop && sleep 0.1 && xdotool key F5"

iBART
May 3rd, 2012, 04:28 PM
worked! thanks man. i added it to startup :)