Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $progressPrefernce = 'silentlyContinue';
- #Generate a random file name
- $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";
- #Create directory
- New-Item "C:\$tmp" -type directory | Out-Null;
- #Init native method helpers
- $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
- }
- "@
- };
- #Register methods
- 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;
- }
- }
- #Load drawing library
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System");
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing");
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Media");
- #Set up graphics object
- [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;
- #Load Image and set sizing
- $image = [Drawing.Image]::FromFile("C:\$tmp\succ.jpg");
- $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;
- #Init sound
- [System.Media.SoundPlayer] $player = [System.Media.SoundPlayer]("C:\$tmp\succ.wav");
- #Draw image, then play sound
- $graphics.DrawImage($image, $rect);
- $player.PlaySync();
- #Finish up, dispose of objects and release graphics
- $graphics.Dispose();
- $image.Dispose();
- [User32]::ReleaseDC([System.IntPtr]::Zero, $desk);
- #Remove the directory and close
- Remove-Item "C:\$tmp" -Force -Recurse;
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement