StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
soooulp  
#1 Posted : Friday, March 26, 2021 11:05:07 AM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 4/23/2020(UTC)
Posts: 67
China

Thanks: 14 times
Was thanked: 3 time(s) in 2 post(s)
This script will auto close the Capslock after 6s when it is on.

Put the following code in Global Actions-Load/Unload

Code:

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');  `);//6秒自动关闭Caps
                            } else {
                                sp.StoreBool("CAPSOn", false); 
                                sp.DeleteTimer('Capsclose');
                            }
                        }
                    }
                }
                catch {}
            });
        sp.StoreObject("keyboardEvent", keyboardEvent);
    }
}

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.