Skip to content

Instantly share code, notes, and snippets.

@Lvl4Sword
Created April 18, 2019 08:00
Show Gist options
  • Save Lvl4Sword/4e3a552156e6047c4ca7ee2340d8c2ad to your computer and use it in GitHub Desktop.
Save Lvl4Sword/4e3a552156e6047c4ca7ee2340d8c2ad to your computer and use it in GitHub Desktop.
import collections
import pyautogui
import pyscreeze
import sys
def MousePosition():
"""This function is meant to be run from the command line. It will
automatically display the location and RGB of the mouse cursor."""
print('Press Ctrl-C to quit.')
try:
while True:
# Get and print the mouse coordinates.
x, y = pyautogui.position()
positionStr = 'X: {0:4} Y: {1:4}'.format(x, y)
sys.stdout.write(positionStr)
sys.stdout.write('\b' * len(positionStr))
sys.stdout.flush()
except KeyboardInterrupt:
sys.stdout.write('\n')
sys.stdout.flush()
MousePosition()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment