1import win32gui # pip install win32gui
2
3def get_cursor_flag():
4 #Get the cursor flag (visibility)
5 flag, hcursor, (x, y) = win32gui.GetCursorInfo()
6 return flag
7
8def run(flags):
9 if flags == 0:
10 # Cursor currently hidden
11 elif flags == 1:
12 # Cursor currently visible
13 else:
14 # Should not happen
15
16cursor_flag = get_cursor_flag()
17run(cursor_flag)