Created
April 18, 2019 08:00
-
-
Save Lvl4Sword/4e3a552156e6047c4ca7ee2340d8c2ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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