How to change caps lock status without key press

前端 未结 2 376
清歌不尽
清歌不尽 2021-01-02 00:37

I am using a python program that is activate when pressing Caps Lock key and I want to be able to turn on/off the caps lock status when the program is active.

I trie

2条回答
  •  借酒劲吻你
    2021-01-02 00:59

    Use sendkeys to change the status and keyboardleds to change the LED indicators.

    sendkeys:

    From another SO dicussion:

    import SendKeys
    
    SendKeys.SendKeys("""
    {CAPSLOCK}
    {SCROLLOCK}
    {NUMLOCK}
    """)
    

    keyboardleds:

    This package seems to work only for POSIX (which is OK if you're using Ubuntu), and you can read more here.

提交回复
热议问题