notes/snippet/python/get_pos.py

21 lines
430 B
Python

#coding=utf-8
import time
import pyautogui
def main():
print('Click Ctrl-C to exit')
width, height = pyautogui.size()
try:
while True:
x, y = pyautogui.position()
print('screen width: {0}, height: {1}, position x: {2}, y: {3}'.format(width, height, x, y))
time.sleep(0.5)
except KeyboardInterrupt:
print('Stopped')
if __name__ == '__main__':
main()