Complete keyboard/mouse input filtering API
I'd like to see (and possibly reject) all keyboard and mouse input going to the WebView.
add_AcceleratorKeyPressed is good, but incomplete. It would be great if it routed full input message range, WM_MOUSEFIRST to WM_MOUSELAST and WM_KEYFIRST to WM_KEYLAST.
Alternatively, expose a HWND that can be subclassed for filtering purposes.
You could use a Hook Proc and qualify it to a specific window(s).
You could use a Hook Proc and qualify it to a specific window(s).
Actually, the issue is as I understand that a window (where all messages are passed to) is in another process (due to ActiveX nature of WebView2) which means that the only way to get to those messages would be to inject some dll and set a hook in browser process.
So yes, the filtering API - so you can have an access to all messages coming to browser window would be a good idea). Actually, if you look at CefSharp and their approach to hosting Chromium you have an access (by use of NativeWindow class) to all messages coming to a specific browser window.
@pagoe-msft : When do you plan to add such a thing into WebView2 API ? This would be a very nice feature. Many thanks :)
Just to +1. My use case is the user being able to push the mouse forward button and have the app react by switching to the next item in a list. I've accomplished this both in CefSharp and previously the old IE control by using window messages in the manner described above without any problem and having the same ability here would be great.
You could use a Hook Proc and qualify it to a specific window(s).
Actually, the issue is as I understand that a window (where all messages are passed to) is in another process (due to ActiveX nature of WebView2) which means that the only way to get to those messages would be to inject some dll and set a hook in browser process.
While you can put a hook in an EXE for that process only, Hooks are typically in a DLL and SetWindowsHookEx attaches to all processes when dwThreadId is set to zero. https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowshookexa
The thing is that with WH_GETMESSAGE hook I am not able to filter out WM_POINTERUPDATE messages even though I pass WM_NULL to MSG structure. Browser still reacts on touch moves. This is quite odd as tried even to filter out WM_INPUT. Hook was established on legacy chrome window (HWND renderer wimdow) in msedge process hosting this window. Done with SetWindowsHookEx.
What is so special about msedge in WM_POINTER handling ?
wt., 26 maj 2020, 17:37 użytkownik douglas-jordan [email protected] napisał:
You could use a Hook Proc and qualify it to a specific window(s).
Actually, the issue is as I understand that a window (where all messages are passed to) is in another process (due to ActiveX nature of WebView2) which means that the only way to get to those messages would be to inject some dll and set a hook in browser process.
While you can put a hook in an EXE for that process only, Hooks are typically in a DLL and SetWindowsHookEx attaches to all processes when dwThreadId is set to zero.
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowshookexa
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MicrosoftEdge/WebViewFeedback/issues/112#issuecomment-634103364, or unsubscribe https://github.com/notifications/unsubscribe-auth/APVYBFXSQMN77ZMXSHTRXMDRTPO47ANCNFSM4KMYBCRQ .
I want to intercept WM_MOUSEWHEEL and to handle nested scrolling (ListView + multiple webview2):
https://user-images.githubusercontent.com/11593903/148534836-4335c1fa-169b-484a-9007-30ad4dae7cf5.mp4
but subclassing won't help:
LRESULT CALLBACK WndProc1(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
WNDPROC superProc = (WNDPROC)::GetProp(hWnd, L"proc");
switch (message)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_CONTEXTMENU:
case WM_MOUSEMOVE:
case WM_MOUSEWHEEL:
// never
return 1;
default:
return superProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
HWND realHBrowser = FindChildWindow(_hWnd, L"Intermediate D3D Window");
//realHBrowser = FindChildWindow(_hWnd, L"Chrome_RenderWidgetHostHWND");
//realHBrowser = FindChildWindow(_hWnd, L"Chrome_WidgetWin_1");
//realHBrowser = FindChildWindow(_hWnd, L"Chrome_WidgetWin_0");
::SetProp(realHBrowser, L"proc", (HANDLE)GetWindowLongPtr(realHBrowser, GWLP_WNDPROC));
::SetWindowLongPtr(realHBrowser, GWLP_WNDPROC, (LONG_PTR)WndProc1);
Calling EnableWindow(hwnd, false); on all WebView windows causes it to produce a weird BEEP sound. It's like 3rd hour of me trying to disable input on the webview, because it should be handled by an another child window. Is this like really impossible at the moment or is there any workaround?
It is really frustrating that this basic functionality is not available in Edge WebView2 - 3 years after being reported.
In my case, CoreWebView2Settings.IsScriptEnabled is set to false to disable unwanted JavaScript (like web beacons in emails or other unwanted JS) but that also disables onkeydown or onmousedown event so using injected JavaScript to return key code something like document.onkeydown = function(e) { window.chrome.webview.postMessage(e.keyCode); e.preventDefault(); }; is really not an option. It must be WM_KEYDOWN capture in app (I am using Win32).
Subclasssing doesn't help and as mentioned above add_AcceleratorKeyPressed is incomplete.
And the same problem exists also for WM_LBUTTONDOWN because mouse events are also needed and again for the same reason cannot be solved by injecting JavaScript.
+1 Here Been scratching my head for two days now and I give up There are 5 different child windows within my app's parent window, related to WebView2, but WndProc of none of them works, so I assume it's sitting in another process.
I'd also be interested if anyone here managed to do it, any method or anything