LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActivateKeyboardLayout Call Library Function Node

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!

0 Kudos
Message 1 of 5
(4,506 Views)

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.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 5
(4,464 Views)

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

0 Kudos
Message 3 of 5
(4,453 Views)

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.

 

 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 5
(4,437 Views)

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.

0 Kudos
Message 5 of 5
(4,434 Views)