Wise on Tech Hacks, scripts and ideas for the refined geek.

2Mar/100

Quick Script to Show/Hide Windows Gadgets

This is written for Windows 7, since it runs all Gadgets in the same process. It shouldn't be too difficult to modify it for Windows Vista.

Basically all this does is provides you with a quick way to start and stop Gadgets on your computer. Save it as a batch file called "gadgets.cmd" in your %PATH% and you can Windows + R and type 'gadgets' to quickly toggle them on and off.
Another cool idea is to download WinHotKey and map the batch file to a Windows keyboard shortcut.

Windows + G brings gadgets to the front
Try mapping Windows + Alt + G to show/hide gadgets entirely!

The script loops through running processes, looks for the sidebar process (outputting to a variable, which is more elegant than most solutions I could find) and either starts it or stops it as necessary.


@echo off
setlocal enableextensions

REM Look for sidebar in running processes...
for /f "tokens=1" %%a in (
'tasklist /fi "IMAGENAME eq sidebar.exe"'
) do (
set myvar=%%a
)
if %myvar% == sidebar.exe GOTO found

REM If its not running, start it
echo "Starting Gadgets..."
c:
cd\
cd "program files"
cd "windows sidebar"
start sidebar >nul
GOTO end

REM If it IS running, kill it
:found
echo "Killing Gadgets"
taskkill /f /im sidebar.exe

:end
endlocal

Update: Combine with this tip for hiding Desktop icons for a more thorough desktop de-clutterer.
Update 2: And here's an app for togglilng auto-hide on the Taskbar.