Sending WM_INPUTLANGCHANGEREQUEST to some applications hangs them

309 Views Asked by At

I am writing custom keyboard switcher and found, that some applications hang with it. First I thought, that there is an endless loop in my app or something like this, but the found, that even sending a message with 3rd party tool can hang the app.

enter image description here

Examples of the apps hanging are Comsol Multyphysics 5.3a and Pinnacle Studio 20.

I read somewhere, that this can be the problem with Qt, but on my side I don't undestand, how can I detect such applications and control them without hanging?


Can it be this issue: https://bugreports.qt.io/browse/QTBUG-59889


I don't understand, why doesn't application hang if I change language with toolbar widget? According to documentation, it does the same: posts WM_INPUTLANGCHANGEREQUEST message!


I have captured messages with Spy++ and saw the default switcher doesn't send this message, it sends only

enter image description here

I don't understand, how application knows which language to choose if WM_INPUTLANGCHANGE it sends itself.

1

There are 1 best solutions below

1
On

I solved this problem The reason is that qt has a bug in processing WM_INPUTLANGCHANGEREQUEST

# 重写窗口消息处理
def wndProc(self, hWnd, msg, wParam, lParam):
    if msg == 80:
        logger.info("msg={},wParam={},lParam={}".format(msg, wParam, lParam))
        # 如果是英文输入法
        if lParam == 67699721:
            # 手动调api切换英文输入法
            intptr = LoadKeyboardLayout("0409", 1)
            ActivateKeyboardLayout(intptr, KLF_ACTIVATE)
            # 禁止向下传递消息
            return False
        # sougou
        # if lParam == 134481924:
        #     return False
    return CallWindowProc(
        self.oldWndProc,
        hWnd,
        msg,
        wParam,
        lParam
    )