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

自动6s关闭大写

搜狗、微软输入法等

方法1(推荐

添加到热键-脚本,热键设置CAPITAL(大写锁定键),勾选激活、不注册


sp.DeleteTimer('Capsclose');
sp.DisplayTextClose();
var info = new DisplayTextInfo();
info.TitleFont = new Font('Segoe UI', 12, host.flags(FontStyle.Bold));
info.MessageFont = new Font("Segoe UI Semibold", 10);
info.ForeColor = "255,255,255";
info.Duration = 1000;
info.Location = "bottomleft";
info.Padding = 10;

if (sp.IsKeyToggled(vk.CAPITAL)) {
    info.BackColor = "37,146,52";
    info.Message = "CAPS Lock is ON";
    sp.DisplayText(info);

    //6秒后自动关闭Caps,不需要可以注释掉或者删除
    sp.CreateTimer('Capsclose', 6000, 0,
        `if (sp.IsKeyToggled(vk.CAPITAL)) {
            var info = new DisplayTextInfo();
            info.TitleFont = new Font('Segoe UI', 12, host.flags(FontStyle.Bold));
            info.MessageFont = new Font("Segoe UI Semibold", 10);
            info.BackColor = "37,146,52";
            info.BackColor = "200,56,70";
            info.Message = "CAPS Lock is OFF";
            info.Duration = 1000;
            info.Location = "bottomleft";
            info.Padding = 10;
            sp.DisplayText(info);
            sp.SendVKey(vk.CAPITAL);
        }`);

} else {
    info.BackColor = "200,56,70";
    info.Message = "CAPS Lock is OFF";

    sp.DisplayText(info);
}

方法2

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

重要设置:选项-高级-启动订阅键盘钩子事件

if(__spEngineWrapper.Engine.Name == sp.EngineList().Last().Engine.Name) {
     var keyboardEventObj = sp.GetStoredObject("keyboardEvent");
     if(!keyboardEventObj.GetType().FullName.includes('EventConnection')) {
         //Bind to the synchronous event
         var keyboardEvent = KeyboardHook.OnKeyboardHookEventAsync.connect(
             function (sender, keyboardHookEvent) {
                 //Wrap all code in try/catch, exceptions will crash S+, such as calling clip.SetText with a null value
                 try {
                     if(keyboardHookEvent.Key == vk.CAPITAL) {
                        if(keyboardHookEvent.KeyState == KeyState.Up) {
                            if(!sp.GetStoredBool("CAPSOn")) {
                                sp.StoreBool("CAPSOn", true); 
                                sp.CreateTimer('Capsclose', 6000,  0, `sp.SendVKey(vk.CAPITAL); sp.DeleteTimer('Capsclose');sp.StoreBool("CAPSOn", false);   `);
                            } else {
                                sp.StoreBool("CAPSOn", false); 
                                sp.DeleteTimer('Capsclose');
                            }
                        }
                    }
                }
                catch {}
            });
        sp.StoreObject("keyboardEvent", keyboardEvent);
    }
}
1 Like