Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Create Keyboard Shortcut to Show or Hide Desktop Icons Easily

Create Keyboard Shortcut to Show or Hide Desktop Icons Easily

Having quick access to show or hide desktop icons can streamline your workflow and keep your workspace clean. While Windows doesn’t provide a direct keyboard shortcut for this task, you can set up a custom shortcut using built-in tools and scripting. This guide walks you through creating a keyboard shortcut that toggles desktop icons on or off, giving you faster control over your desktop appearance and improving your overall efficiency.

What You’ll Need

  • A Windows PC (Windows 10 or Windows 11 recommended)
  • Basic familiarity with creating shortcuts and editing scripts
  • Optional: a script editor like Notepad
  • Optional: a keyboard shortcut tool (built-in or third-party)

Step-by-Step

  1. Create a Script to Toggle Desktop Icons
    • Open Notepad or your preferred text editor.
    • Copy and paste the following PowerShell script:
    •    $desktopIcons = [Windows.UI.ViewManagement.ApplicationView.GetForCurrentView()]
         $path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
         $valueName = "HideIcons"
         $current = Get-ItemProperty -Path $path -Name $valueName
         if ($current.HideIcons -eq 1) {
             Set-ItemProperty -Path $path -Name $valueName -Value 0
         } else {
             Set-ItemProperty -Path $path -Name $valueName -Value 1
         }
         Stop-Process -Name explorer -Force
    • Save the file with a .ps1 extension, for example, “ToggleDesktopIcons.ps1”.
  2. Create a Shortcut to Run the Script
    • Right-click on your desktop, select New > Shortcut.
    • In the location field, enter:
    • powershell.exe -ExecutionPolicy Bypass -File "C:\Path\To\Your\ToggleDesktopIcons.ps1"
    • Replace “C:\Path\To\Your\” with the actual path where you saved your script.
    • Click Next, name your shortcut (e.g., “Toggle Desktop Icons”), and click Finish.
  3. Assign a Keyboard Shortcut to the Shortcut
    • Right-click the shortcut you just created and select Properties.
    • In the Shortcut key field, click and press your preferred key combination (e.g., Ctrl + Alt + D).
    • Click OK to save.
  4. Test Your Shortcut
    • Press the assigned key combination to toggle desktop icons on or off.
    • If icons do not appear or disappear as expected, verify the script path and shortcut settings.

Common Mistakes

  • Not running the script with administrator privileges if required.
  • Incorrect script path or filename in the shortcut.
  • Forgetting to set the execution policy to bypass or sign the script.
  • Using an invalid keyboard shortcut that conflicts with existing shortcuts.
  • Not testing the shortcut after creation to ensure it works properly.

Tips

  • Save your script in a dedicated folder to keep things organized.
  • Use a simple, memorable keyboard shortcut for quick access.
  • Consider creating a batch file or a shortcut with a specific icon for easy identification.
  • If the script doesn’t work, run PowerShell as administrator to troubleshoot permissions.
  • Always back up your registry before editing it manually.

Troubleshooting

  • Shortcut Doesn’t Work: Verify the script path is correct, and ensure PowerShell execution policies allow running scripts. Test the script directly in PowerShell first.
  • Icons Don’t Toggle: Check if the registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced has the HideIcons value and that it changes between 0 and 1.
  • Explorer Doesn’t Refresh: The script stops the explorer process; if icons don’t reappear, restart explorer manually or log out and back in.
  • Permission Issues: Run the script or shortcut as administrator if necessary.
  • Keyboard Shortcut Not Working: Confirm the shortcut key combination isn’t used by another program and that the shortcut properties are saved correctly.

Frequently Asked Questions

Can I customize the keyboard shortcut for toggling desktop icons?

Yes, during the shortcut creation, you can assign any available key combination in the shortcut properties under the Shortcut key field.

Is there a way to toggle desktop icons without scripting?

Not directly via built-in Windows shortcuts, but you can manually right-click on the desktop, select View, and toggle Show desktop icons. Using scripts automates this process.

Will this work on Windows 11 and Windows 10?

Yes, the method works on both Windows 10 and Windows 11, as it relies on standard registry modifications and PowerShell scripts supported in these versions.

Can I assign multiple shortcuts to toggle icons on and off?

While possible, it’s more practical to assign a single shortcut that toggles the state each time you press it, as shown in the script.

What if my icons still don’t toggle after following this guide?

Ensure your script runs correctly by executing it manually in PowerShell. Also, verify your registry settings and that explorer.exe restarts properly after toggling.

Related

Create Keyboard Shortcut to Show or Hide Desktop Icons Easily
Scroll to top