Jump to content

"else" not executed in "if.. then.. else.."


Go to solution Solved by Jos,

Recommended Posts

I have (mostly) used copy paste to switch between 2 keyboard layouts:

$hWnd= WinGetHandle("[active]")
if _GetKeyboardLayout($hWnd = "0000040D") then
    _SetKeyboardLayout("00000409", $hWnd)
else
    _SetKeyboardLayout("0000040D", $hWnd)
endif


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

Func _SetKeyboardLayout($sLayoutID, $hWnd)
    Local $WM_INPUTLANGCHANGEREQUEST = 0x50
    Local $ret = DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", $sLayoutID, "int", 0)
    DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, _
                                                "int", $WM_INPUTLANGCHANGEREQUEST, _
                                                "int", 1, _
                                                "int", $ret[0])
EndFunc

 

Problem is the "else" statement never get executed. I switched the "if" statements and always the 1st is executed, never the second, "else" statement.

I have tested previously the _GetKeyboardLayout function, and it worked as it should.

 

btw, How do I insert text in code format?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...