Advertisement
kolyaventuri

SUCC

Sep 4th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $progressPrefernce = 'silentlyContinue';
  2. #Generate a random file name
  3. $tmp = -join ((65..90) + (97..122) | Get-Random -Count 8 | % {[char]$_});
  4. $f1 = "https://enx3s.com/files/succ.jpg";
  5. $f2 = "https://enx3s.com/files/succ.wav";
  6.  
  7. #Create directory
  8. New-Item "C:\$tmp" -type directory | Out-Null;
  9.  
  10. #Init native method helpers
  11. $script:nativeMethods = @();
  12. function Register-NativeMethod([string]$dll, [string]$methodSignature)
  13. {
  14.     $script:nativeMethods += [PSCustomObject]@{ Dll = $dll; Signature = $methodSignature; };
  15. }
  16. function Add-NativeMethods()
  17. {
  18.     $nativeMethodsCode = $script:nativeMethods | % { "
  19.        [DllImport(`"$($_.Dll)`")]
  20.        public static extern $($_.Signature);
  21.    " }
  22.  
  23.     Add-Type @"
  24.        using System;
  25.        using System.Runtime.InteropServices;
  26.        public static class User32 {
  27.            $nativeMethodsCode
  28.        }
  29. "@
  30. };
  31.  
  32. #Register methods
  33. Register-NativeMethod "user32.dll" "IntPtr GetDC(IntPtr hwnd)";
  34. Register-NativeMethod "user32.dll" "void ReleaseDC(IntPtr hwnd, IntPtr dc)";
  35. Add-NativeMethods
  36.  
  37. Add-Type -AssemblyName System.Windows.Forms;
  38. $screens = [System.Windows.Forms.Screen]::AllScreens;
  39. foreach($screen in $screens) {
  40.   if($screen.Primary) {
  41.     $primary = $screen;
  42.   }
  43. }
  44.  
  45. #Load drawing library
  46. [void] [System.Reflection.Assembly]::LoadWithPartialName("System");
  47. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing");
  48. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Media");
  49.  
  50. #Set up graphics object
  51. [System.IntPtr] $desk = [User32]::GetDC([System.IntPtr]::Zero);
  52. [System.Drawing.Graphics] $graphics = [System.Drawing.Graphics]::FromHdc($desk);
  53.  
  54. #Download Files
  55. Invoke-WebRequest -OutFile "C:\$tmp\succ.jpg" $f1 | Out-Null;
  56. Invoke-WebRequest -OutFile "C:\$tmp\succ.wav" $f2 | Out-Null;
  57.  
  58. #Load Image and set sizing
  59. $image = [Drawing.Image]::FromFile("C:\$tmp\succ.jpg");
  60.  
  61. $factor  = 0.75;
  62. $w = $image.Width * $factor;
  63. $h = $image.Height * $factor;
  64. $x = ($primary.Bounds.Width / 2) - ($w / 2) + $primary.Bounds.X;
  65. $y = ($primary.Bounds.Height / 2) - ($h / 2) + $primary.Bounds.Y;
  66.  
  67. $rect = New-Object Drawing.Rectangle $x, $y, $w, $h;
  68.  
  69. #Init sound
  70. [System.Media.SoundPlayer] $player = [System.Media.SoundPlayer]("C:\$tmp\succ.wav");
  71.  
  72. #Draw image, then play sound
  73. $graphics.DrawImage($image, $rect);
  74. $player.PlaySync();
  75.  
  76.  
  77. #Finish up, dispose of objects and release graphics
  78. $graphics.Dispose();
  79. $image.Dispose();
  80. [User32]::ReleaseDC([System.IntPtr]::Zero, $desk);
  81.  
  82. #Remove the directory and close
  83. Remove-Item "C:\$tmp" -Force -Recurse;
  84. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement