Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Sean McArdle | e7534ee0a5 | |
Sean McArdle | 83d5d65fa3 | |
Sean McArdle | 172549e4ce |
|
@ -24,6 +24,8 @@ namespace KeyWatch__
|
|||
static bool NumLock { get { return (((ushort)GetKeyState(0x90)) & 0xffff) != 0; } }
|
||||
static bool ScrollLock { get { return (((ushort)GetKeyState(0x91)) & 0xffff) != 0; } }
|
||||
|
||||
private static volatile bool _doingWork = false;
|
||||
|
||||
private string _numlockSelection;
|
||||
private string _capslockSelection;
|
||||
private string _scrolllockSelection;
|
||||
|
@ -48,13 +50,15 @@ namespace KeyWatch__
|
|||
|
||||
|
||||
bool watching = _manageCaps || _manageNum || _manageScroll;
|
||||
if (!watching) { return; }
|
||||
|
||||
if (!watching) return; // nothing to manage, who cares
|
||||
if (_doingWork) return; // already working on things, skip
|
||||
|
||||
_doingWork = true;
|
||||
// Set desired key state
|
||||
if (_manageNum) {
|
||||
if (_numlockSelection != null) {
|
||||
if ((_numlockSelection == "Enabled" && !NumLock) ||
|
||||
(_numlockSelection == "Disabled" && NumLock)){
|
||||
(_numlockSelection == "Disabled" && NumLock)) {
|
||||
_sim.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.NUMLOCK);
|
||||
Trace.WriteLine(String.Format("{0} - enable Numlock", DateTime.Now));
|
||||
}
|
||||
|
@ -69,10 +73,12 @@ namespace KeyWatch__
|
|||
}
|
||||
if (_manageScroll) {
|
||||
if ((_scrolllockSelection == "Enabled" && !ScrollLock) ||
|
||||
(_scrolllockSelection == "Disabled" && ScrollLock))
|
||||
_sim.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SCROLL);
|
||||
Trace.WriteLine(String.Format("{0} - disable Scrolllock", DateTime.Now));
|
||||
(_scrolllockSelection == "Disabled" && ScrollLock)) {
|
||||
_sim.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SCROLL);
|
||||
Trace.WriteLine(String.Format("{0} - disable Scrolllock", DateTime.Now));
|
||||
}
|
||||
}
|
||||
_doingWork = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue