mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-15 00:43:59 +08:00
safe
This commit is contained in:
parent
4c6866c9ad
commit
f7a05e5680
@ -51,6 +51,8 @@ def grabwindow(app, callback=None):
|
||||
_()
|
||||
try:
|
||||
hwnd = gobject.baseobject.textsource.hwnd
|
||||
if not hwnd:
|
||||
raise
|
||||
except:
|
||||
hwnd = windows.GetForegroundWindow()
|
||||
|
||||
@ -77,7 +79,6 @@ def grabwindow(app, callback=None):
|
||||
_()
|
||||
|
||||
|
||||
|
||||
def getprocesslist():
|
||||
|
||||
pids = windows.EnumProcesses()
|
||||
@ -233,5 +234,6 @@ def mouseselectwindow(callback):
|
||||
def screenshot(x1, y1, x2, y2, hwnd=None):
|
||||
bs = winsharedutils.gdi_screenshot(x1, y1, x2, y2, hwnd)
|
||||
pixmap = QPixmap()
|
||||
if bs:
|
||||
pixmap.loadFromData(bs)
|
||||
return pixmap
|
||||
|
@ -375,6 +375,8 @@ def gdi_screenshot(x1, y1, x2, y2, hwnd=None):
|
||||
rect.right = x2
|
||||
rect.bottom = y2
|
||||
bf = _gdi_screenshot(hwnd, rect, pointer(sz))
|
||||
if not (sz.value and bf):
|
||||
return None
|
||||
data = cast(bf, POINTER(c_char))[: sz.value]
|
||||
c_free(bf)
|
||||
return data
|
||||
|
@ -158,6 +158,9 @@ BYTE *SaveBitmapToBuffer(HBITMAP hBitmap, size_t *size)
|
||||
}
|
||||
DECLARE BYTE *gdi_screenshot(HWND hwnd, RECT rect, size_t *size)
|
||||
{
|
||||
*size = 0;
|
||||
if (rect.bottom == rect.top || rect.left == rect.right)
|
||||
return nullptr;
|
||||
if (!hwnd)
|
||||
hwnd = GetDesktopWindow();
|
||||
auto hdc = GetDC(hwnd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user