Win32::Shortkeys - A shortkeys perl script for windows
my $s = Win32::Shortkeys->new("kbhook.properties");
Depending on the the sorkeys.xml file, some keystroke are replaced with string or keys command (enter, tab, cursor right ...) taken from this file.
Since the synopsis above is short, the main things to describe are in the file pass to Win32::Shortkeys-new($file)>.
It must follow the Config::YAML::Tiny syntax. Mine looks like
The key given in the load_key property is used to reload the shorkeys.xml file (without exiting the script). The key given in the quit_key property is used to terminate the script.
It's name is given by the file_path property. It's xml syntax is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE shortkey SYSTEM "dtd/shk.dtd">
<data k='t'>Recent advances in biochemical and molecular diagnostics for the rapid detection of antibiotic-resistant Enterobacteriaceae: a focus
<data k='j'>Expert Review of Molecular Diagnostics
The values of the k attribute are a-z string composed of lower case character(s) (a string can have two or more characters). I call those strings shortkeys and when press on the keyboard after they < key with the script running, the key pressed are replaced by the content of the corresponding data element.
For example, with the cursor in an opened notepad file, hitting the two keys <j when the script is running will replace this two characters with the value of the corresponding <data> element: Expert Review of Molecular Diagnostics.
The shortkeys.xml file should be utf-8 encoded, even if the encoding can be defined in the properties.
With the key <, the script enter a "search mode" for a shortkey sequence. This key is hard coded and can't be changed (unless you edit the code).
The text from the shortkeys file is sent to the keyboard using the send_input API function. With using the use.ctrl_v='1' attribute in a data element, the text will be place in the clipboard and paste (with sending the keys ctlr + v) at the cursor position.
<data k= 'a' use.ctrl_v= '1'>
This text will be copied and paste.
And the new line will be preserved.
In the xml file, data elements can be combine using a dataref element.
<data k= 'u'>
Published version; http://dx.doi.org/<dataref id= 'qu'></dataref>
When hitting <u, the text that will be subtitued will be Published version; http://dx.doi.org/10.1080/14737159.2017.1289087
a command keystroke start with # (to diplay # as a character, it has to be enter has ##), next you have to give
the command itself, set by a character (only one character) listed in the map defined with the property vkcode_map
The character z is hardcoded to indicate a waiting time : in the shortkeys_utf8.xml file #z04 will calls the code
usleep ( 4 * 100_000 );
If z is used to indicate a key in vkcode_map, this will be overriden.
how much you want to repeat that command, on two position, with a padding 0 if necessary (01)
the next characters are treated as text (unless a new command keystroke is defined with #)
The shift, control and alt keys are released
after a non-command key has been given. For example ctr+shift+a (written as #c01#s01a) will send the following event: key press for the keys control and shift, key press and released for the a key, key release for shift and control
at the end of a command keystroke, if the keys have not been released. For example a sequence of shit+tab, shift+tab, shift+tab (#s01#t01#t01#t01) will release the shift key at the end. On the contrary #s01#t01#t01#t01abc will call three back tab and will write Abc.
To install this module type the following:
On windows use nmake or dmake instead of make.
The following modules are required in order to use this module
Test::Simple => 0.44,
Win32::Shortkeys::Kbh => 0.01,
Config::YAML::Tiny => 1.42,
Win32::Clipboard => 0.58,
XML::Parser => 2.44,
Encode => 2.84,
Time::HiRes => 1.9733,
Carp => 1.40
Any questions or problems can be posted to me (rappazf) on my gmail account.
The current state of the source can be extract using Mercurial from
François Rappaz <firstname.lastname@example.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install Win32::Shortkeys, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.