event python code example
Example 1: 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)
while True:
a = win32api.GetKeyState(0x01)
if a != state_left:
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)
Example 2: button click event in python
button_element = driver1.find_element_by_id('button event')
button_element.click()