Last active
April 22, 2022 23:30
-
-
Save kylesmile1103/fb49adb4cfcb4658365aef2efb84227f to your computer and use it in GitHub Desktop.
Challenge accepted! | https://zingnews.vn/chu-re-ngoi-lap-trinh-ngay-tai-le-ruoc-dau-o-trung-quoc-post1229628.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[string]$uri = "https://pluspng.com/img-png/heart-png--3100.png" | |
) | |
Add-Type -AssemblyName PresentationFramework | Out-Null | |
Add-Type -AssemblyName System.Drawing | Out-Null | |
Add-Type -AssemblyName System.Windows.Forms | Out-Null | |
Add-Type -AssemblyName WindowsFormsIntegration | Out-Null | |
[void][System.Windows.Forms.Application]::EnableVisualStyles() | |
[Xml]$xaml = @" | |
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
WindowStyle="None" ResizeMode="NoResize" | |
AllowsTransparency="True" ShowInTaskbar="False" | |
WindowStartupLocation="CenterScreen" | |
Topmost="True" WindowState="Maximized"> | |
<Window.Background> | |
<ImageBrush x:Name="image" Stretch="2"/> | |
</Window.Background> | |
</Window> | |
"@ | |
$Window = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $xaml)) | |
$xaml.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process { | |
Set-Variable -Name ($_.Name) -Value $window.FindName($_.Name) -Scope Script | |
} | |
$window.Add_Closing( { [System.Windows.Forms.Application]::Exit(); Stop-Process $pid }) | |
$windowcode = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);' | |
$asyncwindow = Add-Type -MemberDefinition $windowcode -name Win32ShowWindowAsync -namespace Win32Functions -PassThru | |
$asyncwindow::ShowWindowAsync((Get-Process -PID $pid).MainWindowHandle, 0) | Out-Null | |
[System.Windows.Forms.Integration.ElementHost]::EnableModelessKeyboardInterop($window) | |
$window.Show() | |
$window.Activate() | |
$window.Add_closing( { $_.cancel = $true }) | |
[byte[]]$byte = (Invoke-WebRequest -Method GET -Uri $uri -UseBasicParsing).Content | |
$base64 = [Convert]::ToBase64String($byte) | |
$bitmap = New-Object System.Windows.Media.Imaging.BitmapImage | |
$bitmap.BeginInit() | |
$bitmap.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($base64) | |
$bitmap.EndInit() | |
$bitmap.Freeze() | |
$image.ImageSource = $bitmap | |
$appContext = New-Object System.Windows.Forms.ApplicationContext | |
[void][System.Windows.Forms.Application]::Run($appContext) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order to run this: open Powershell then execute these following commands (copy all and paste by pressing right-click onto the Powershell console):