Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python mouse listener

import win32api
import time

width = win32api.GetSystemMetrics(0)
height = win32api.GetSystemMetrics(1)
midWidth = int((width + 1) / 2)
midHeight = int((height + 1) / 2)

state_left = win32api.GetKeyState(0x01)  # Left button down = 0 or 1. Button up = -127 or -128
while True:
    a = win32api.GetKeyState(0x01)
    if a != state_left:  # Button state changed
        state_left = a
        print(a)
        if a < 0:
            print('Left Button Pressed')
        else:
            print('Left Button Released')
            win32api.SetCursorPos((midWidth, midHeight))
    time.sleep(0.001)
Comment

PREVIOUS NEXT
Code Example
Python :: python logging silent 
Python :: time python 
Python :: gunicorn django static files 
Python :: How to Loop Through Sets in python 
Python :: python map function 
Python :: mnist 
Python :: import csv as dic 
Python :: Making a delete request using python 
Python :: tkinter fenstertitel 
Python :: how to use ActionChains selenium python with WebDriverWait 
Python :: split column and rename them 
Python :: argsort in descending order numpy 
Python :: django set cookie 
Python :: Python Difference between two timedelta objects 
Python :: python split space or tab 
Python :: python array linspace 
Python :: how to install qrcode module in python 
Python :: pair plot seaborn 
Python :: message to dict protobuf 
Python :: python append to a exiting csv file 
Python :: group a dataset 
Python :: sum of digits in python 
Python :: python meanGroups(a): 
Python :: leer fichero de texto con columnas como diccionario python 
Python :: Dictionary get both key and value. 
Python :: webdriver.chrome() python not working 
Python :: How to plot Feature importance of any model in python 
Python :: typer python 
Python :: numpy variance 
Python :: python integers 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =