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?


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.

fn test5() {
    unsafe {
        if let Err(e) = Com::CoInitializeEx(
        ) {
            println!("{:?}", e);
        let b = &TextServices::CLSID_TF_LangBarItemMgr.clone() as *const GUID;
        let c = Com::CoCreateInstance::<Option<&IUnknown>, TextServices::ITfLangBarItemMgr>(
        if let Ok(res) = c
            .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());


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
我的笔记 编辑

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.