Autohide the icons in Windows 10
with fading animation
with fading animation
How can I autohide and show my icons?
With the power of AutoHotkey, there is an easy way to auto-hide your icons even in newer versions of operating systems like Windows 10. AutoHotkey is also a powerful tool to customize modern Windows too. In this short article, you can take a quick look at how you can auto-hide your icons in Windows 10 and add fading effects when the icons appear up or disappear from your desktop.
There are two videos, the first one is the newer version. It has a GUI and there are some options you can control.
You can download the ahk file from GitHub:
https://github.com/bceenaeiklmr/HideMyIcon
Download the exe file:
PayPal.me:
https://paypal.me/bceen
The video of the new version
And the old version
You will be able to download the compiled file so you can use it even if you first heard about AutoHotkey. If you are familiar with AutoHotkey code at least a bit I recommend building your own .ahk file (you can copy the full code), but it’s only your decision.
The Window’s desktop and its icons
We all love our desktops. And we like to stack icons on them. The only problem with that is, that after a while, there will be too many of them. Our desktops turn into pure chaos and this affects our effectiveness.
I only want to see my icons if I really need them. For instance, if my desktop is the active window. This AutoHotkey script can show or hide your icons on your desktop with a fancy fading animation you can tweak. Are you interested?
How can I autohide and show my icons?
An AutoHotkey script changes the transparency of the desktop icons based on conditions:
if the active window is your desktop you can see your icons
if another window is active you can’t see your icons
fading (in-out) animation during window transitions
How can I use it?
There are two possible way to use the script:
You download the script in a compiled format (exe)
You create an ahk file and use it with installed AutoHotkey
I recommend to download it if you are not familiar with AutoHotkey yet
The full AutoHotkey code
The following code can be copied, you can create your own .ahk file.
#SingleInstance,Force
#Persistent
SetWinDelay, 1
SetBatchLines, -1
DetectHiddenWindows, on
global hwnd, ico, transp
hwnd:= WinExist("ahk_class Progman")
ControlGet, ico, hwnd,, SysListView321, ahk_id %hwnd%
WinSet, transparent, 255, ahk_id %ico%
WinHide, ahk_id %ico%
SetTimer, Win10_IcoTransp, 20
OnExit("ExitFn")
Win10_IcoTransp(){
If WinActive("ahk_id" hwnd){
If !DllCall("IsWindowVisible",UInt,ico){
while (transp != 255){
WinShow, ahk_id %ico%
transp += 15
WinSet, Transparent, %transp%, % "ahk_id" ico
sleep, 20
}
}
} else {
If DllCall("IsWindowVisible",UInt,ico){
while (transp != 0){
transp -= 15
WinSet, Transparent, %transp%, % "ahk_id" ico
sleep, 20
}
WinHide, ahk_id %ico%
}
}
}
ExitFn(){
WinSet, Transparent, 255, ahk_id %ico%
WinShow, ahk_id %ico%
ExitApp
}
The code explanation
If you have some experience in AutoHotkey already, then I highly recommend to create your own .ahk file. I will try to explain every single step, that can be learned and could be usable in the future.
You can find the desktop with just a few clicks using AutoHotkey’s built-in program, WindowSpy.
Here is What WindowSpy shows after you click on your desktop.
Program Manager
ahk_class Progman
ahk_exe explorer.exe
ahk_pid 5348
First we need to get the hwnd of the desktop.
You can do this using AutoHotkey’s built-in WinExist() function in no time time.
hwnd:= WinExist("ahk_class Progman")
The icons’ control
Unfortunately, we can use only the ahk_class,
since the ahk_exe explorer.exe can interfere with other classes,
you won’t need the PID either.
However, you need the control name of the desktop icons,
so you can customize your control (icons).
ControlGet, ico, hwnd,, SysListView321, ahk_id %hwnd%
The variable will be the ico,
the second parameter is the ControlGet command’s mode, that in our case is hwnd.
The third parameter is blank now.
The icons can be found under the SysListView321 control.
The title is the hwnd what we get previously with the WinExist() function
Setting the windows’ transparency
This customization is about the window transparency now.
With the built-in AutoHotkey WinSet, Transparent, %value%, %windowtitle% command
the windows’s transparency can be changed.
Transparent = 0 is means invisible, and the maximum transparency is 255 which means fully visible.
WinSet, transparent, 255, ahk_id %ico%
WinHide icons’ window
WinHide, ahk_id %ico%
WinHide, ahk_id %ico%
Setting a timer with SetTimer and a function
The good thing you don’t need to use labels with the SetTimer command anymore. Simply you can just type the function name as used to (label name).
The timer run in every 20ms. Quick math: 1000 / 20 = 50 [times/1sec] )
SetTimer, Win10_IcoTransp, 20
The autohide icon Windows 10 function
The function checks if the desktop is active or not then it checks if the icons’ window is visible or hidden.
The built-in AutoHotkey’s WinActivate function paired with an If condition comes handy. To check the icon’s window visibility state we can use the Microsoft library that is an effictive and reliable way.
DllCall("IsWindowVisible",UInt,ico)
Adding Fade in-out effects
If t transparency is 0 (hide) or 255 (show) your desktop icons. ( and the window )
Animations ( between the whiles ) only started if the current active window is not the same as in the previous 20 ms.
This sections covers also the speed of the effects.
The transparency can be 0-255. 0 means invisible, so I had 255 another state left.
After a few tests my choice was 15. ( transp += value or transp -= value )
This means during a whole fade ( in or out ) transaction there are 17 different transparency states.
The sleep value means the delta time between two consecutive transparency states.
If the transparency reaches a treshold limit (min = 0 (invisible) or max = 255 (fully visible)) the script will break from the while loop.
If WinActive("ahk_id" hwnd){
If !DllCall("IsWindowVisible",UInt,ico){
while (transp != 255){
WinShow, ahk_id %ico%
transp += 15
WinSet, Transparent, %transp%, % "ahk_id" ico
sleep, 20
}
}
}
Or if the desktop is not active, the ‘else’ part.
If DllCall("IsWindowVisible",UInt,ico){
while (transp != 0){
transp -= 15
WinSet, Transparent, %transp%, % "ahk_id" ico
sleep, 20
}
WinHide, ahk_id %ico%
}
The OnExit function allows the user to declare what should happen if a script will be terminated or exited. I thought it would be good to have an option to set back everything to the default values when this happens. The transparency value should be reverted to 255 and the window must be shown again. Now you exit the script.
ExitFn(){
WinSet, Transparent, 255, ahk_id %ico%
WinShow, ahk_id %ico%
ExitApp
}
More of these articles please! :)