Python Windows przełącz Caps_Lock

from ctypes import windll
from win32api import GetKeyState
from win32con import VK_CAPITAL

class KEY_SYSTEM:
    def toggle_capslock(self, turn_on):
        '''
        toggle_capslock(int) ->  int

        Turns CAPSLOCK on or off and returns whether
        it was originally on or off.        '''

        KEYEVENTF_KEYUP = 2
        KEYEVENTF_EXTENDEDKEY = 1
        KEYEVENTF_KEYUP = 2

        is_on = GetKeyState(VK_CAPITAL) & 1

        if is_on != turn_on:
            windll.user32.keybd_event(VK_CAPITAL,
                                      69,
                                      KEYEVENTF_EXTENDEDKEY | 0,
                                      0)
            windll.user32.keybd_event(VK_CAPITAL, 69,
                                      KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                                      0)
        return is_on

    def get_caps_lock_status(self):
        return GetKeyState(VK_CAPITAL)

KEY_SYSTEM().toggle_capslock(0)
structure