hide-taskbar.ps1 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # PowerShell script to hide Windows taskbar
  2. # This script uses Windows API to hide the taskbar
  3. # Run with: powershell -ExecutionPolicy Bypass -File hide-taskbar.ps1
  4. try {
  5. Add-Type @"
  6. using System;
  7. using System.Runtime.InteropServices;
  8. public class Taskbar {
  9. [DllImport("user32.dll")]
  10. public static extern int FindWindow(string className, string windowName);
  11. [DllImport("user32.dll")]
  12. public static extern int ShowWindow(int hwnd, int command);
  13. [DllImport("user32.dll")]
  14. public static extern int FindWindowEx(int parentHandle, int childAfter, string className, string windowTitle);
  15. public const int SW_HIDE = 0;
  16. public const int SW_SHOW = 5;
  17. public static void Hide() {
  18. // Hide main taskbar
  19. int hwnd = FindWindow("Shell_TrayWnd", null);
  20. if (hwnd != 0) {
  21. ShowWindow(hwnd, SW_HIDE);
  22. }
  23. // Hide secondary taskbar (if exists, e.g., on multi-monitor setup)
  24. int secondaryHwnd = FindWindow("Shell_SecondaryTrayWnd", null);
  25. if (secondaryHwnd != 0) {
  26. ShowWindow(secondaryHwnd, SW_HIDE);
  27. }
  28. }
  29. public static void Show() {
  30. // Show main taskbar
  31. int hwnd = FindWindow("Shell_TrayWnd", null);
  32. if (hwnd != 0) {
  33. ShowWindow(hwnd, SW_SHOW);
  34. }
  35. // Show secondary taskbar (if exists)
  36. int secondaryHwnd = FindWindow("Shell_SecondaryTrayWnd", null);
  37. if (secondaryHwnd != 0) {
  38. ShowWindow(secondaryHwnd, SW_SHOW);
  39. }
  40. }
  41. }
  42. "@
  43. # Hide taskbar
  44. [Taskbar]::Hide()
  45. # Exit successfully
  46. exit 0
  47. } catch {
  48. # If error occurs, exit with error code
  49. exit 1
  50. }