xsharp.eu • CapsLock(), InsMode() , NumLock() - Page 2
Page 2 of 2

CapsLock(), InsMode() , NumLock()

Posted: Wed Apr 14, 2021 5:03 am
by Karl-Heinz
Hi Robert,

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.

Code: Select all

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 

regards
Karl-Heinz

CapsLock(), InsMode() , NumLock()

Posted: Wed Apr 14, 2021 7:02 am
by robert
Karl-Heinz ,
The naming is OK. Since these are internal structures there is very little change of naming conflicts anyway.
Robert

CapsLock(), InsMode() , NumLock()

Posted: Wed Apr 14, 2021 7:52 pm
by Karl-Heinz
Guys,

in the attachment you find the latest VFPKeyboard.viaef
,
regards
Karl-Heinz

CapsLock(), InsMode() , NumLock()

Posted: Thu Apr 15, 2021 10:19 am
by robert
Karl-Heinz,

I'll include this in the upcoming 2.8 release

Robert

CapsLock(), InsMode() , NumLock()

Posted: Thu May 06, 2021 1:56 pm
by Karl-Heinz
Guys,

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