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:
|
try:
|
||||||
hwnd = gobject.baseobject.textsource.hwnd
|
hwnd = gobject.baseobject.textsource.hwnd
|
||||||
|
if not hwnd:
|
||||||
|
raise
|
||||||
except:
|
except:
|
||||||
hwnd = windows.GetForegroundWindow()
|
hwnd = windows.GetForegroundWindow()
|
||||||
|
|
||||||
@ -77,7 +79,6 @@ def grabwindow(app, callback=None):
|
|||||||
_()
|
_()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getprocesslist():
|
def getprocesslist():
|
||||||
|
|
||||||
pids = windows.EnumProcesses()
|
pids = windows.EnumProcesses()
|
||||||
@ -233,5 +234,6 @@ def mouseselectwindow(callback):
|
|||||||
def screenshot(x1, y1, x2, y2, hwnd=None):
|
def screenshot(x1, y1, x2, y2, hwnd=None):
|
||||||
bs = winsharedutils.gdi_screenshot(x1, y1, x2, y2, hwnd)
|
bs = winsharedutils.gdi_screenshot(x1, y1, x2, y2, hwnd)
|
||||||
pixmap = QPixmap()
|
pixmap = QPixmap()
|
||||||
pixmap.loadFromData(bs)
|
if bs:
|
||||||
|
pixmap.loadFromData(bs)
|
||||||
return pixmap
|
return pixmap
|
||||||
|
@ -375,6 +375,8 @@ def gdi_screenshot(x1, y1, x2, y2, hwnd=None):
|
|||||||
rect.right = x2
|
rect.right = x2
|
||||||
rect.bottom = y2
|
rect.bottom = y2
|
||||||
bf = _gdi_screenshot(hwnd, rect, pointer(sz))
|
bf = _gdi_screenshot(hwnd, rect, pointer(sz))
|
||||||
|
if not (sz.value and bf):
|
||||||
|
return None
|
||||||
data = cast(bf, POINTER(c_char))[: sz.value]
|
data = cast(bf, POINTER(c_char))[: sz.value]
|
||||||
c_free(bf)
|
c_free(bf)
|
||||||
return data
|
return data
|
||||||
|
@ -158,6 +158,9 @@ BYTE *SaveBitmapToBuffer(HBITMAP hBitmap, size_t *size)
|
|||||||
}
|
}
|
||||||
DECLARE BYTE *gdi_screenshot(HWND hwnd, RECT rect, 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)
|
if (!hwnd)
|
||||||
hwnd = GetDesktopWindow();
|
hwnd = GetDesktopWindow();
|
||||||
auto hdc = GetDC(hwnd);
|
auto hdc = GetDC(hwnd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user