Rank: Advanced Member
Groups: Approved
Joined: 4/23/2020(UTC) Posts: 56  Thanks: 11 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: thepromises  Originally Posted by: lyscop  Originally Posted by: Rob  This worked for me. It creates a timer that checks every 250 milliseconds for the state of the Caps Lock key and shows a message at the bottom of the screen for 2 seconds when the state changes. Green background when Caps Lock is ON, red when it is OFF. Put script in: Global Actions > Load/Unload > Loadcheck Enable Load Automation
Code:sp.CreateTimer("CAPSWatch",
250,
250,
`if(sp.IsKeyToggled(vk.CAPITAL)) {
if(sp.GetStoredBool("CAPSOn") === false) {
sp.StoreBool("CAPSOn", true);
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.ForeColor = "255,255,255";
info.Message = "CAPS Lock is ON";
info.Duration = 2000;
info.Location = "bottom";
info.Padding = 10;
sp.DisplayText(info);
}
} else {
if(sp.GetStoredBool("CAPSOn") === true) {
sp.StoreBool("CAPSOn", false);
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 = "200,56,70";
info.ForeColor = "255,255,255";
info.Message = "CAPS Lock is OFF";
info.Duration = 2000;
info.Location = "bottom";
info.Padding = 10;
sp.DisplayText(info);
}
}`
);
Hi, Rob, How to keep the green message show if the caps lock is on, and it will miss when the caps lock is off. Then, whether it can show a message when the Microsoft input change to the Chinese input method.
Code:
sp.CreateTimer("CAPSWatch",
250,
250,
`if(sp.IsKeyToggled(vk.CAPITAL)) {
if(sp.GetStoredBool("CAPSOn") === false) {
sp.StoreBool("CAPSOn", true);
var info = new DisplayTextInfo();
info.TitleFont = new Font('Segoe UI', 12, host.flags(FontStyle.Bold));
info.MessageFont = new Font("Segoe UI Semibold", 18);
info.BackColor = "0,0,0";
info.ForeColor = "255,255,255";
info.Message = "CapsLock is ON";
info.Duration = 86400;
info.Location = "bottom";
info.Padding = 15;
sp.DisplayText(info);
}
} else {
if(sp.GetStoredBool("CAPSOn") === true) {
sp.StoreBool("CAPSOn", false);
var info = new DisplayTextInfo();
info.TitleFont = new Font('Segoe UI', 12, host.flags(FontStyle.Bold));
info.MessageFont = new Font("Segoe UI Semibold", 18);
info.BackColor = "0,0,0";
info.ForeColor = "255,255,255";
info.Message = "CapsLock is OFF";
info.Duration = 500;
info.Location = "bottom";
info.Padding = 15;
sp.DisplayText(info);
}
}`
);
哈哈设置时间我想到了,试下Rob的方法,很好用 避免了弹其他消息覆盖掉这个消息框,所以得消息都叠加在这个里面显示
|