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
ExecuteScript with Win32/C++: Need synchronous return value #1905
Comments
Hey @MarkusSchreiner - Sorry for the delay here. We aren't planning to support a synchronous version of this function. The C++ |
Do we have a way to proceed with Sync return from ExecuteScript available from webview2? Anything considered? Or how can we achieve await like functionality with C++? |
@MarkusSchreiner When we tried the above sample code, we do not see any message pump in the while loop in the function and invoke was never called. |
@raroraca I implemented the callback handler the 'old school' way, perhaps sharing the code of this class helps you:
|
very good!thanks |
Can you provide a complete demo? QueryInterface doesn't seem to work when I try to run it. function asleep(ms) {
} I expect results {"totalTime":2000} , not {} |
I also need a proper way to retrieve the return value of a HTML embedded Java Scripts.
(see issues #838 and #840 )
Thus the C++ API of WebView2 does not support the function ExecuteScriptAsync(), this is a very tricky thing!
I determined with the process monitor, that the callback of ICoreWebView2ExecuteScriptCompletedHandler pumps a message with the ID 1025 after execution,
The only way (as I figured out) to retrieve the return value is by 'faking' a local message loop, wait until the message with ID 1025 was received, and then polling a member variable of my ICoreWebView2ExecuteScriptCompletedHandler implementation class.
The code looks a bit like this:
But this does not look like the best solution, and also it is kind of a little laggy. Sometimes the message loop needs ~5 seconds.
Is there not a 'proper' way to do this?
What do the developers of WebView2 think about this issue?
Is an official implementation for ExecuteScriptAsync() to be pubished in the near future?
The text was updated successfully, but these errors were encountered: