Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $progressPreference = 'silentlyContinue';
- $tmp = -join ((65..90) + (97..122) | Get-Random -Count 8 | % {[char]$_});
- $f1 = "https://enx3s.com/files/succ.jpg";
- $f2 = "https://enx3s.com/files/succ.wav";
- New-Item "C:\$tmp" -type directory | Out-Null;
- $script:nativeMethods = @();
- function Register-NativeMethod([string]$dll, [string]$methodSignature)
- {
- $script:nativeMethods += [PSCustomObject]@{
- Dll = $dll;
- Signature = $methodSignature;
- };
- };
- function Add-NativeMethods()
- {
- $nativeMethodsCode = $script:nativeMethods | % {
- "[DllImport(`"$($_.Dll)`")] public static extern $($_.Signature);";
- };
- Add-Type "using System; using System.Runtime.InteropServices; public static class User32 {$nativeMethodsCode}";
- };
- # Load in native DLL functions
- Register-NativeMethod "user32.dll" "IntPtr GetDC(IntPtr hwnd)";
- Register-NativeMethod "user32.dll" "void ReleaseDC(IntPtr hwnd, IntPtr dc)";
- Add-NativeMethods;
- Add-Type -AssemblyName System.Windows.Forms;
- $screens = [System.Windows.Forms.Screen]::AllScreens;
- foreach($screen in $screens) {
- if($screen.Primary) {
- $primary = $screen;
- }
- };
- # This is how we load assemblies
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System");
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing");
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Media");
- # Create call functions to init variables
- [System.IntPtr] $desk = [User32]::GetDC([System.IntPtr]::Zero);
- [System.Drawing.Graphics] $graphics = [System.Drawing.Graphics]::FromHdc($desk);
- # Download files
- Invoke-WebRequest -OutFile "C:\$tmp\succ.jpg" $f1 | Out-Null;
- Invoke-WebRequest -OutFile "C:\$tmp\succ.wav" $f2 | Out-Null;
- # Various variable initiations
- $image = [Drawing.Image]::FromFile("C:\$tmp\succ.jpg"); #Equivalent to Drawing.Image.FromFile(string file)
- $factor = 0.75;
- $w = $image.Width * $factor;
- $h = $image.Height * $factor;
- $x = ($primary.Bounds.Width / 2) - ($w / 2) + $primary.Bounds.X;
- $y = ($primary.Bounds.Height / 2) - ($h / 2) + $primary.Bounds.Y;
- $rect = New-Object Drawing.Rectangle $x, $y, $w, $h;
- [System.Media.SoundPlayer] $player = [System.Media.SoundPlayer]("C:\$tmp\succ.wav");
- # Draw the image and play sound
- $graphics.DrawImage($image, $rect);
- $player.PlaySync();$graphics.Dispose();$image.Dispose();
- [User32]::ReleaseDC([System.IntPtr]::Zero, $desk);
- Remove-Item "C:\$tmp" -Force -Recurse;
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement