azot/Azot/X.py

31 lines
838 B
Python
Raw Normal View History

2015-07-22 10:27:29 +03:00
from Xlib import display
2015-07-28 09:59:16 +03:00
from time import sleep
2015-07-28 12:28:37 +03:00
from Azot.logger import warning
2015-07-28 10:07:28 +03:00
2016-05-19 11:01:10 +03:00
working_display = display.Display()
working_screen = working_display.screen()
root_window = working_screen.root
2015-07-22 10:27:29 +03:00
# Get screen resolution
def get_geometry():
2015-07-27 16:52:11 +03:00
while 1:
try:
2016-05-19 11:01:10 +03:00
width = working_screen.width_in_pixels
height = working_screen.height_in_pixels
2015-07-27 16:52:11 +03:00
return {"x": width, "y": height}
2016-05-19 11:01:10 +03:00
except Exception as e:
2015-07-28 10:07:28 +03:00
warning(str(e) + '\n' + 'Spleep for 10 second')
2015-07-28 09:59:16 +03:00
sleep(10)
2015-07-22 10:27:29 +03:00
# Get mouse cursor position
def get_cursor_position():
2015-07-27 16:52:11 +03:00
while 1:
try:
2016-05-19 11:01:10 +03:00
data = root_window.query_pointer()._data
2015-07-22 10:27:29 +03:00
2015-07-27 16:52:11 +03:00
return {'x': data['root_x'], 'y': data['root_y']}
2016-05-19 11:01:10 +03:00
except Exception as e:
2015-07-28 10:07:28 +03:00
warning(str(e) + '\n' + 'Spleep for 10 second')
2016-05-19 11:01:10 +03:00
sleep(10)