stuncloud / UWSCR

UWSC互換スクリプト実行ツール
MIT License
46 stars 4 forks source link

inputダイアログに対してIMEが利用不可能になる場合がある #185

Open stuncloud opened 1 month ago

stuncloud commented 1 month ago

概要

なにかしらのダイアログ (msgbox, input, slctbox) を表示後にinputダイアログを表示すると、そのダイアログに対してIMEが使用できなくなる

再現スクリプト

INPUT("IME使える")
INPUT("IME使えなくなる")

再現手順

No response

バージョン

1.0.1

不具合発生環境

Windows 10

stuncloud commented 1 month ago

IMEが無効になってしまう原因がなにかしらあると思われるが、全く見当がつかないのでひとまず対症療法的な対応を試みる

このケースではWINNLSEnableIMEが有効かもしれない 以下のように利用されている

https://radioc.web.fc2.com/weblib/ms/dev16/402022.htm

発生状況が似通っており、効果も期待できる

stuncloud commented 1 month ago

この現象についてgeminiに聞いてみた結果


The issue you're experiencing with IME being disabled after closing a dialog and then reopening one with an edit control could be caused by several factors related to the Win32 API and IME interactions. Here are some potential causes to investigate:

  1. IME Context Disassociation:

    When you close the first dialog, the IME context associated with the edit control might be getting dissociated from the window. This can happen if the dialog's HWND is destroyed or if the IME context is explicitly removed using functions like ImmDestroyContext. When you reopen the dialog with the edit control, a new IME context needs to be created and associated with the control, but this might not be happening correctly due to the previous context being lost.

  2. IME Thread Issues:

    IME functionality is managed on a per-thread basis. If the IME thread is terminated or restarted after closing the first dialog, it could disrupt the IME context association and cause IME to be disabled in the subsequent dialog.

  3. Dialog Creation Flags:

    The flags used when creating the dialog windows might be affecting the IME behavior. Check if you're using flags like WS_EX_NOIME or WS_EX_NOINPUTIME that could be intentionally disabling IME for the dialogs.

  4. IME Configuration Changes:

    If the user or a program modifies the IME configuration settings between closing and reopening the dialogs, it could lead to IME being disabled in the second dialog. This might involve changes to input locales, IME hotkeys, or other IME-related settings.

  5. Third-party IME Interference:

    If you're using a third-party IME instead of the default Windows IME, there might be compatibility issues or bugs in the third-party IME that are causing the problem. Try switching back to the default IME temporarily to see if the issue persists.

To troubleshoot the issue effectively, consider these steps:

  1. Debug IME Context Association:

    Use IME management functions like ImmGetContext and ImmAssociateContext to track the IME context association state throughout the process of closing and reopening the dialogs. Check if the context is being properly associated with the edit control's window handle.

  2. Verify IME Thread Stability:

    Ensure that the IME thread is not being terminated or restarted unexpectedly. Use debugging tools to monitor thread creation and destruction events.

  3. Review Dialog Creation Flags:

    Double-check the flags used when creating the dialog windows to ensure they are not explicitly disabling IME. Remove any unnecessary flags that might be affecting IME behavior.

  4. Monitor IME Configuration Changes:

    Track any changes to IME configuration settings using system events or IME notification mechanisms. Identify if any configuration changes coincide with the IME being disabled.

  5. Test with Default IME:

    Temporarily switch to the default Windows IME and check if the issue persists. If the problem disappears, investigate compatibility issues with the third-party IME.

By carefully examining these potential causes and following the troubleshooting steps, you should be able to pinpoint the root cause of the IME disablement issue and implement appropriate solutions to restore proper IME functionality in your Win32 dialogs.

stuncloud commented 1 month ago

WINNLSEnableIME では解決せず

のいずれにも効果なし

stuncloud commented 1 month ago

input関数を二度呼び、最初の正常な状態と次の現象発生状態を比較すると以下の通り

初回 現象発生時 備考
タスクバー表示 表示あり 表示なし (※1)
WINNLSEnableIME TRUE TRUE IMEは無効になっていないっぽい
ImmGetContext 正常に取得可 正常に取得可 IME自体は存在しているっぽい
ImmGetOpenStatus FALSE 初回の状態を返す 初回にIMEオンならTRUE、オフならFALSE
ImmSetOpenStatusをTRUE 影響なし 影響なし 初回もIMEオンにならない
ImmGetConversionStatus
lpfdwconversion IME_CONVERSION_MODE(25) IME_CONVERSION_MODE(9) ※2
lpfdwsentence IME_SENTENCE_MODE(8) IME_SENTENCE_MODE(8)
ImmSetConversionStatus 25にしても影響なし ※3
stuncloud commented 1 month ago

Windows 11でも再現した

stuncloud commented 4 weeks ago

https://stackoverflow.com/questions/2325383/windows-language-bar-will-not-show-input-method-options-for-some-of-my-windows#2333571

stuncloud commented 3 weeks ago