I am trying to create a shortcut through which i can toggle 'Show desktop' and also and if the program is run through desktop 'hide desktop icons' so here is my .bat file
set mypath=%cd%
cd C:\Program Files\oneClickHD\
start ShowDesktop.lnk
if "%mypath%"=="C:\Users\admin\Desktop" goto GO
:GO
start HideDesktopIcons.exe
this piece of code doesn't really work as dir of bat wont change if i use its shortcut to run it so i thought of 3 methods but cannot implement them these methods are :
1)detect if there is any window is open if yes then toggle showdesktop.lnk or if current foreground window is not desktop toggle
2)check if desktop is on foreground and if yes run hideIcons.exe
3)instead of using showdesktop.lnk that toggles show desktop use something that just opens up desktop
to find solution i tried using nircmd through which i couldn't find how to return value of active windows or check if desktop is active and there is a commend in that : nircmd win min alltopnodesktop which is the only one that seems to work but it minimizes everything and i could only see wallpaper it just works in weird way. then i also thought of using vbs scripting but found better to use .bat for windows related things. then i also tried using powershell but it doesnt seem on my pc .
Something with NO window support is better than something with minimal window support.
You need to write a real program. This tells you the foreground window's handle, class name, and window title.
See my answer here for a way for COM languages like VBScript How to find the window Title of Active(foreground) window using Window Script Host
Create a file called GetForegroundWindow.bas. Put this in it.
Put above file on the desktop. Start a command prompt and type
It gives output like this.
you can parse with a
For /f
loop. SeeFor /?
.These are the windows of the Shell