StrokesPlus.net教程及脚本持续更新

输入法英文状态的时候桌面下方提示,Shift切换后关闭

代码由作者发布S+net官方论坛,依据AHK输入法状态查询

如果不需要提示输入法状态,只需要大写键按下提示,弹起提示关闭,添加第二部分代码,并且注释开始结束之间的代码

添加到全局动作-启动/退出-启动(开启)

第一部分

//Define IME constants
const WM_IME_CONTROL = 0x283;
const IMC_GETOPENSTATUS = 0x005;

//If the Imm32 module has not already been defined
if(!NativeModules.Imm32)
{
    var IntPtrT = host.typeOf(System.IntPtr);

    //Define imm32 type
    var imm32TB = sp.NativeModule().DefineType("Imm32", "Class,Public,SequentialLayout,Serializable");
         
        //Define the platform invoke call
        //From: https://docs.microsoft.com/en-us/windows/win32/api/imm/nf-imm-immgetdefaultimewnd
        imm32TB.DefinePInvokeMethod("ImmGetDefaultIMEWnd",
                                                                 "imm32.dll",
                                                                 [IntPtrT],
                                                                 IntPtrT,
                                                                 "PreserveSig");        

        //Create the type (finalize, now made an official C# class)                                         
    imm32TB.Create();                                                                 

    //Note: Changes cannot be made to a class once created. If you need to change or add
    //      anything, you must restart S+ to update the class.
}

第二部分

sp.CreateTimer("LangWatch",
               250,
               250,
               `var info = new DisplayTextInfo();
                 
               info.TitleFont = new Font('Segoe UI', 12, host.flags(FontStyle.Bold));
               info.MessageFont = new Font("Segoe UI Semibold", 12);
               info.BackColor = "15,179,98";  //绿
               info.ForeColor = "255,255,255";
               info.Duration = 1000;
               info.Opacity = 0.5;
               //info.Location = "679,765";
               info.Location = "190,809";
               //info.Location = "0,0";
               //info.Location = "bottom";
               //info.FadeSteps = 10;
               info.Padding = 10;
               info.Message = "";

                if(sp.IsKeyToggled(vk.CAPITAL)) {//大写键监控
                    info.Message = "CAPS Lock is ON";

                }

                //开始
                var imeWnd = NativeModules.Imm32.ImmGetDefaultIMEWnd(sp.ForegroundWindow().HWnd);

                //Send the message and store return value
                var ret = sp.WindowFromHandle(imeWnd).SendMessageObj(WM_IME_CONTROL, IMC_GETOPENSTATUS, 0x0);


                if(ret.ToInt32() === 0) {
                    if(info.Message.length > 0) {
                        info.Message += " - ";
                        info.BackColor = "255,105,180";//粉
                        info.Location = "190,809";
                    } else {
                        info.BackColor = "56,142,142";//墨绿
                        info.Location = "325,809";
                    }
                    info.Message += "En Keyboard ACTIVE";  
                }
                //结束

                if(info.Message.length > 0) {
                    if(sp.GetStoredBool("LangShown")) {
                        sp.DisplayTextUpdate(info);
                    } else {
                        sp.DisplayText(info);
                        sp.StoreBool("LangShown", true);
                    }
                } else {
                    //sp.DisplayTextClose();
                    sp.StoreBool("LangShown", false);
                }
               `
);