NumLock switched off when launching Notepad++



  • Every time I launch Notepad++ on my Windows 10 laptop, NumLock is Switched OFF.
    I have used the Computer\HKEY_USERS.DEFAULT\Control Panel\Keyboard\InitialKeyboardIndicators=2 registry hack to switch Numlock ON when the machine boots, and it will stay on only until the point where I start Notepad++.
    This is driving me up the walls!
    Is there a way to prevent the NumLock from getting set to OFF when launching Notepad++?



  • @Theo-Fondse

    There is probably a better solution, but until you find it you could script turning Num Lock back on after Notepad++ starts up with the Pythonscript plugin.

    Put the following code in startup.py and make sure Pythonscript’s “Initialisation” option is set to ATSTARTUP (under the Configuration menu option for the Pythonscript plugin). Note that Pythonscript is only 32-bit right now, so it will only work with 32-bit Notepad++.

    I really hope you find a better solution and don’t have to resort to this !! :-D

    If this (or ANY posting on the Notepad++ Community site) is useful, don’t reply with a “thanks”, simply up-vote ( click the ^ in the ^ 0 v area on the right ).

    import ctypes
    
    def turn_on_numlock():
        VK_NUMLOCK = 0x90
        KEYEVENTF_EXTENDEDKEY = 0x01
        KEYEVENTF_KEYUP = 0x02
        GetKeyState = ctypes.windll.user32.GetKeyState
        keybd_event = ctypes.windll.user32.keybd_event
        if not GetKeyState(VK_NUMLOCK):
            keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0)
            keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0)
    
    turn_on_numlock()

Log in to reply