Skip to content

Instantly share code, notes, and snippets.

@kylesmile1103
Last active April 22, 2022 23:30
Show Gist options
  • Save kylesmile1103/fb49adb4cfcb4658365aef2efb84227f to your computer and use it in GitHub Desktop.
Save kylesmile1103/fb49adb4cfcb4658365aef2efb84227f to your computer and use it in GitHub Desktop.
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)
@kylesmile1103
Copy link
Author

kylesmile1103 commented Apr 22, 2022

In order to run this: open Powershell then execute these following commands (copy all and paste by pressing right-click onto the Powershell console):

saps powershell -Verb RunAs -ArgumentList ('-Command "{0}"' -f $(icm -ScriptBlock $([scriptblock]::create( {
Set-ExecutionPolicy Unrestricted -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
$gist="https://gist.githubusercontent.com/kylesmile1103/fb49adb4cfcb4658365aef2efb84227f/raw/f93e210cc432d6551ae933edbbf7d52fd0200f8b/heart.ps1"
iex((New-Object System.Net.WebClient).DownloadString($gist));
})))) -WindowStyle hidden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment