Is it possible to control capslock light without actual capslocking? - windows

I am using windows on my laptop. I also remapped caps lock to esc for smoother vim experience.
Now my caps lock light indicator is always off and I start wondering "Is it possible to use caps lock indicator for something else?". Something like blinking on request etc.
I never did something like that so I have very basic questions:
Can light indicator be separately turned on\off without actual caps lock functionality?

Unless your keyboard has its own API to control the lights (gaming keyboards sometimes do), or you have a custom keyboard driver that can control the lights, then what you are asking for is generally not possible with most keyboards, as Windows simply has no API to control just a keyboard's lights without also updating its key states.
UPDATE:
Apparently, there is such an API, after all:
IOCTL_KEYBOARD_QUERY_INDICATORS IOCTL
The IOCTL_KEYBOARD_QUERY_INDICATORS request returns information about the keyboard indicators.
IOCTL_KEYBOARD_SET_INDICATORS IOCTL
The IOCTL_KEYBOARD_SET_INDICATORS request sets the keyboard indicators.
You can use DefineDosDevice() and CreateFile() to open a HANDLE to the desired keyboard, and then use DeviceIoControl() to query the keyboard for its current KEYBOARD_INDICATOR_PARAMETERS, and then update its LedFlags field to include or omit the KEYBOARD_CAPS_LOCK_ON flag to turn the CapLock key's LED light on/off as needed.
See Manipulating the Keyboard Lights in Windows NT for an example.

Related

Using KeyRemap4MacBook to bind a keyboard key to a scroll action?

Basically, I want to bind a certain letter to scroll up the mouse reel, and do so continuously if I hold the key continuously. I need it to work even if other keys are being pressed at the same time, and only work on a certain window title/tab title in the browser.
I basically want to emulate the function of the autohotkey program for the "Attack On Titan Tribute Game"'s reeling function.
An AutoHotKey equivalent is available at:
http://fenglee.com/forum/viewtopic.php?f=2&t=7548
(Which may be offline due to unknown reasons, might have to wait)
Basically, if you download the application, set Reel In to the "x" or "e" key, it works regardless if other keys are being held. Just make sure you uncheck the checkbox so it can work in any window. It basically scrolls down for you. It also includes the source.
Or.. if I can use any other free application to do the same thing, that'd be nice.
All I want is the scrolling function and it has to be specific to a window/plugin/etc. and be able to be triggered while holding down other keys.

GetAsyncKeyState() causes anti-virus program to flag as keylogger

I have been building a very small game in the Windows API, and in the main message loop I use GetAsyncKeyState() to test if a user is pressing the arrow buttons. I use this instead of WM_KEYDOWN because with WM_KEYDOWN there is an initial pause after the first press, and I don't want to modify a user's settings. My antivirus program flags the game as a keylogger program, is there an alternative way about this?
How is the anti-virus program supposed to guess that you are not using GetAsyncKeyState() to spy on the keyboard and log keys? You tell it of course, make an exclusion. If you're worried that your future customers are not so easily convinced then go back to using WM_KEYDOWN/UP. Use an array of 256 bools to keep track of the key state. Set it to true on DOWN, regardless of how many you get, false on UP. Also check if the scanner is happy when you stop calling the API function when your app loses focus. Pay attention to WM_ACTIVATEAPP.

How can I fire a key press or mouse click event without touching any input device at system level?

How can I fire an automatic key press or mouse click event when a color appears on the screen
on other application or browser?
It depends a lot on what you want. Do you want to send the keys to
your Application
another fixed Application
Simulate a global keypress
Simulating keys globally
All of these will cause problems targeting a specific application and the active window changes.
SendKeys Sends Messages to the active app. It's a high level function taking a string which encodes a sequence of keys.
keybd_event is very low level and injects a global keypress. In most cases SendKeys is easier to use.
mouse_event simulates mouse input.
SendInput supersedes these functions. It's more flexible but a bit harder to use.
Sending to a specific window
When working with a fixed target window, sending it messages can work depending on how the window works. But since this doesn't update all states it might not always work. But you don't have a race condition with changing window focus, which is worth a lot.
WM_CHAR sends a character in the basic multilingual plane (16 bit)
WM_UNICHAR sends a character supporting the whole unicode range
WM_KEYDOWN and WM_KEYUP Sends keys which will be translated to characters by the keyboard layout.
My recommendation is when targeting a specific window/application try using messages first, and only if that fails try one of the lower level solutions.
when a color appears on the screen on other application or browser
I made one program using OpenCV and C++ for operating mouse with finger gesture. I used 3 color strips for 3 mouse function.
Yellow color for Left click
Blue color for Right click
Pink color for controlling cursor position
Whenever camera detect these colors, associated function takes place, I have used mouse_event for performing mouse function.
For more information you may read my code, blog, video.
I'm not 100% sure what you want, but if all you are after is running the method linked the the button.Clicked event, then you can manually run the method just like any other method.
You can use the .NET SendKeys class to send keystrokes.
Emulating mouse clicks requires P/Invoke.
I don't know how to detect colors on the screen.

Is it possible to programmatically turn on the Macbook Pro's keyboard backlight for individual keys?

Although I have a feeling that this isn't technically possible, it's worth asking anyways. Is it possible to turn on the Macbook Pro's keyboard backlights for individual keys? I am working on a piece of grid-based software which allows the user to navigate around by pressing any key on the keyboard to position the cursor at that point in the grid. It would be very cool if I could somehow just turn on the backlight for certain keys to give the user an easy way to see the current position of the cursor.
Is it even possible for an application to control the keyboard backlighting at all, let alone for individual keys?
Yes, on programs controlling the backlight.
iTunes visualizer that pusles keyboard backlighting to music:
http://www.youtube.com/watch?v=LUXLkwlF9e8
How to manually adjust (via plugin):
http://osxdaily.com/2006/11/30/how-to-manually-adjust-the-macbook-pro-keyboard-backlight/
Not sure on programs controlling individual keys, but as that would require additional hardware to be installed on Mac's part, i doubt it.
Well after trawling the webs, it looks like the answer to that is no. But I'd like to point out that each key does have its own key- a tiny little LED (same kind they use under phone keypad buttons). Also, I've seen some people saying that flashing these lights on and off repeatedly is bad for them. Bullshit- all digital electronics control light output from LED's by flashing on and off many many times a second. Read up on PWM on wikipedia or something..
Anyways just had to get that out there :)
Thanks,
Nic

Setting Virtual Key/MouseButton State Without Triggering Events

Is it possible to set the virtual key state / mouse button state for all programs on a computer without triggering the associated events at the same time (like setting the left mouse button to be currently pressed without sending a mouse down event). Could this be achieved by setting up a fake keyboard or mouse driver for a fake keyboard or mouse that when queried as to the current state of a key would reply giving an answer of your choice or by any other means?
Edit:
This has to affect programs that I do not have the code for running in other threads ect...
Well, I don't have a complete answer for you but...
The Win32 function SetKeyboard State() changes the state of the keyboard for the thread that called it.
I know this does not affect the entire system, but if you only need the keyboard state changed for applications you are developing, then this could be called by each program, reading in the array passed to it from a temporary file on the harddrive.
Otherwise... don't know of anything else offhand...

Resources