I want to use Rust to implement an input method state overlay that follows the cursor (only displayed when typing) but can't get the input method state in real time, how to solve it?

Describe

As the problem, I want to implement an input method status overlay that will be displayed when entering, but I am stuck in using the Windows library to get the current input method state. At present, you can use the TSF API of window to get the configuration information of the input method (the code is as follows), but it doesn't seem to be useful. It's a pain in the Egg Pain.


#[allow(dead_code)]
fn test5() {
    unsafe {
        if let Err(e) = Com::CoInitializeEx(
            Option::Some(std::ptr::null_mut()),
            Com::COINIT_MULTITHREADED,
        ) {
            println!("{:?}", e);
        }
        println!("sucess");
        let b = &TextServices::CLSID_TF_LangBarItemMgr.clone() as *const GUID;
        let c = Com::CoCreateInstance::<Option<&IUnknown>, TextServices::ITfLangBarItemMgr>(
            b,
            None,
            Com::CLSCTX_ALL,
        );
        if let Ok(res) = c
            .unwrap()
            .GetItem(&TextServices::GUID_TFCAT_TIP_KEYBOARD.clone() as *const GUID)
        {
            println!("{:?}", res);
            println!("{:?}", res.GetStatus());
            let mut rrr = TextServices::TF_LANGBARITEMINFO::default();
            let rrr_ptr = &mut rrr as *mut TextServices::TF_LANGBARITEMINFO;
            if let Ok(_) = res.GetInfo(rrr_ptr) {
                println!("--{:?}", *rrr_ptr);
            };
            println!("{:?}", res.GetTooltipString());
        }
    }
}

Subsequent

Status display is one of the basic functions. The functions that I want to achieve in the future include intelligent switching. But it seems to be stuck in the cradle. T . T
有道在线词典
翻译结果
状态展示是基础功能之一 后续想要实现的功能还有智能切换等 但貌似直接卡死在摇篮里了. T . T
Status display is one of the basic features that we want to implement later and smart switching and so on but it seems to be stuck in the cradle. T . T
我的笔记 编辑