Thank you very much for xdotool. This is my first post to the list.
Background:
One of my users was running XP 32-bit (on hardware). Amongst other
packages he needs Microsoft Office. Although the user of the machine
was happy enough with Windows XP, his browsing habits left the machine
at risk from malicious software and I was very bored with reinstalling
Windows whenever it was 0wn3d, which was almost every week.
To prevent damage caused by browser-induced malware, I decided to
install Linux (Debian Squeeze) on my careless user's hardware. The
user needs Microsoft Office, so I installed Windows 7 (64-bit) under
VirtualBox. Even if Windows does yield to an attack, it's trivial to
recover a VirtualBox snapshot, but Windows 7 64-bit may not have been
the best choice I ever made...
The user has an old and much-loved Microsoft Office Keyboard, and it
turns out that there are known issues with this old keyboard and
Windows 7. For about two weeks I struggled to get three of the keys
to work with Microsoft Office, running on Windows 7 64-bit, running on
VirtualBox, running on X, running on Linux. :/
In desperation I turned to xbindkeys and xdotool. It sort of worked,
but I found that my first attempt would result effectively with a
control key combination (at least for CTRL-C) 'stuck down'. I had to
press and release the control and C keys on the keyboard to stop the
repeating keypresses. This also left the keyboard in a bemused state,
with (e.g.) the arrow keys no longer functioning properly, and a few
more keypresses or sometimes a '/usr/bin/reset' were necessary before
these keys regained their usual function. The 'backspace' key seemed
to be more effective than some in this recovery process but I haven't
delved deeply into the issue.
As well as xdotool 'key' commands I tried 'keydown', 'keyup' and even
a few 'type' commands, and I tried setting a --delay to progressively
longer and longer values; I even replaced the Debian supplied version
of xdotool (20100302) with the latest version (20110530 -- and that's
another story :) but that didn't help either. I didn't get anywhere
until after hitting the search engines I came across this post:
This gave me the idea of adding a --delay 0 option. Rather to my
surprise, that worked. I had finally managed to translate the 'Cut',
'Copy' and 'Paste' keys on the Microsoft Office Keyboard to 'Ctrl-X',
'Ctrl-C' and 'Ctrl-V' using xbindkeys and xdotool. The xbindkeys
configuration file is below. Easy when you know how.... :)
8<---------------------------------------------------
"xdotool key --clearmodifiers --delay 0 Control_L+X"
release + c:145
"xdotool key --clearmodifiers --delay 0 Control_L+C"
release + c:141
"xdotool key --clearmodifiers --delay 0 Control_L+V"
release + c:143
8<---------------------------------------------------
Have I missed the explanation for the apparent 'stuck keys'?
--
73,
Ged.