Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python Windows Toggle 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)
Comment

PREVIOUS NEXT
Code Example
Python :: dataframe to DatasetDict 
Python :: deoplete 
Python :: python synta error 
Python :: how to access clipboard with python 
Python :: parsing date columns when reading csv 
Python :: series multiindex values 
Python :: python interate with two list 
Python :: get list values in b/w indexes python 
Python :: the most effective search method in python with example 
Python :: visualising centroid of an unsupervised learning algorithm 
Python :: python store salt in csv 
Python :: what is topic modelling in nlp 
Python :: bold colors in pytohn 
Python :: function for getting the basic statistic of our Dataframe in one go 
Python :: appropriate graph for data visualization 
Python :: install mangadex python 
Python :: TypeError: strptime() argument 1 must be str, not list 
Python :: Insert datframe column at specific place 
Python :: How to Use the abs() Function with an Integer Argument 
Python :: lists as parameters in stats.f_oneway 
Python :: appears in json dump 
Python :: i type nano in python and o get error 
Python :: infinty in python 
Python :: gpt2 simple restore_from 
Python :: Python Script to check how many images are broken 
Python :: how is pythons glob.glob ordered list 
Python :: django cms create page programmatically 
Python :: ios iterate through dictionary 
Python :: pyqt5 how to see if clipboard is empty 
Python :: how to deploy a file size greater than 100mb on pythonanywhere 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =