Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1538

Feeds & Internet Data • Re: Market Prices

$
0
0
When clicked, this will open the web site in a baked-in version of Internet Explorer, make it full screen and in front with focus, take a .png image, and save it to your Desktop.
[jsmorley] I have a question about your code. According to Windows Copilot, is it possible to take a Screenshot from a Website with the WebView2.

Quote Windows Copilot;
"Yes, you can use Microsoft Edge's WebView2 control to take screenshots of web pages. Here is an example of how you can do this with PowerShell and WebView2:"? Quote

Qestion to Windows Copilot:
To take a screenshot, does the web browser have to be open? or can it be closed.

Quote Windows Copilot;
To take a screenshot with WebView2, the web browser does not have to be open. The WebView2 control acts as an embedded browser within your application and can load and display web pages without the main browser having to be open. This means that you can take screenshots of web pages without manually opening the browser.

When you run the PowerShell script, the WebView2 control is used in the background to load the web page and take the screenshot. The browser itself remains closed.





The dll in the Script-Path is not the right one.

Do you know more about this? Is there a way?

Code:

# Installiere das WebView2 SDK#Install-Package Microsoft.Web.WebView2 -Source nuget.org# Lade die WebView2 AssemblyAdd-Type -Path "C:\Windows\SystemApps\Shared\WebView2SDK\Microsoft.Web.WebView2.Core.dll"# Erstelle eine neue WebView2-Umgebung$env = [Microsoft.Web.WebView2.Core.CoreWebView2Environment]::CreateAsync().Result# Erstelle ein neues WebView2-Steuerelement$webview = New-Object Microsoft.Web.WebView2.WinForms.WebView2# Initialisiere das WebView2-Steuerelement$webview.CreateCoreWebView2Async($env).Wait()# Setze die Größe des WebView2-Steuerelements$webview.Width = 1024$webview.Height = 768# Navigiere zur Website$webview.Source = [Uri]::new("http://www.google.de")# Warte, bis die Seite geladen ist$webview.NavigationCompleted.Add({    # Mache einen Screenshot    $bitmap = New-Object System.Drawing.Bitmap $webview.Width, $webview.Height    $graphics = [System.Drawing.Graphics]::FromImage($bitmap)    $webview.DrawToBitmap($bitmap, [System.Drawing.Rectangle]::new(0, 0, $webview.Width, $webview.Height))    $bitmap.Save("C:\Users\Windows-11\Pictures\screenshot.png", [System.Drawing.Imaging.ImageFormat]::Png)        # Schließe das WebView2-Steuerelement    $webview.Dispose()})# Starte das WebView2-Steuerelement$webview.CreateCoreWebView2Async($env).Wait()

Statistics: Posted by Rooky_89 — 26 minutes ago



Viewing all articles
Browse latest Browse all 1538

Trending Articles