04-28-2013 11:14 PM - last edited on 04-29-2013 04:22 PM by JordanG
Hello Folks,
I've tried to configure a CLFN to force the windows keyboard layout to some language. LabVIEW crashed, I'm not sure what I dont understand... But I thought maybe some of you could create a vi using the following links.
LoadKeyboardLayout function
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646305(v=vs.85).aspx
ActivateKeyboardLayout function
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646289(v=vs.85).aspx
There is probably a way to use any windows dll function following the same guidelines, I might be afraid by the HKL typedef...
The community already shows us how to get the keyboardlayout using labview, now we could document how to set it.
https://decibel.ni.com/content/docs/DOC-14903
Kind regards!
04-29-2013 03:42 PM - edited 04-29-2013 03:46 PM
Next time don't post links that redirect through your own Outlook webhost interface, but the direct ones.
So lets look at the functions:
HKL WINAPI LoadKeyboardLayout( _In_ LPCTSTR pwszKLID, _In_ UINT Flags );
This function has a C String Pointer parameter and an uInt32 one. It returns a HKL which is a handle and best represented as a pointer sized (unsigned) integer, to avoid potential problems about 32 Bit / 64 bit Windows.
You have to watch out that this function is an ANSI/Unicode combo and therefore you have to call the actual function LoadKeyboardLayoutA() with the appended A, since that is the ANSI function and LabVIEW uses ANSI strings too.
HKL WINAPI ActivateKeyboardLayout( _In_ HKL hkl, _In_ UINT Flags );
This takes an HKL and an uInt32 and returns another HKL. Nothing new in comparison to the previous function so that should be easy.
If you still seem to have trouble show as what you have done so far that does not work.
04-29-2013 05:25 PM
Hello Rolf,
thanks for your answer. I've tried by reading carefully your explanations. Attached what I think should be working, but it freezes at the first CLFN, I put 1 as HKL as described in MSDN...
The primary U.S. English layout is named "00000409"
Thanks for caring,
Jimmy
04-30-2013 02:20 PM
Well, first. the WINAPI keyword in the function prototype is synomym to stdcall calling convention. Change that for one.
Second, change the library path inside the configuration to user32.dll instead of the absolute path which can be different on different Windows versions.
Third, although this won't crash you as long as you execute this VI only on LabVIEW for 32 bit Windows, change the HKL parameters to be pointer sized integers instead of 32 bit integers.
04-30-2013 02:28 PM
Well, I followed your instructions, and it doesn't crash anymore. Bonus, it changes the KeyboardLayout as expected.
Thank you very much Rolf, and have a nice day.