This commit is contained in:
恍兮惚兮 2024-12-29 15:00:43 +08:00
parent 5937a7afdd
commit a4edf162fd
4 changed files with 23 additions and 3 deletions

View File

@ -289,3 +289,11 @@ DECLARE_API void html_bind_function(void *web, const wchar_t *name, void (*funct
auto ww = static_cast<MWebBrowserEx *>(web);
ww->jsobj->bindfunction(name, function);
}
DECLARE_API HWND html_get_ie(void *web)
{
if (!web)
return nullptr;
auto ww = static_cast<MWebBrowserEx *>(web);
return ww->GetIEServerWindow();
}

View File

@ -1428,7 +1428,7 @@ class mshtmlWidget(abstractwebview):
self.curr_url = None
t = QTimer(self)
t.setInterval(100)
t.timeout.connect(self.__getcurrenturl)
t.timeout.connect(self.__getcurrent)
t.timeout.emit()
t.start()
self.add_menu(0, _TR("复制"), winsharedutils.clipboard_set)
@ -1449,11 +1449,19 @@ class mshtmlWidget(abstractwebview):
func(winsharedutils.html_get_select_text(self.browser))
return windows.WNDPROCTYPE(orig)(hwnd, msg, wp, lp)
def __getcurrenturl(self):
def __getcurrent(self):
_u = winsharedutils.html_get_current_url(self.browser)
if self.curr_url != _u:
self.curr_url = _u
self.on_load.emit(_u)
if (
windows.GetAsyncKeyState(windows.VK_CONTROL)
and windows.GetAsyncKeyState(67)
and winsharedutils.html_get_ie(self.browser) == windows.GetFocus()
):
winsharedutils.clipboard_set(
winsharedutils.html_get_select_text(self.browser)
)
def navigate(self, url):
winsharedutils.html_navigate(self.browser, url)

View File

@ -265,6 +265,8 @@ FindWindow.argtypes = LPCWSTR, LPCWSTR
FindWindow.restype = HWND
SetFocus = _user32.SetFocus
SetFocus.argtypes = (HWND,)
GetFocus = _user32.GetFocus
GetFocus.restype = HWND
_EnumWindows = _user32.EnumWindows
_EnumWindows.argtypes = WNDENUMPROC, c_void_p
_ShellExecuteW = _shell32.ShellExecuteW

View File

@ -139,7 +139,9 @@ html_get_select_text.restype = c_wchar_p
html_bind_function_FT = CFUNCTYPE(None, POINTER(c_wchar_p), c_int)
html_bind_function = utilsdll.html_bind_function
html_bind_function.argtypes = c_void_p, c_wchar_p, html_bind_function_FT
html_get_ie = utilsdll.html_get_ie
html_get_ie.argtypes = (c_void_p,)
html_get_ie.restype = HWND
_GetLnkTargetPath = utilsdll.GetLnkTargetPath
_GetLnkTargetPath.argtypes = c_wchar_p, c_wchar_p, c_wchar_p, c_wchar_p