Simulate key to activate Caps Lock

Discussion in 'Mac Programming' started by CMT, Mar 19, 2011.

  1. CMT macrumors member

    CMT

    Joined:
    Aug 24, 2009
    #1
    Is there any way to simulate a key press in order to activate/deactivate CapsLock programmatically?

    I've been searching for simulating keys but caps lock remains untouched.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    This shows how to detect caps lock being pressed

    This shows how to create a low-level key event.

    I'd have though that you could combine these to do what you want…


    Edit: or not. Having read the first link it may not be possible without interfacing with the keyboard driver...
     
  3. CMT thread starter macrumors member

    CMT

    Joined:
    Aug 24, 2009
    #3
    Indeed the author says at the end:

    Looks like it will not be that simple. Maybe it's time to give a try to AppleScript?

    Thanks robbieduncan
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    You could try this. But installing a custom keyboard driver does seem a touch extreme..
     
  5. CMT thread starter macrumors member

    CMT

    Joined:
    Aug 24, 2009
    #5
    Hmm, quite extreme. Anyway, I don't think it's an interesting idea to ask users (from my app) to install such keyboard hack…

    Back to AppleScript, looks like
    Code:
    key code
    could solve the problem (Help Library > System Events > Processes Suite > key code). The only problem is that I need to know how to use this, AppleScript is not one of my strengths.

    Back to google… :)
     

Share This Page