steff Posted May 31, 2011 Posted May 31, 2011 (edited) Hello, helpful people I have several Windows system with input configured as in the attached image: - Default input language: Italian - Keyboard: Swiss German Italian I need to run a Unix Virtual Machine and configure it passing the correct keyboard setting, this because in my company we have an application which only runs under Linux, and we can't afford to give the users two different systems, or forcing them to switch one another. Apart from that, the main problem is that using the WinAPIEx.au3 _WinAPI_GetKeyboardLayout doesn't return the actual layout the keyboard is configured with. It's always returning the 00000410, which is the italian layout, even if the Swiss German layout is set. I don't even understand where this actual layout is kept: in the registry, all I can see is: HKEY_CURRENT_USER\Keyboard Layout\Preload 1 = d0010410 2 = 00000410 (Italian) and HKEY_CURRENT_USER\Keyboard Layout\Substitutes d0010410 = 00000807 (German Swiss) To be more explainful, here is the test I do: - start with Language bar set to Italian - run notepad.exe - activate the notepad window and set the language to be Swiss German - run the following script: Opt("WinTitleMatchMode", 2) Sleep(500) $hWnd = WinGetHandle("Notepad") MsgBox (0, "Keyboard code for window: " & $hWnd, _GetKeyboardLayout($hWnd)) Func _GetKeyboardLayout($hWnd) Local $ret = DllCall("user32.dll", "long", "GetWindowThreadProcessId", "hwnd", $hWnd, "ptr", 0) $ret = DllCall("user32.dll", "long", "GetKeyboardLayout", "long", $ret[0]) Return "0000" & Hex($ret[0], 4) EndFunc I expect the script to return the German Swiss code (0000807). Instead, it return the italian one (00000410) Does anybody have any hint? Thanks in advance stef Edited May 31, 2011 by steff
steff Posted May 31, 2011 Author Posted May 31, 2011 After some research, I arrive to this MSDN page that suggested me to run a search in this forum and to get this post: The GetKeyboardLayoutName function always return the keyboard layout code.
guinness Posted May 31, 2011 Posted May 31, 2011 (edited) And @KBLayout OR _WinAPI_GetKeyboardLayout() in WinAPIEx.au3 by Yashied. Edited May 31, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
steff Posted June 1, 2011 Author Posted June 1, 2011 (edited) And @KBLayout OR _WinAPI_GetKeyboardLayout() in WinAPIEx.au3 by Yashied.Actually, they don't return the real keyboard layout: please read my initial post.As MSDN states:GetKeyboardLayout FunctionRetrieves the active input locale identifier (formerly called the keyboard layout) for the specified thread.So, if my input locale identifier is = Italian and my keyboard is Swiss German, _WinAPI_GetKeyboardLayout() returns the Italian code.As far as I researched, with three different computer with different keyboard layout, the GetKeyboardLayoutName function always return the correct keyboard layout code . Edited June 1, 2011 by steff
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now