Win95Key 2.0

10x to :
Samuel Audet guardia@cam.org for original idea
Dmitry Ban for event processing idea
Sergey Yevtushenko for help with WarpCenter's functions

0. What it is

win95key is a little program that enable <unused> keys on your keyboard when you're working with OS/2 pm. For example you can make the left windoze key to open Warp Center menu or key with an arrow pointed at broken window to launch netscape. With this program you can map almost any key combination to any action you want. It provides standard way both for adding the new functionality and for the keyboard events mapping as well. You can use almost any keyboards with almost any keys. If you're programmer you can create your own plug ins with your own logic.

1. What's bad

Unfortunately i don't have enough time to develop PM configuration frontend for it. But i hope that there's somebody who will create any. ;)
In fact Alex Samorukov have created very useful configuration tool. It still beta so we're waiting for his kindly permission to publish this tool

2. Installation

Just unzip to the any directory and run win95key.exe

3. Customization

The main idea is that keyboard combinations are linked to "actions" and "actions" are mapped to pieces of the code imported from "plugin" DLLs. As soon as we're working with OS/2 we have to use "OS/2 way" so I decide to use standard OS2 INI file to store settings. I don't know why but name of this file is always "win95key.INI". I use regedit2.exe tool included in Warp 4 FP5 or later to edit it; but there are a lot of tools to edit OS/2 INI files. This INI file consists of three sections:

3.0. First one - "PLUGINS"

contains action names linked to plug ins. For example following entry in PLUGINS section will create action "OpenObject" from dll "w95k_std.dll", entry "OpenObject" :

You may use dll entries numbers as well as names. You may use full path to dll as well as relative.

3.1. Second section - "MODIFIERS"

describes special keys treated as modifiers in addition to standard Ctrl, Alt and Shift. Syntax is simple : modifier_name=modifier_scancode

For example if you want to use left windoze key as modifier with the name LWIN, just create following entry in "MODIFIERS" section :

Where 0x mean hexadecimal notation (126 in Dec)
You can omit scancode (just set it to 0) for 'standard' keys. Just use mnemonic name, for example A for 'A' key. You can find special mnemonic names in 3.3.

3.2. Third (and last) section - "KEYS"

contains actual key assignments. Name of the entry describe key combination in the following format : [<Modifier>[+<Modifier>[...]]&]<scancode>  where each of the modifiers have to be described in "MODIFIERS" section except standard Ctrl, Alt and shift. Remember that all modifiers' names but standard are case sensitive. <scancode> is the scancode for key used to invoke event. You may also use mnemonic name of the desired key, such as A for 'A' key. Please find the spesial mnemonic names in 3.3. Value of each entry contains action from "PLUGINS" section with the optional parameters in quotes. For example entry to launch netscape when pressing LWIN+N may look like following :

3.3. Special key names
 
 
Name Key
Esc Esc key
F1-F12 F keys
ScrollLock Scroll Lock key
Pause Pause key
k1-k0 Numeric keys on the main part of the keyboard
BackSpace BackSpace key
CapsLock Caps lock key
LShift Left shift
RShift Right shift
LCtrl Left ctrl
RCtrl Right ctrl
LAlt Left alt
RAlt Right alt
LWin Left windoze key
RWin Right windoze key
WinMenu Key with the mouse pointer pointed to the broken window
s_left Left arrow key on the little keypad between main keyboard and numeric keypad
s_right Right arrow key on the little keypad between main keyboard and numeric keypad
s_up Up arrow key on the little keypad between main keyboard and numeric keypad
s_down Down arrow key on the little keypad between main keyboard and numeric keypad
s_ins Insert key on the little keypad between main keyboard and numeric keypad
s_home Home key on the little keypad between main keyboard and numeric keypad
s_del Delete key on the little keypad between main keyboard and numeric keypad
s_end End key on the little keypad between main keyboard and numeric keypad
s_pgUp Page Up key on the little keypad between main keyboard and numeric keypad
s_pgDn Page Down key on the little keypad between main keyboard and numeric keypad
NumLock Num Lock key on the numeric keypad
Home Home key on the numeric keypad
End End key on the numeric keypad
Up Up arrow key on the numeric keypad
Down Down arrow key on the numeric keypad
Left Left arrow key on the numeric keypad
Right Right arrow key on the numeric keypad
PgUp Page Up key key on the numeric keypad
PgDn Page Down key on the numeric keypad
Ins Insert key on the numeric keypad
Del Delete key on the numeric keypad
Center '5' key on the numeric keypad
BigEnter Main enter key
SmallEnter Enter key on the numeric keypad
Plus Plus key on the numeric keypad
Minus Minus key on the numeric keypad
Space Space key

4. Plugins

4.1. Standard plugin library

At the moment just one plugin library is supplied with win95key.exe. It contains five foo you can use. Here's a brief description :
w95k_std.dll plugin library
Entry name Entry number Description Number of the parameters Parameters
Is mandatory Description
SwitchTo 1 Switch to (bring up) window 1 Yes Title of the window to make active
WindowList 2 Shows the window list 0  
DesktopMenu 3 Shows the desktop's context menu 1 No Desktop's title
ContextMenu 4 Shows the context menu of the current application 0  
WarpcenterMenu 5 Shows the WarpCenter's menus 1 Yes Describes action to perform. Allowed values are : 
Value Action
MENU Show WarpCenter's OS/2WARP menu
WINDOWLIST Show WarpCenter's window list
LOCKUP Desktop lockup
FIND Find an object
SHUTDOWN Warpcenter's system shutdown
INFO Switch WarpCenter's information pane
TRAYS WarpCenter's trays select menu
CLOCK Switch WarpCenter's clock mode
PROPERTIES WarpCenter's properties
OpenObject 6 Opens an object or launch program 3 Yes Object name or path
No Type of view. Allowed values are :
Value
HELP
PALETTE
PROMPTDLG
RUNNING
SETTINGS
TREE
CONTENTS
DETAILS
If you'll omit this parameter, default view type will be used
No "NEWVIEW" will always open new view, any other or no parameter will use object's settings
Volume 7 Controls OS/2 MM Volume 1 Yes Up or Down

4.2. Create your own!

It's easy to create your own plugin dll. You just have to create usual dll with set of functions using the following template :

void EXPENTRYPluginFoo(int argc, char * argv[])
{ HMQ hmqLocal=NULLHANDLE;

  hmqLocal=WinCreateMsgQueue(WinQueryAnchorBlock(HWND_DESKTOP), 0);

  WinMessageBox(HWND_DESKTOP,HWND_DESKTOP, "Hello world!", "PluginFoo", 11,
             MB_OK | MB_MOVEABLE | MB_INFORMATION);

  if(hmqLocal!=NULLHANDLE)
    { WinDestroyMsgQueue(hmqLocal);
    }
}

5. Tools for configuration and troubleshooting

As soon as i didn't develop any frontend for this it's not too easy to customize ;) But i include some useful tools such as tool which will help you to find scancode for your favorite key. Just run showkey.exe and press this key - it's so easy :

Please remember that if this utility doesn't show scancode of your favorite key, it mean that your key is not supported by os/2. Usually it happens if your keyboard is not supported by \OS2\BOOT\KBDBASE.SYS; for example if this file was replaced by process commander. Please use Process Commander in WatchCat mode if you want to use win95key together with Process Commander. Unfortunately at the moment i have at least one report about keyboard with keys that are not supported by os/2 keyboard driver

6. License, responsibility and so on.

This program is freeware. This program is also my property. You can't change or use the sources (included). On the other hand if you have any idea how to improve it or have found a bug feel free to contact me. And of course there are no such things as any warranties. You may use this program for free but I'm not responsible for any data/hardware/health/anything else loss and/or damage.

7. Contacts

You can reach me by mail : vik@avi.kiev.ua. I will place new versions to my home page http://vik.avi.kiev.ua/software.phtml but connections there are very slow. Sorry.

8. History

0.21 ctrl-shift-left.win.key=shutdown system
remove.cmd - uninstall script added
0.23 Russian support added
0.25 Spanish support added
(Jordi Nadal i F bregas <jornadal@redestb.es>)
install/remove scripts modified
(Louis Mckinley <Mckinley.Louis@ic.gc.ca>)
0.26 Dutch support added
(Daniel Jacobs)
0.27  NLS
0.29  NLS
0.30  Minor bug fixed
0.31  Feature added
0.32  Italian support added. (Sergio Trovarelli )
2.0 b1 First 2.0 beta
2.0 b2 Key processing algorithm changed
2.0 b3 Menu added. Re-read config added
2.0 b4 realloc/free bug
2.0 b5 Key processing algorithm changed
2.0 b6 Mnemonic names added. Semaphore removed.
2.0 b7 OpenObject plugin semaphore added
2.0 b8 OpenObject plugin message removed. Memory allocation for event firing thread added (shame on me). Semaphore removed.
2.0 b9 Mod. names now case independent. A lot of little bugs fixed. Window pos and size saving added. Volume foo added.
2.0 b10-b12 Reload doesn't 'free' modifiers buffer. A lot of bugs fixed.
2.0 b13-b14 Attempt to 'free' unallocated memory (sys3175). 
Doesn't 'free' allocated memory. <g>
Conflicts with PMMail, Netscape etc. fixed. (os/2 sucks) 
Object desktop dll added but still not working ;) 
And (as usual) a lot of minor bugs fixed, such as 'k6^' instead 'k6'
PM configuration tool added!
2.0 b15 New parameter - use key presses instead releases. It tells w95k to fire event on key down instead default behavior (event fires when key releases)
Binaries has been moved to 'bin' dir (by Alex)
A lot of new bugs added ;)
Workaround for OpenObject foo (opened object was not at the top, move manually)
2.0 b16 Minor bug : event firing for released keys when configured to use key presses instead releases.
2.0 b17 New parameter for OpenObject plugin

Best regards
Vik