Here is a simple script to make a keyboard's LED blink
Copy the script below and save it as .wsf
Rem blinking LED :vstsv
<package> <job id="vbs"> <script language="VBScript"> set WshShell = WScript.CreateObject("WScript.Shell") For count=0 to 10 WshShell.SendKeys "{CAPSLOCK}" WScript.Sleep 500 WshShell.SendKeys "{NUMLOCK}" WScript.Sleep 500 WshShell.SendKeys "{SCROLLLOCK}" WScript.Sleep 500 Next </script> </job> </package>
|
The other alternative for Windows user is to use SendKeys Python module. You can find it
here. The page also contains good tutorial and documentation.
import SendKeys SendKeys.SendKeys(""" {CAPSLOCK} {PAUSE 1} {NUMLOCK} {PAUSE 1} {SCROLLLOCK} {PAUSE 1} """)
|
JAVA can be used to get the same results.
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
public class SendKeys {
public boolean numlock(boolean s) {
Toolkit tool = Toolkit.getDefaultToolkit();
try {
tool.setLockingKeyState(KeyEvent.VK_NUM_LOCK, s);
} catch (Exception e) {
return false;
}
return true;
}
public boolean capslock(boolean s) {
Toolkit tool = Toolkit.getDefaultToolkit();
try {
tool.setLockingKeyState(KeyEvent.VK_CAPS_LOCK, s);
} catch (Exception e) {
return false;
}
return true;
}
public boolean scrolllock(boolean s) {
Toolkit tool = Toolkit.getDefaultToolkit();
try {
tool.setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, s);
} catch (Exception e) {
return false;
}
return true;
}
public static void main(String[] args) throws Exception {
SendKeys flasher = new SendKeys();
for(int i=0;i<10;i++){
flasher.numlock(true);
Thread.sleep(500);
flasher.numlock(true);
Thread.sleep(500);
flasher.capslock(true);
Thread.sleep(500);
flasher.capslock(true);
Thread.sleep(500);
flasher.scrolllock(true);
Thread.sleep(500);
flasher.scrolllock(true);
Thread.sleep(500);
}
}
} |
nice one..
ReplyDelete