Is there a method where I can set windows transparently to caps preferrably when a specific application is run. For bonus points, I should be able to revert back to normal (non capslock mode) when the application is terminated.

I googled and went through SO/SF but I don't even know where to start to find the answer.

Thanks

  • 3
    Not sure why this has four close votes on it, but come on... this is a perfectly valid question. For example, this comes up all the time when accessing an AS/400 (IBM iSeries mainframe) from a Windows client machine. The mainframe's set up such that keyboard input needs to be capital letters, but the same people pulling info off the mainframe don't want to sending out emails in all caps... and evidently, hitting the caps lock button from time to time is too much of a burden on the users. – HopelessN00b Feb 5 '14 at 7:34
  • 2
    @HopelessN00b Agreed, although this is not a "common issue", I'd say it's definitely within the bounds of "professional system administration" – Mathias R. Jessen Feb 5 '14 at 13:34
  • I read this as "display all in caps" thus my answer, not "force input into all caps". That's a big difference and the question needs to be clarified. – mfinni Feb 5 '14 at 14:37
up vote 6 down vote accepted

You can easily toggle CAPS LOCK using PowerShell, just import some virtual keyboard magic from user32.dll:

$importDef = @"
using System.Runtime.InteropServices;

public class CapsControls 
{

enum virtKeys : int 
{
    vkCaps = 0x14 
}

[DllImport("user32.dll")] 
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo); 

[DllImport("user32.dll")] 
static extern short GetKeyState(virtKeys nVirtKey);

public static void ToggleCaps() 
{
    keybd_event(virtKeys.vkCaps, 0x45, 0x1, 0);
    keybd_event(virtKeys.vkCaps, 0x45, 0x3, 0); 
}

public static void EnableCaps() 
{

    if((GetKeyState(virtKeys.vkCaps) % 2) == 0)
    {
        ToggleCaps();
    } 
}

public static void DisableCaps() 
{

    if((GetKeyState(virtKeys.vkCaps) % 2) != 0)
    {
        ToggleCaps();
    } 
}

} 
"@

Add-Type -TypeDefinition $importDef

Now you can control caps lock from a PowerShell session:

[CapsControls]::ToggleCaps() # simulate a CAPS key press
[CapsControls]::EnableCaps() # if disabled, CAPS key press
[CapsControls]::DisableCaps() # if enabled, CAPS key press

If possible, invoke it from the application, but you could use a scheduled task to run the command every time the application is launched

  • Perfect, that's a starting point, thank you – SteveMustafa Feb 5 '14 at 17:32

No, you can't, using system tools. There might be some 3rd party tools for this.

You could try and change the Windows Color and Appearance settings to change the system display fonts, and you could change it to a font that is only caps. This won't work in all application however.

How about you define the problem you're solving, rather than ask us for help with the solution that you're looking at? Why did you tag this as "batch" and "powershell"? Those don't appear to be related to anything in your question as written.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.