MKANET

Untitled

Feb 1st, 2021
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6. # Helper functions for gaining access to Win32 API
  7. ###########################################################################################
  8. $script:nativeMethods = @();
  9. function Register-NativeMethod([string]$dll, [string]$methodSignature)
  10. {
  11. $script:nativeMethods += [PSCustomObject]@{ Dll = $dll; Signature = $methodSignature; }
  12. }
  13. function Add-NativeMethods()
  14. {
  15. $nativeMethodsCode = $script:nativeMethods | % { "
  16. [DllImport(`"$($_.Dll)`")]
  17. public static extern $($_.Signature);
  18. " }
  19.  
  20. Add-Type @"
  21. using System;
  22. using System.Runtime.InteropServices;
  23. public class NativeMethods {
  24. $nativeMethodsCode
  25. }
  26. "@
  27. }
  28. ###########################################################################################
  29.  
  30. # Add your Win32 API here:
  31. ###########################################################################################
  32. Register-NativeMethod "user32.dll" "bool SetForegroundWindow(IntPtr hWnd)"
  33. Register-NativeMethod "user32.dll" "bool ShowWindow(IntPtr hWnd, int nCmdShow)"
  34. Register-NativeMethod "user32.dll" "bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint)"
  35. Register-NativeMethod "user32.dll" "bool AnimateWindow(IntPtr hwnd, UInt32 dwTime, UInt32 dwFlags)"
  36. Register-NativeMethod "user32.dll" "IntPtr FindWindow(IntPtr ZeroOnly, string lpWindowName)"
  37. Register-NativeMethod "user32.dll" "void keybd_event(Byte bVk, Byte bScan, UInt32 dwFlags, UInt32 dwExtraInfo)"
  38. Register-NativeMethod "user32.dll" "bool InvalidateRect(IntPtr hWnd, IntPtr ZeroOnly, bool bErase)"
  39. Register-NativeMethod "user32.dll" "UInt16 TileWindows(IntPtr ZeroOnly, int wHow, IntPtr lpRect, int cKids, IntPtr[] lpKids)"
  40. Register-NativeMethod "dwmapi.dll" "void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind)"
  41. ###########################################################################################
  42.  
  43. # Build class and registers them:
  44. Add-NativeMethods
  45.  
  46. $application = New-Object -com shell.application
  47.  
  48.  
  49.  
  50. [DllImport("dwmapi.dll")]
  51. static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment