mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
Add some User32 API
This commit is contained in:
@@ -1374,3 +1374,17 @@ BOOL WINAPI GetProcessDEPPolicy(
|
||||
_Out_ LPDWORD lpFlags,
|
||||
_Out_ PBOOL lpPermanent
|
||||
);
|
||||
|
||||
BOOL WINAPI GetCursorPos(
|
||||
_Out_ LPPOINT lpPoint
|
||||
);
|
||||
|
||||
HWND WINAPI WindowFromPoint(
|
||||
_In_ POINT Point
|
||||
);
|
||||
|
||||
|
||||
BOOL WINAPI GetWindowRect(
|
||||
_In_ HWND hWnd,
|
||||
_Out_ LPRECT lpRect
|
||||
);
|
||||
|
||||
@@ -2792,4 +2792,9 @@ typedef struct _CRYPT_ENCODE_PARA {
|
||||
DWORD cbSize;
|
||||
PVOID pfnAlloc;
|
||||
PVOID pfnFree;
|
||||
} CRYPT_ENCODE_PARA, *PCRYPT_ENCODE_PARA;
|
||||
} CRYPT_ENCODE_PARA, *PCRYPT_ENCODE_PARA;
|
||||
|
||||
typedef struct tagPOINT {
|
||||
LONG x;
|
||||
LONG y;
|
||||
} POINT, *PPOINT, *LPPOINT;
|
||||
File diff suppressed because one or more lines are too long
@@ -3468,6 +3468,15 @@ class _CRYPT_ENCODE_PARA(Structure):
|
||||
PCRYPT_ENCODE_PARA = POINTER(_CRYPT_ENCODE_PARA)
|
||||
CRYPT_ENCODE_PARA = _CRYPT_ENCODE_PARA
|
||||
|
||||
class tagPOINT(Structure):
|
||||
_fields_ = [
|
||||
("x", LONG),
|
||||
("y", LONG),
|
||||
]
|
||||
LPPOINT = POINTER(tagPOINT)
|
||||
PPOINT = POINTER(tagPOINT)
|
||||
POINT = tagPOINT
|
||||
|
||||
class tagRECT(Structure):
|
||||
_fields_ = [
|
||||
("left", LONG),
|
||||
|
||||
+35
-10
@@ -1,12 +1,30 @@
|
||||
import ctypes
|
||||
|
||||
import windows
|
||||
from windows import winproxy
|
||||
from windows.generated_def import *
|
||||
|
||||
|
||||
|
||||
callback_type = ctypes.WINFUNCTYPE(UINT, HWND, LPARAM)
|
||||
|
||||
|
||||
class Point(POINT):
|
||||
def __repr__(self):
|
||||
return "<{0} x={1} y={2}>".format(type(self).__name__, self.x, self.y)
|
||||
#return "<{0} x={1:#x} y={2:#x}>".format(type(self).__name__, self.x, self.y)
|
||||
|
||||
class Rect(RECT):
|
||||
def __repr__(self):
|
||||
return "<{0} left={1} top={2} right={3} bottom={4}>".format(type(self).__name__, self.left, self.top, self.right, self.bottom)
|
||||
#return "<{0} x={1:#x} y={2:#x}>".format(type(self).__name__, self.x, self.y)
|
||||
|
||||
|
||||
def get_cursor_pos():
|
||||
res = Point()
|
||||
winproxy.GetCursorPos(res)
|
||||
return res
|
||||
|
||||
class Window(object):
|
||||
def __init__(self, handle):
|
||||
self.handle = handle
|
||||
@@ -18,6 +36,23 @@ class Window(object):
|
||||
res = windows.winproxy.GetWindowTextA(self.handle, buffer, size)
|
||||
return buffer[:res]
|
||||
|
||||
def rect(self):
|
||||
res = Rect()
|
||||
winproxy.GetWindowRect(self.handle, res)
|
||||
return res
|
||||
|
||||
def size(self):
|
||||
rect = self.rect()
|
||||
width = rect.right - rect.left
|
||||
heigth = rect.bottom - rect.top
|
||||
return width, heigth
|
||||
|
||||
@classmethod
|
||||
def at_point(cls, point):
|
||||
handle = winproxy.WindowFromPoint(point)
|
||||
return cls(handle)
|
||||
|
||||
|
||||
# I don't understand the interest:
|
||||
# Either return "" or C:\Python27\python.exe
|
||||
#def module(self):
|
||||
@@ -39,13 +74,3 @@ def enumwindows():
|
||||
if not result:
|
||||
raise
|
||||
return result
|
||||
|
||||
|
||||
v = enumwindows()
|
||||
|
||||
for i in v:
|
||||
w = Window(i)
|
||||
if w.name():
|
||||
print("{0} -> {1} ".format(i, w.name()))
|
||||
|
||||
raise "YOLO"
|
||||
|
||||
@@ -1131,6 +1131,19 @@ GetWindowModuleFileNameA = TransparentUser32Proxy('GetWindowModuleFileNameA', no
|
||||
GetWindowModuleFileNameW = TransparentUser32Proxy('GetWindowModuleFileNameW', no_error_check)
|
||||
GetSystemMetrics = TransparentUser32Proxy('GetSystemMetrics', no_error_check)
|
||||
|
||||
@User32Proxy("GetCursorPos")
|
||||
def GetCursorPos(lpPoint):
|
||||
return GetCursorPos.ctypes_function(lpPoint)
|
||||
|
||||
|
||||
@User32Proxy("WindowFromPoint")
|
||||
def WindowFromPoint(Point):
|
||||
return WindowFromPoint.ctypes_function(Point)
|
||||
|
||||
@User32Proxy("GetWindowRect")
|
||||
def GetWindowRect(hWnd, lpRect):
|
||||
return GetWindowRect.ctypes_function(hWnd, lpRect)
|
||||
|
||||
# ## Version stuff ## #
|
||||
|
||||
@VersionProxy("GetFileVersionInfoA")
|
||||
|
||||
Reference in New Issue
Block a user