比如怎样改变输入法,检测到输入法改变的函数等。
谢谢。

解决方案 »

  1.   

    这个代码使我有一年用PB编程的时候需要进行输入法控制的时候用的。里面用了API函数,你可以看一下
    //外部函数声明
    function boolean ImmSimulateHotKey (ULong hWnd, ULong dwHotKeyID) library "IMM32.dll" 
        function ulong GetKeyboardLayout(ulong dwLayout) LIBRARY "user32.dll" 
        function boolean ImmIsIME(uLong hklKeyboardLayout) library "IMM32.DLL" 
    ////////////////////////////////////////
    ulong hklCurrent 
        ulong hnd //在第一个文本框中的getfocus事件中添加代码
        //切换到英文输入法
        hklCurrent=GetKeyboardLayout(0) 
     boolean ceshi
     ceshi=ImmIsIME(hklCurrent)
    //  messagebox ("ceshi",string(ceshi))
        if ImmIsIME(hklCurrent)=false then 
    messagebox ("a","只能输入英文字符")
           hnd=Handle(this) 
           ImmSimulateHotKey(hnd,265) 
    else
    messagebox ("a","是汉字输入状态,请切换输入法") //this is chinese cord
           sle_2.setfocus()
        end if //注:在VC中,可以查看IME方面的资料,IME是input method edit的意思
      

  2.   

    输入法改变时会发送WM_IME_SELECT消息,可以用钩子截获。
      

  3.   

    WM_IME_SELECT
    The WM_IME_SELECT message is sent to an application when the system is about to change the current IME. An application that has created an IME window should pass this message to that window so that it can retrieve the keyboard layout handle for the newly selected IME. 上面是关于WM_IME_SELECT的介绍,这个消息会发送到应用程序(窗口),那么我为什么接收不到这个消息,必须要用钩子吗?
    此外还有方法知道输入法改变了吗?
      

  4.   

    再来个好心人吧!
    我现在只想知道用户何时打开了输入法,(也就是用户何时按下了CTRL+SPACE,可是我接收不到这个消息)。楼上说的WM_IME_SELECT,我为什么也接收不到呢。
      

  5.   

    应用程序(窗口)接收不到这个消息。输入法改变时只能收到WM_IME_NOTIFY消息。
    你可以用spy++查查看。
      

  6.   

    我能收到WM_IME_NOTIFY消息,可是这个消息中那个命令对应输入法状态的改变呢,我是指输入法的开启或者关闭。(我都试过了,好像也没有啊)
      

  7.   

    还是用钩子吧。
    else if(((LPSENDMSG)lParam)->message==WM_IME_SELECT)
    {
    HWND hWndIME = (HWND)(((LPSENDMSG)lParam)->lParam);
    if((int)hWndIME == 67699721)
    lstrcpy(szPlayText, "英文输入法");
    else if((int)hWndIME == -535951356)
    lstrcpy(szPlayText, "微软拼音输入法");
    else if((int)hWndIME == -536803324)
    lstrcpy(szPlayText, "全拼输入法");
    else if((int)hWndIME == -536606716)
    lstrcpy(szPlayText, "智能ABC输入法");
    else if((int)hWndIME == -536672252)
    lstrcpy(szPlayText, "郑码输入法");
    else if((int)hWndIME == 535754748)
    lstrcpy(szPlayText, "王码五笔输入法");
    else if((int)hWndIME == -536541180)
    lstrcpy(szPlayText, "区位码输入法");
    else if((int)hWndIME == -536737788)
    lstrcpy(szPlayText, "双拼输入法");
    else if((int)hWndIME == -536082428)
    lstrcpy(szPlayText, "表形码输入法");
    ::PostMessage(g_hWnd, WM_READOUT,0,0);
    }
      

  8.   

    不好意思,再次请教:
    1使用全局钩子还是针对自己的钩子?
    2使用什么类型的钩子,是WH_GETMESSAGE么?
    3最后,hWndIME == -536606716是怎么得到的(纯属好奇^o^)