i finally added "XS" to the names of the two new members and the two modified structures. i think that signals that not the original structure declarations are used.
INTERNAL CLASS Win32
CONST INTERNAL KEYEVENTF_KEYUP := 2 AS INT
CONST INTERNAL VK_INSERT := 45 AS INT
CONST INTERNAL VK_NUMLOCK := 144 AS INT
CONST INTERNAL VK_CAPITAL := 20 AS INT
CONST INTERNAL TYPE_KEYBOARD := 1 AS INT
[DllImport("user32.dll", SetLastError := TRUE)] ;
INTERNAL STATIC METHOD SendInput(nInputs AS DWORD , pInputs AS winInputXS[], cbSize AS LONG ) AS DWORD
[DllImport("user32.dll", SetLastError := TRUE)] ;
INTERNAL STATIC METHOD GetKeyState(nVirtkey AS INT) AS SHORTINT
[StructLayout(LayoutKind.Sequential)];
INTERNAL STRUCTURE winKeyboardInputXS
INTERNAL wVk AS WORD
INTERNAL wScan AS WORD
INTERNAL dwFlags AS DWORD
INTERNAL time AS DWORD
INTERNAL dwExtraInfo AS IntPtr
INTERNAL Unused1XS AS DWORD
INTERNAL UnUsed2XS AS DWORD
END STRUCTURE
[StructLayout(LayoutKind.Sequential)] ;
INTERNAL STRUCTURE winInputXS
INTERNAL Type AS DWORD
INTERNAL Input AS winKeyboardInputXS
END STRUCTURE
END CLASS
Attached is a app that handles the insert key via a keyboard hook. To round things up, i implemented a local (app only) and a global keyboard hook. A global hook doesn't make much sense in this particular case, so it's added just to show the different behavior.
The name of the attached app is still VFPKeyboard.viaef, but because i added a VO window with a sle to test the insert key, the app requires now the VO dialect.
In the Start() method you can decide whether you want to install a local (app only) or a global keyboard hook. Just change the content of the logic var 'lUseGlobalHook' in the start() method. If a global hook is installed, switch to another app and press the insert key. When you look at the terminal window, you will see now a message that the insert key state has changed. This does not happen if a local (app only) keyboard hook is installed.
BTW. I doubt that it's always possible to detect correctly at startup the current insert key state.
regards
Karl-Heinz
Attachments
[The extension viaef has been deactivated and can no longer be displayed.]