Skip to content

fix whole_screenshot #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions MBPython/screenshot.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# -*- coding:utf-8 -*-
from ctypes import windll
from ctypes import windll,create_string_buffer,byref,c_int,c_void_p,c_longlong
import platform
from .winConst import WinConst
import win32gui, win32ui
import win32ui
from struct import pack
import collections
import zlib


_LRESULT = c_longlong if platform.architecture()[0]=='64bit' else c_int


user32=windll.user32
def to_png(data, size, level=6, file_name=None):
width, height = size
Expand Down Expand Up @@ -109,16 +113,20 @@ def whole_screenshot(mb,webview,file_name):

left=0
top=0
mb.wkeGetContentWidth.argtypes = [_LRESULT]
mb.wkeGetContentHeight.argtypes = [_LRESULT]
width=mb.wkeGetContentWidth(webview)
height=mb.wkeGetContentHeight(webview)
pixels=create_string_buffer(width*height*4)
mb.wkeResize(webview,width,height)
mb.wkeUpdate()
mb.wkePaint.argtypes = [_LRESULT,c_void_p,c_int]
mb.wkePaint(webview,byref(pixels),0)
img=pixelsParse(data=bytearray(pixels), left=left
,top=top,width=width,height=height)
to_png(img.rgb, img.size, level=6, file_name=file_name)
pixels=None
img=None
return True

return True