LoginSignup
2
1

Windowsのタスクバーを完全非表示

Posted at

Windowsで業務用アプリを全画面で表示しているが、マウスが最下部にあるとタスクバーが表示されてしまうのが問題である場合などで使用。(タスクバーを自動的に隠すの設定だけではダメな場合)

ここ(Windows のタスクバーを完全に消す)を参考に、exeを作成したがSymantecに消されてしまうのでPowerShell版を作成

手順

スクリプト保存

以下のコードをテキストエディターで任意の場所に保存

TaskBarHandler.ps1
Add-Type @"
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;

    public class TaskBarHandler
    {
        [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressUnmanagedCodeSecurity]
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
        [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressUnmanagedCodeSecurity]
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); 
    
        public static bool restore(string className, string windowName)
        {
            IntPtr hwnd = FindWindow(className, windowName);
            return ShowWindow(hwnd, 9);
        }

        public static bool hide(string className, string windowName)
        {
            IntPtr hwnd = FindWindow(className, windowName);
            return ShowWindow(hwnd, 0);
        }
    }
"@
$task_bar_status = [TaskBarHandler]::hide("Shell_TrayWnd", $null)
if (-Not ($task_bar_status)) {
    [TaskBarHandler]::restore("Shell_TrayWnd", $null)
}

PowerShell起動

Windowsキー + R 押下
powershell -ExecutionPolicy RemoteSigned

スクリプト実行

PS C:\> C:\[任意の場所]\TaskBarHandler.ps1

最初の実行で、タスクバーが消える。
もう一度実行すると、復活!

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1