StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
A script to auto close the Capslock after 6s
Rank: Advanced Member
Groups: Approved
Joined: 4/23/2020(UTC) Posts: 67  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/UnloadCode:
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);
}
}
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
A script to auto close the Capslock after 6s
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.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close