/
get_desktop_icon_list_gui.py
78 lines (57 loc) · 1.98 KB
/
get_desktop_icon_list_gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'ipetrash'
def get_desktop_resolution():
"""
Функция возвращает разрешение экрана.
"""
from ctypes.wintypes import RECT
from win32con import MONITOR_DEFAULTTONEAREST
import ctypes
MonitorFromWindow = ctypes.windll.user32.MonitorFromWindow
GetMonitorInfo = ctypes.windll.user32.GetMonitorInfoW
class MONITORINFO(ctypes.Structure):
_fields_ = [
('cbSize', ctypes.c_int),
('rcMonitor', RECT),
('rcWork', RECT),
('dwFlags', ctypes.c_int),
]
from get_desktop_icon_list import GetDesktopListViewHandle
hwnd = GetDesktopListViewHandle()
monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST)
info = MONITORINFO()
info.cbSize = ctypes.sizeof(MONITORINFO)
GetMonitorInfo(monitor, ctypes.byref(info))
width = info.rcMonitor.right - info.rcMonitor.left
height = info.rcMonitor.bottom - info.rcMonitor.top
return width, height
try:
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
except:
try:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
except:
from PySide.QtGui import *
from PySide.QtCore import *
if __name__ == '__main__':
app = QApplication([])
width_desktop, height_desktop = get_desktop_resolution()
scene_rect = QRectF(0, 0, width_desktop, height_desktop)
scene = QGraphicsScene()
scene.addRect(scene_rect)
scene.setSceneRect(scene_rect)
from get_desktop_icon_list import get_desktop_icons_list
for i, name, pos, rect in get_desktop_icons_list():
x, y, w, h = pos.x, pos.y, rect.right - rect.left, rect.bottom - rect.top
scene.addRect(x, y, w, h)
view = QGraphicsView()
view.setWindowTitle('winapi_get_desktop_icon_list')
view.setScene(scene)
n = 3
view.scale(1.0 / n, 1.0 / n)
view.show()
app.exec_()