Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # get_mouse.py - Displays the mouse cursor's current positions.
- import pyautogui
- print('Press Ctrl+C to quite.')
- # Get and print the mouse coordinates.
- try:
- while True:
- x, y = pyautogui.position()
- postion_str = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
- pixcel_color = pyautogui.screenshot().getpixel((x,y))
- postion_str += ' RGB: (' + str(pixcel_color[0]).rjust(3) + ', ' + str(pixcel_color[1]).rjust(3) + ', ' + str(pixcel_color[2]).rjust(3) + ')'
- print(postion_str, end='')
- print('\b' * len(postion_str), end='', flush = True)
- except KeyboardInterrupt:
- print('\nDone.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement