move computeruse prototype into separate folder

This commit is contained in:
talksik
2025-06-28 07:29:37 -07:00
parent d7fff8a58a
commit 57133f3d2c
4 changed files with 2 additions and 1 deletions
+39
View File
@@ -0,0 +1,39 @@
'''
This script simulates a double-click at the given mouse cursor position.
'''
import Quartz
from time import sleep
def post_mouse_event(type, pos, click_state):
event = Quartz.CGEventCreateMouseEvent(
None, type, pos, Quartz.kCGMouseButtonLeft
)
Quartz.CGEventSetIntegerValueField(event, Quartz.kCGMouseEventClickState, click_state)
Quartz.CGEventPost(Quartz.kCGHIDEventTap, event)
def double_click (x, y):
pos = None
if x is None or y is None:
# Get current mouse position if no coordinates are provided
loc = Quartz.CGEventGetLocation(Quartz.CGEventCreate(None))
pos = (loc.x, loc.y)
else:
# Use provided coordinates
pos = (x, y)
# First click
post_mouse_event(Quartz.kCGEventLeftMouseDown, pos, 1)
post_mouse_event(Quartz.kCGEventLeftMouseUp, pos, 1)
sleep(0.05) # Short delay within double-click threshold
# Second click
post_mouse_event(Quartz.kCGEventLeftMouseDown, pos, 2)
post_mouse_event(Quartz.kCGEventLeftMouseUp, pos, 2)
if __name__ == "__main__":
print('test: double clicking at cursor position in 3 seconds...')
sleep(3)
double_click()