I am not aware of a method to catch a mouse click event without an associated window to catch it from a GUI library.
I know there is a way by using pygame. But I expect a simpler way to implement because the program is not for game for sure.
It doesnt *have* to be a game to use pygame. In reality its just another GUI library with tools geared for gaming. Simpler? I mean its less than 15 lines of code.
- Code: Select all
import pygame as pg
running = True
screen = pg.display.set_mode((600,400))
for event in pg.event.get():
if event.type == pg.QUIT:
running = False
elif event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
print('mouse button 1 pressed down')
elif event.type == pg.MOUSEBUTTONUP and event.button == 1:
print('mouse button 1 released')
but you have to have the window up and in focus for it to catch the mouse click