Difference between revisions of "KeyMacs plugin"

From Code::Blocks
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Code::Blocks Contrib Plugins]]
+
[[Category:Code::Blocks 3rd Party Plugins]]
 
{{Infobox_Plugin|
 
{{Infobox_Plugin|
 
   name = KeyMacs |
 
   name = KeyMacs |
   logo = [[Image:KeyMacIco.png]] |
+
   logo = [[File:Generic-plugin.png]] |
   developer = [[User:Pecan|Pecan]] |
+
   developer = Pecan |
   maintainer = Pecan |
+
   maintainer = |
   version = 0.3.0
+
   version = 1.3.21
 
}}
 
}}
  
'''KeyMacs''' (or '''Keyboard Macros''') plugin enables Recording, Playback, and editing of keystroke macros.
+
See the forum message
  
 +
[/index.php/topic,9980.msg70445.html#msg70445 KeyMacs plugin]
  
 +
[http://code.google.com/p/cbkeymacs/ Google repository]
 +
 +
'''KeyMacs''' (or Keyboard Macros) plugin enables Recording, Playback, and editing of keystroke macros. For simpler macros see the [[abbreviations plugin]].
 +
 +
==What is KeyMacs==
  
====What is KeyMacs====
 
----------------
 
 
KeyMacs is a Code::Blocks plugin providing the user an ability to group sequences of keystokes as a macro (KeyMac). The KeyMac can be executed by either the main Plugin menu, a menu command key, or the context menu.
 
KeyMacs is a Code::Blocks plugin providing the user an ability to group sequences of keystokes as a macro (KeyMac). The KeyMac can be executed by either the main Plugin menu, a menu command key, or the context menu.
  
The KeyMac "{END}{ENTER}//{TAB 2}", for example, will move the cursor to the end of the current line, start a new line, enter the C++ comment sequence and two tabs.
+
The KeyMac <code>{END}{ENTER}//{TAB 2}</code>, for example, will move the cursor to the end of the current line, start a new line, enter the C++ comment sequence and two tabs.
  
KeyMacs can be created in the KeyMac editor or by way of the "Record Macro" menu. The editor can be accessed via MainMenu => Plugins => KeyMacs => EditMacros.
+
KeyMacs can be created in the KeyMac editor or by way of the "Record Macro" menu. The editor can be accessed via ''MainMenu->Plugins->KeyMacs->EditMacros''.
  
[[Image:KeyMacs102.PNG]]  
+
[[File:KeyMacs102.PNG]]
  
 
Within the editor, click the New button. A new empty "Untitled" macro is created. Click on "Untitled" and rename it, for example, MyMac. Hit enter to confirm the rename.
 
Within the editor, click the New button. A new empty "Untitled" macro is created. Click on "Untitled" and rename it, for example, MyMac. Hit enter to confirm the rename.
  
    {END}{ENTER}//{TAB 2}
+
<code>{END}{ENTER}//{TAB 2}</code>
  
Enter the above keymac into the right hand text window . Click within the "Menued Macro" check box to cause KeyMacs to add MyMac as an entry on the Pugins=>KeyMacs=>submenu and the CodeBlocks editor context menu.
+
Enter the above keymac into the right hand text window . Click within the "Menued Macro" check box to cause KeyMacs to add MyMac as an entry on the ''Pugins->KeyMacs->submenu'' and the Code::Blocks editor context menu.
  
[[Image:KeyMacs103.PNG]]  
+
[[File:KeyMacs103.PNG]]
  
Within the Command Key edit box, enter the keystrokes "Ctrl-Alt-M". This is
+
Within the Command Key edit box, enter the keystrokes "Ctrl-Alt-M". This is the command (hot) keys that will be placed on the menu entry for MyMac. This key sequence should be unique, not conficting with any other menu command key sequence used in the Code::Blocks menu system.
the command (hot) keys that will be placed on the menu entry for MyMac. This
 
key sequence should be unique, not conficting with any other menu command key sequence
 
used in the Code::Blocks menu system.
 
  
 
Click on OK to accept the KeyMac definition.
 
Click on OK to accept the KeyMac definition.
  
You will now see a MyMac menu entry at the bottom of the Menu=>Plugins=>KeyMacs
+
You will now see a MyMac menu entry at the bottom of the ''Menu->Plugins->KeyMacs'' menu panel with the command keys Ctrl-Alt-M.
menu panel with the command keys Ctrl-Alt-M.
 
  
Either clicking on the MyMac menu item, invoking it with the command keys,
+
Either clicking on the MyMac menu item, invoking it with the command keys, or choosing it from the KeyMacros context menu should produce <code>//</code> followed by two tabs as a new comment line in your edit window.
or choosing it from the KeyMacros context menu should produce "//" followed by two tabs
 
as a new comment line in your edit window.
 
  
 
KeyMacs without command keys can still be "menued", and be invoked by clicking on them from either the main or context menu.
 
KeyMacs without command keys can still be "menued", and be invoked by clicking on them from either the main or context menu.
  
====Recording and playback====
+
==Recording and playback==
----------------------
+
 
KeyMac contain a "Record Macro" facility that stores each keystroke for
+
KeyMac contain a "Record Macro" facility that stores each keystroke for later use by the "Play Macro" menu item.
later use by the "Play Macro" menu item.
 
  
Once recorded, stopped or played back, the keystrokes are stored in the KeyMacs
+
Once recorded, stopped or played back, the keystrokes are stored in the KeyMacs Editor by the label "Scratch".
Editor by the label "Scratch".
 
  
The Scratch macro is over written on each record, stop, or playback. If you wish to save
+
The Scratch macro is over written on each record, stop, or playback. If you wish to save it, you must use the KeyMacs editor to rename "Scratch" to some other label.
it, you must use the KeyMacs editor to rename "Scratch" to some other label.
 
  
Recorded keymacs should be edited for accuracy. They may contain suprious,
+
Recorded keymacs should be edited for accuracy. They may contain misinterpreted or unwanted keystrokes. A <code>{</code> brace recorded in a macro, for example, cannot be played back accurately as a character until it's surrounded by escape braces <code>{{}</code>.
unwanted keystrokes. A '{' brace recorded in a macro, for example, cannot be
 
played back accurately as a character until it's surrounded by escape braces "{{}".
 
  
"!", "^", "+", cannot be played back as characters until they too are
+
<code>!</code>, <code>^</code>, <code>+</code>, cannot be played back as characters until they too are surrounded by braces; else they play back as the <tt>Alt</tt>, <tt>Ctrl</tt>, and <tt>Shift</tt> prefix modifiers for any key that follows them. Eg., <code>^c</code> is not the characters <code>^</code> and <code>c</code>, but the copy operation <tt>Ctrl-C</tt>. The character sequence must appear as <code>{^}c</code>.
surrounded by braces; else they play back as the Alt, Ctrl, and Shift
 
prefix modifiers for any key that follows them.  
 
Eg., "^c" is not the characters '^' and
 
'c', but the copy operation Ctrl-C. The character sequence must appear as
 
"{^}c".
 
  
KeyMacs attempts to determine the intent of the user by surrounding single character occurances of these chars with escape braces, but it's not always correct.
+
KeyMacs attempts to determine the intent of the user by surrounding single character occurrences of these chars with escape braces, but it's not always correct.
  
 
If, during recording, the window focus leaves the editor, KeyMacs cannot see and record user key presses. They can, however, be re-entered into the macro via the KeyMacs editor.
 
If, during recording, the window focus leaves the editor, KeyMacs cannot see and record user key presses. They can, however, be re-entered into the macro via the KeyMacs editor.
  
====Named Key Symbols====
+
Named Key Symbols
-----------------
+
 
At the bottom of the KeyMacs editor is a list of key symbols (KeySyms) which
+
At the bottom of the KeyMacs editor is a list of key symbols (KeySyms) which represent functions performed for the user by KeyMacs. For example, <code>{ENTER}</code> emulates the user depressing then releasing the <tt>Enter</tt> key.
represent functions performed for the user by KeyMacs. For example, {ENTER}
+
 
emulates the user depressing then releasing the Enter key.
+
Other KeySyms, like <code>{ALTDOWN}</code>, depress the keys but do not release them until an opposite KeySym, like <code>{ALTUP}</code>, appears in the key macro stream. These "paired" KeySyms can cause havoc if not entered as matching pairs.
 +
 
 +
Eg., <code>{CTRLDOWN}{RIGHT}{RIGHT}{CTRLUP}</code> moves two words to the right.
 +
 
 +
KeySyms which cause movement may contain a numeric parameter. Eg, <code>{RIGHT 4}</code> will move the cursor 4 positions to the right.
 +
 
 +
; <code>{WAIT 5}</code> : will pause for 5 milliseconds.
 +
; <code>{ASC 0191}</code> : will enter the char represented by ascii 191 into the editor.
 +
; <code>{ENTER 2}</code> : will create two new lines
 +
; <code>{UP}{DOWN}{RIGHT}{LEFT}</code> : are others.
 +
 
 +
==Special keys==
 +
 
 +
<code>!</code>, <code>^</code>, <code>+</code>, represent the keystrokes <tt>Alt</tt>, <tt>Ctrl</tt>, and <tt>Shift</tt> respectively. They provide a modifier for the character key that follows it. When KeyMacs sees a <code>!c</code>, it interprets it as an <tt>Alt-c</tt>; a <code>+v</code> as a <tt>Shift-v</tt>; a <code>^t</code> as a <tt>Ctrl-t</tt>. KeyMacs depresses the modifier key, depresses the char key, releases the char key, then releases the modifier key.
 +
 
 +
The brace set <code>{</code> and <code>}</code> are used to delineate special KeySyms. To use them as characters in a macro, they must be surrounded by braces themselves. IE., <code>{{}</code> and <code>{}}</code> correctly represent the left and right brace as characters.
 +
 
 +
==Quirks & restrictions==
 +
 
 +
Key macros must begin execution from within an editor window. Once invoked from within an editor, macro keys may be injected into other windows, such as the find dialog. The sequence <code>^fPecan{ENTER}</code> would invoke the find dialog, insert the chars <tt>Pecan</tt> into the find text control, then execute the find by depressing and releasing the enter key.
 +
 
 +
Macros not checked as "Menued Macro" in the KeyMacs editor simply remain in the database for future reference. They can, of course, be deleted.
 +
 
 +
The macro database resides in the users home directory as <tt>cbKeyMacs.ini</tt>. The first section contains the macro definitions. The second section specifies the menu command keys or blank if "un-menued".
 +
 
 +
KeyMacs can execute other KeyMacs by referencing their menu command key. Be careful. This can cause an infinte loop if two macros invoke each other. To avoid this, a KeyMac that invokes another KeyMac should itself have no command keys.
 +
 
 +
A Keymac that is invoked by another KeyMac might execute asynchronously. Invoked KeyMacs do not return to the invoking Keymac The invoking KeyMac cannot wait for the invoked KeyMac. Most likely, the invoked KeyMac is queued up behind the invoking KeyMac, but it might also start its own thread.
 +
 
 +
The context <code>{MENU}</code> keysym opens on my Windows XP2 system at coordinates (0,0). I've found no way to change this annoying behavior.
 +
 
 +
KeyMacs injects keys into the focused window keyboard buffer. It attempts to start the KeyMac within the window that invoked the menu. But if you're running a "focus follows mouse" system, the mouse may change the window focus during KeyMac execution causing keys to input into the wrong window. Be careful of the mouse pointer location during invocations of the context menu.
 +
 
 +
On *nix. I have not yet succeeded in moving the mouse pointer back into the window owning the KeyMac when the mouse ends outside the owning window.
 +
 
 +
<code>{ASC}</code> is not available for *nix since XWindows does not support it.
 +
 
 +
==How do I install it?==
 +
 
 +
Download: [http://code.google.com/p/cbkeymacs/downloads/list] to a clean folder.
 +
 
 +
Compile KeyMacs for MSWindows with <tt>KeyMacs.cbp</tt>. Then copy <tt>KeyMacs.dll</tt> to <tt>...\trunk\src\devel\share\CodeBlocks\plugins\KeyMacs.dll</tt>. Copy <tt>KeyMacs.zip</tt> to <tt>...\trunk\src\devel\share\CodeBlocks\KeyMacs.zip</tt>
 +
 
 +
Compile KeyMacs for Linux with <tt>KeyMacs(unix).cbp</tt>. Then copy <tt>KeyMacs.so</tt> to <tt>.../trunk/src/devel/share/codeclocks/plugins/KeyMacs.so</tt>. Copy <tt>KeyMacs.zip</tt> to <tt>.../trunk/src/devel/share/codeblocks/KeyMacs.zip</tt>
 +
 
 +
Linux users will need the X11 and Xtst development libraries. These are usually already provided by the distribution. Ubuntu Synaptic provided the following libraries when I searched for xtst:
 +
 
 +
[[File:KeyMacs107.PNG]]
 +
 
 +
KeySym definitions
 +
 
 +
<code>^</code>, <code>!</code>, <code>+</code> are key modifiers representing <tt>CTRL</tt>, <tt>ALT</tt>, <tt>SHIFT</tt>
 +
 
 +
<code>{ALT UP|DOWN}</code> - Program menu invocation
 +
 
 +
<code>{BACKSPACE}</code> or <code>{BS}</code>
 +
 
 +
<code>{DEL}</code>
 +
 
 +
<code>{DELETE}</code>
 +
 
 +
<code>{DOWN}</code>
 +
 
 +
<code>{END}</code>
 +
 
 +
<code>{ENTER}</code>
 +
 
 +
<code>{ESC}</code> or <code>{ESCAPE}</code>
 +
 
 +
<code>{F1}</code> <code>{F2}</code> <code>{F3}</code> <code>{F4}</code> <code>{F5}</code> <code>{F6}</code> <code>{F7}</code> <code>{F8}</code> <code>{F9}</code> <code>{F10}</code> <code>{F11}</code> <code>{F12}</code>
 +
 
 +
<code>{HOME}</code>
 +
 
 +
<code>{INS}</code> or <code>{INSERT}</code>
 +
 
 +
<code>{LEFT}</code> <code>{RIGHT}</code>
 +
 
 +
<code>{PGDN}</code> <code>{PGUP}</code>
 +
 
 +
<code>{SPACE}</code>
 +
 
 +
<code>{TAB}</code>
  
Other KeySyms, like {ALTDOWN}, depress the keys but do not release them
+
<code>{UP}</code>
until an opposite KeySym, like {ALTUP}, appears in the key macro stream.
 
These "paired" KeySyms can cause havoc if not entered as matching pairs.
 
  
Eg., {CTRLDOWN}{RIGHT}{RIGHT}{CTRLUP} moves two words to the right.
+
<code>{PRINTSCREEN}</code>
  
KeySyms which cause movement may contain a numeric parameter. Eg, {RIGHT 4}
+
<code>{SCROLLLOCK}</code>
will move the cursor 4 positions to the right.
 
  
    {WAIT 5} will pause for 5 milliseconds.
+
<code>{NUMLOCK}</code>
    {ASC 0191} will enter the char represented by ascii 191 into the editor.
 
    {ENTER 2} will create two new lines
 
    {UP}{DOWN}{RIGHT}{LEFT} are others.
 
   
 
  
 +
<code>{CTRLBREAK}</code>
  
====Special keys====
+
<code>{PAUSE}</code>
------------
 
!, ^, +, represent the keystrokes Alt, Ctrl, and Shift respectively.
 
They provide a modifier for the character key that follows it. When KeyMacs
 
sees a "!c", it interprets it as an Alt-c; a "+v" as a Shift-v; a "^t" as a
 
Ctrl-t. KeyMacs depresses the modifier key, depresses the char key, releases
 
the char key, then releases the modifier key.
 
  
The brace set '{' and  '}' are used to delineate special KeySyms. To use them as
+
<code>{CAPSLOCK}</code>
characters in a macro, they must be surrounded by braces themselves. IE.,
 
{{} and {}} correctly represent the left and right brace as characters.
 
  
 +
<code>{NUMPAD0}</code>
  
====Quirks & restrictions.====
+
<code>{NUMPAD1}</code> <code>{NUMPAD2}</code> <code>{NUMPAD3}</code> <code>{NUMPAD4}</code> <code>{NUMPAD5}</code> <code>{NUMPAD6}</code> <code>{NUMPAD7}</code> <code>{NUMPAD8}</code> <code>{NUMPAD9}</code>
---------------------
 
Key macros must begin execution from within an editor window. Once invoked
 
from within an editor, macro keys may be injected into other windows, such as
 
the find dialog. The sequence "^fPecan{ENTER}" would invoke the find dialog,
 
insert the chars "Pecan" into the find text control, then execute the find by
 
depressing and releasing the enter key.
 
  
Macros not checked as "Menued Macro" in the KeyMacs editor simply remain in
+
<code>{NUMPADMULT}</code> <code>{NUMPADADD}</code> <code>{NUMPADSUB}</code> <code>{NUMPADDOT}</code> <code>{NUMPADDIV}</code> <code>{NUMPADENTER UP|DOWN}</code>
the database for future reference. They can, of course, be deleted.
 
  
The macro database resides in the users home directory as cbKeyMacs.ini. The
+
<code>{MENU}</code> - context menu
first section contains the macro definitions. The second section specifies the menu command keys or blank if "un-menued".
 
  
KeyMacs can execute other KeyMacs by referencing their menu command key. Be careful.
+
<code>{LCTRL}</code> <code>{RCTRL}</code>
This can cause an infinte loop if two macros invoke each other. To avoid
 
this, a KeyMac that invokes another KeyMac should itself have no command keys.
 
  
A Keymac that is invoked by another KeyMac might execute asynchronously. Invoked
+
<code>{LALT}</code> <code>{RALT}</code>
KeyMacs do not return to the invoking Keymac The invoking KeyMac cannot wait
 
for the invoked KeyMac. Most likely, the invoked KeyMac is queued up behind
 
the invoking KeyMac, but it might also start its own thread.
 
  
The context {MENU} keysym opens on my Windows XP2 system at coordinates (0,0).
+
<code>{LSHIFT}</code> <code>{RSHIFT}</code>
I've found no way to change this annoying behavior.
 
  
KeyMacs injects keys into the focused window keyboard buffer. It attempts to
+
<code>{SLEEP}</code>
start the KeyMac within the window that invoked the menu. But if you're running
 
a "focus follows mouse" system, the mouse may change the window focus during
 
KeyMac execution causing keys to input into the wrong window.
 
Be careful of the mouse pointer location during invocations of the context menu.
 
  
On *nix. I have not yet succeeded in moving the mouse pointer back into the
+
<code>{CTRLDOWN}</code> <code>{CTRLUP}</code>
window owning the KeyMac when the mouse ends outside the owning window.
 
  
{ASC} is not available for *nix since XWindows does not support it.
+
<code>{ALTDOWN}</code> <code>{ALTUP}</code>
  
 +
<code>{SHIFTDOWN}</code> <code>{SHIFTUP}</code>
  
====How do I install it?====
+
<code>{ASC 0nnn}</code>
--------------------
 
Download: http://www.savefile.com/files/611464
 
Unzip cbKeyMacs03-15-2.zip to a clean folder.
 
  
Compile KeyMacs for MSWindows with KeyMacs.cbp. Then copy KeyMacs.dll to ...\trunk\src\devel\share\CodeBlocks\plugins\KeyMacs.dll.
+
<code>{WAIT}</code>
Copy KeyMacs.zip to ...\trunk\src\devel\share\CodeBlocks\KeyMacs.zip
 
  
Compile KeyMacs for Linux with KeyMacs(unix).cbp. Then copy KeyMacs.dll to .../trunk/src/devel/share/codeclocks/plugins/KeyMacs.dll.
+
==Example KeyMacs==
Copy KeyMacs.zip to .../trunk/src/devel/share/codeblocks/KeyMacs.zip
 
 
Linux users will need the X11 and Xtst development libraries.
 
Ubuntu Synaptic provided the following libraries when I searched for xtst:
 
[[Image:KeyMacs107.PNG]]
 
  
====KeySym definitions====
+
Use cmd key <tt>Ctrl-Enter</tt> to create a new indented line.
------------------
 
    ^, !, + are key modifiers representing CTRL, ALT,SHIFT
 
    {ALT UP|DOWN} - Program menu invocation
 
    {BACKSPACE} or {BS}
 
    {DEL}
 
    {DELETE}
 
    {DOWN}
 
    {END}
 
    {ENTER}
 
    {ESC} or {ESCAPE}
 
    {F1} {F2} {F3} {F4} {F5} {F6} {F7} {F8} {F9} {F10} {F11} {F12}
 
    {HOME}
 
    {INS} or {INSERT}
 
    {LEFT} {RIGHT}
 
    {PGDN} {PGUP}
 
    {SPACE}
 
    {TAB}
 
    {UP}
 
    {PRINTSCREEN}
 
    {SCROLLLOCK}
 
    {NUMLOCK}
 
    {CTRLBREAK}
 
    {PAUSE}
 
    {CAPSLOCK}
 
    {NUMPAD0}
 
    {NUMPAD1} {NUMPAD2} {NUMPAD3} {NUMPAD4} {NUMPAD5} {NUMPAD6} {NUMPAD7}
 
    {NUMPAD8} {NUMPAD9} {NUMPADMULT} {NUMPADADD} {NUMPADSUB} {NUMPADDOT}
 
    {NUMPADDIV} {NUMPADENTER UP|DOWN}
 
    {MENU} - context menu
 
    {LCTRL} {RCTRL}
 
    {LALT} {RALT}
 
    {LSHIFT} {RSHIFT}
 
    {SLEEP}
 
    {CTRLDOWN} {CTRLUP}
 
    {ALTDOWN} {ALTUP}
 
    {SHIFTDOWN} {SHIFTUP}
 
    {ASC 0nnn}
 
    {WAIT}
 
  
 +
: <code>{END}{ENTER}</code>
  
====Example KeyMacs====
+
Use <tt>Ctrl-P</tt> to enter the C++ pointer sequence (saving a lot of mistypes)
---------------
 
Use cmd key Ctrl-Enter to create a new indented line.
 
    "{END}{ENTER}"
 
  
Use Ctrl-P to enter the C++ pointer sequence (saving alot of mistypes)
+
: <code>-></code>
    "->"
 
  
Use Alt-Ctrl-C to enter the C++ comment sequence
+
Use <tt>Alt-Ctrl-C</tt> to enter the C++ comment sequence
    "{END}{ENTER}//{TAB}"
 
  
Use Alt-Ctrl-B to enter a new set of formated braces
+
: <code>{END}{ENTER}//{TAB}</code>
    "{END}{ENTER}{{}{ENTER 2}{HOME}{}}{UP}{TAB}"
 
  
 +
Use <tt>Alt-Ctrl-B</tt> to enter a new set of formatted braces
  
Pecan 2007/01/15
+
: <code>{END}{ENTER}{{}{ENTER 2}{HOME}{}}{UP}{TAB}</code>

Latest revision as of 18:20, 5 September 2011

KeyMacs
Generic-plugin.png
Developer(s): Pecan
Maintainer(s):
Version: 1.3.21

See the forum message

[/index.php/topic,9980.msg70445.html#msg70445 KeyMacs plugin]

Google repository

KeyMacs (or Keyboard Macros) plugin enables Recording, Playback, and editing of keystroke macros. For simpler macros see the abbreviations plugin.

What is KeyMacs

KeyMacs is a Code::Blocks plugin providing the user an ability to group sequences of keystokes as a macro (KeyMac). The KeyMac can be executed by either the main Plugin menu, a menu command key, or the context menu.

The KeyMac {END}{ENTER}//{TAB 2}, for example, will move the cursor to the end of the current line, start a new line, enter the C++ comment sequence and two tabs.

KeyMacs can be created in the KeyMac editor or by way of the "Record Macro" menu. The editor can be accessed via MainMenu->Plugins->KeyMacs->EditMacros.

KeyMacs102.PNG

Within the editor, click the New button. A new empty "Untitled" macro is created. Click on "Untitled" and rename it, for example, MyMac. Hit enter to confirm the rename.

{END}{ENTER}//{TAB 2}

Enter the above keymac into the right hand text window . Click within the "Menued Macro" check box to cause KeyMacs to add MyMac as an entry on the Pugins->KeyMacs->submenu and the Code::Blocks editor context menu.

KeyMacs103.PNG

Within the Command Key edit box, enter the keystrokes "Ctrl-Alt-M". This is the command (hot) keys that will be placed on the menu entry for MyMac. This key sequence should be unique, not conficting with any other menu command key sequence used in the Code::Blocks menu system.

Click on OK to accept the KeyMac definition.

You will now see a MyMac menu entry at the bottom of the Menu->Plugins->KeyMacs menu panel with the command keys Ctrl-Alt-M.

Either clicking on the MyMac menu item, invoking it with the command keys, or choosing it from the KeyMacros context menu should produce // followed by two tabs as a new comment line in your edit window.

KeyMacs without command keys can still be "menued", and be invoked by clicking on them from either the main or context menu.

Recording and playback

KeyMac contain a "Record Macro" facility that stores each keystroke for later use by the "Play Macro" menu item.

Once recorded, stopped or played back, the keystrokes are stored in the KeyMacs Editor by the label "Scratch".

The Scratch macro is over written on each record, stop, or playback. If you wish to save it, you must use the KeyMacs editor to rename "Scratch" to some other label.

Recorded keymacs should be edited for accuracy. They may contain misinterpreted or unwanted keystrokes. A { brace recorded in a macro, for example, cannot be played back accurately as a character until it's surrounded by escape braces {{}.

!, ^, +, cannot be played back as characters until they too are surrounded by braces; else they play back as the Alt, Ctrl, and Shift prefix modifiers for any key that follows them. Eg., ^c is not the characters ^ and c, but the copy operation Ctrl-C. The character sequence must appear as {^}c.

KeyMacs attempts to determine the intent of the user by surrounding single character occurrences of these chars with escape braces, but it's not always correct.

If, during recording, the window focus leaves the editor, KeyMacs cannot see and record user key presses. They can, however, be re-entered into the macro via the KeyMacs editor.

Named Key Symbols

At the bottom of the KeyMacs editor is a list of key symbols (KeySyms) which represent functions performed for the user by KeyMacs. For example, {ENTER} emulates the user depressing then releasing the Enter key.

Other KeySyms, like {ALTDOWN}, depress the keys but do not release them until an opposite KeySym, like {ALTUP}, appears in the key macro stream. These "paired" KeySyms can cause havoc if not entered as matching pairs.

Eg., {CTRLDOWN}{RIGHT}{RIGHT}{CTRLUP} moves two words to the right.

KeySyms which cause movement may contain a numeric parameter. Eg, {RIGHT 4} will move the cursor 4 positions to the right.

{WAIT 5}
will pause for 5 milliseconds.
{ASC 0191}
will enter the char represented by ascii 191 into the editor.
{ENTER 2}
will create two new lines
{UP}{DOWN}{RIGHT}{LEFT}
are others.

Special keys

!, ^, +, represent the keystrokes Alt, Ctrl, and Shift respectively. They provide a modifier for the character key that follows it. When KeyMacs sees a !c, it interprets it as an Alt-c; a +v as a Shift-v; a ^t as a Ctrl-t. KeyMacs depresses the modifier key, depresses the char key, releases the char key, then releases the modifier key.

The brace set { and } are used to delineate special KeySyms. To use them as characters in a macro, they must be surrounded by braces themselves. IE., {{} and {}} correctly represent the left and right brace as characters.

Quirks & restrictions

Key macros must begin execution from within an editor window. Once invoked from within an editor, macro keys may be injected into other windows, such as the find dialog. The sequence ^fPecan{ENTER} would invoke the find dialog, insert the chars Pecan into the find text control, then execute the find by depressing and releasing the enter key.

Macros not checked as "Menued Macro" in the KeyMacs editor simply remain in the database for future reference. They can, of course, be deleted.

The macro database resides in the users home directory as cbKeyMacs.ini. The first section contains the macro definitions. The second section specifies the menu command keys or blank if "un-menued".

KeyMacs can execute other KeyMacs by referencing their menu command key. Be careful. This can cause an infinte loop if two macros invoke each other. To avoid this, a KeyMac that invokes another KeyMac should itself have no command keys.

A Keymac that is invoked by another KeyMac might execute asynchronously. Invoked KeyMacs do not return to the invoking Keymac The invoking KeyMac cannot wait for the invoked KeyMac. Most likely, the invoked KeyMac is queued up behind the invoking KeyMac, but it might also start its own thread.

The context {MENU} keysym opens on my Windows XP2 system at coordinates (0,0). I've found no way to change this annoying behavior.

KeyMacs injects keys into the focused window keyboard buffer. It attempts to start the KeyMac within the window that invoked the menu. But if you're running a "focus follows mouse" system, the mouse may change the window focus during KeyMac execution causing keys to input into the wrong window. Be careful of the mouse pointer location during invocations of the context menu.

On *nix. I have not yet succeeded in moving the mouse pointer back into the window owning the KeyMac when the mouse ends outside the owning window.

{ASC} is not available for *nix since XWindows does not support it.

How do I install it?

Download: [1] to a clean folder.

Compile KeyMacs for MSWindows with KeyMacs.cbp. Then copy KeyMacs.dll to ...\trunk\src\devel\share\CodeBlocks\plugins\KeyMacs.dll. Copy KeyMacs.zip to ...\trunk\src\devel\share\CodeBlocks\KeyMacs.zip

Compile KeyMacs for Linux with KeyMacs(unix).cbp. Then copy KeyMacs.so to .../trunk/src/devel/share/codeclocks/plugins/KeyMacs.so. Copy KeyMacs.zip to .../trunk/src/devel/share/codeblocks/KeyMacs.zip

Linux users will need the X11 and Xtst development libraries. These are usually already provided by the distribution. Ubuntu Synaptic provided the following libraries when I searched for xtst:

KeyMacs107.PNG

KeySym definitions

^, !, + are key modifiers representing CTRL, ALT, SHIFT

{ALT UP|DOWN} - Program menu invocation

{BACKSPACE} or {BS}

{DEL}

{DELETE}

{DOWN}

{END}

{ENTER}

{ESC} or {ESCAPE}

{F1} {F2} {F3} {F4} {F5} {F6} {F7} {F8} {F9} {F10} {F11} {F12}

{HOME}

{INS} or {INSERT}

{LEFT} {RIGHT}

{PGDN} {PGUP}

{SPACE}

{TAB}

{UP}

{PRINTSCREEN}

{SCROLLLOCK}

{NUMLOCK}

{CTRLBREAK}

{PAUSE}

{CAPSLOCK}

{NUMPAD0}

{NUMPAD1} {NUMPAD2} {NUMPAD3} {NUMPAD4} {NUMPAD5} {NUMPAD6} {NUMPAD7} {NUMPAD8} {NUMPAD9}

{NUMPADMULT} {NUMPADADD} {NUMPADSUB} {NUMPADDOT} {NUMPADDIV} {NUMPADENTER UP|DOWN}

{MENU} - context menu

{LCTRL} {RCTRL}

{LALT} {RALT}

{LSHIFT} {RSHIFT}

{SLEEP}

{CTRLDOWN} {CTRLUP}

{ALTDOWN} {ALTUP}

{SHIFTDOWN} {SHIFTUP}

{ASC 0nnn}

{WAIT}

Example KeyMacs

Use cmd key Ctrl-Enter to create a new indented line.

{END}{ENTER}

Use Ctrl-P to enter the C++ pointer sequence (saving a lot of mistypes)

->

Use Alt-Ctrl-C to enter the C++ comment sequence

{END}{ENTER}//{TAB}

Use Alt-Ctrl-B to enter a new set of formatted braces

{END}{ENTER}{{}{ENTER 2}{HOME}{}}{UP}{TAB}