rudi Posted July 22, 2020 Share Posted July 22, 2020 Hi. I just came across these two functions: _WinAPI_GetKeyboardLayout() _WinAPI_GetKeyboardLayoutList() That's something, that would be quite helpfull sometimes at a server, where I want a different keyboard layout, but I already fail to *GET* the current layout or the list of layouts. #include <WinAPISys.au3> $LayoutList=_WinAPI_GetKeyboardLayoutList ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $LayoutList = ' & $LayoutList & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $VarType=VarGetType($LayoutList) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $VarType = ' & $VarType & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $layout=_WinAPI_GetKeyboardLayout ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $layout = ' & $layout & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $VarType=VarGetType($Layout) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $VarType = ' & $VarType & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ; _WinAPI_ActivateKeyboardLayout >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\forum.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop @@ Debug(6) : $LayoutList = >Error code: 0 @@ Debug(8) : $VarType = UserFunction >Error code: 0 @@ Debug(10) : $layout = >Error code: 0 @@ Debug(12) : $VarType = UserFunction >Error code: 0 +>12:57:26 AutoIt3.exe ended.rc:0 +>12:57:26 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.7655 What is the variable type "UserFunction"? Looking up the functions in WinApiSYS.AU3 I'd expect either to receive an @error value or an array to be returned. $hWnd propably shall be a window handle, isn't it? expandcollapse popupWinAPISys.au3 ------------------- [snip] ; #FUNCTION# ==================================================================================================================== ; Author.........: Yashied ; Modified.......: Jpm ; =============================================================================================================================== Func _WinAPI_GetKeyboardLayout($hWnd) Local $aRet = DllCall('user32.dll', 'dword', 'GetWindowThreadProcessId', 'hwnd', $hWnd, 'ptr', 0) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) $aRet = DllCall('user32.dll', 'handle', 'GetKeyboardLayout', 'dword', $aRet[0]) If @error Then Return SetError(@error, @extended, 0) ; If Not $aRet[0] Then Return SetError(1000, 0, 0) Return $aRet[0] EndFunc ;==>_WinAPI_GetKeyboardLayout ; #FUNCTION# ==================================================================================================================== ; Author.........: Yashied ; Modified.......: jpm ; =============================================================================================================================== Func _WinAPI_GetKeyboardLayoutList() Local $aRet = DllCall('user32.dll', 'uint', 'GetKeyboardLayoutList', 'int', 0, 'ptr', 0) If @error Or Not $aRet[0] Then Return SetError(@error + 20, @extended, 0) Local $tData = DllStructCreate('handle[' & $aRet[0] & ']') $aRet = DllCall('user32.dll', 'uint', 'GetKeyboardLayoutList', 'int', $aRet[0], 'struct*', $tData) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $aList[$aRet[0] + 1] = [$aRet[0]] For $i = 1 To $aList[0] $aList[$i] = DllStructGetData($tData, 1, $i) Next Return $aList EndFunc ;==>_WinAPI_GetKeyboardLayoutList [/snip] What do I miss? Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
TheXman Posted July 22, 2020 Share Posted July 22, 2020 (edited) 1 hour ago, rudi said: What do I miss? 1 hour ago, rudi said: $LayoutList=_WinAPI_GetKeyboardLayoutList There is a difference between $LayoutList=_WinAPI_GetKeyboardLayoutList And $LayoutList=_WinAPI_GetKeyboardLayoutList() One assigns a user function to a variable and the other assigns the return value of the user function to a variable. Edited July 22, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
rudi Posted August 4, 2020 Author Share Posted August 4, 2020 (edited) On 7/22/2020 at 1:54 PM, TheXman said: There is a difference between $LayoutList=_WinAPI_GetKeyboardLayoutList And $LayoutList=_WinAPI_GetKeyboardLayoutList() One assigns a user function to a variable and the other assigns the return value of the user function to a variable. Doh 😣 Thx! Edited August 4, 2020 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
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