Well, we will write a little code first. If you are not scared by that fact, go and install AutoIt. It is a great scripting language for Windows. It saves the day when you just want what you want to be accomplished and not worry about anything else. Anything that comes up to your mind, first check this thing, if you cannot find it, or it is limited in some sense, only then try implementing it wholly by yourself. Fortunately, what we are going to do is actually quite basic, so it has all that we need.
Here is my code for hiding and showing the ToDo gadget based on a hotkey.
HotKeySet("!t", "ShowHideTodo") ;Change this line
$hWindows = WinList("[CLASS:SideBar_HTMLHostWindow]")
If @error Then
MsgBox(4096, "Error", "Could not find the correct window")
For $i = 1 to $hWindows
If $size > 150 And $size > 150 Then ;Change this line
$state = WinGetState($hWindows[$i], "")
If Not BitAnd($state, 2) Then
WinSetState($hWindows[$i], "", @SW_SHOW)
WinSetState($hWindows[$i], "", @SW_HIDE)
What we are doing here is essentially giving it a classname and getting a list of handles to the windows that have this classname. These are the sidebar gadgets. So since there are probably more than one gadget on your desktop, we are getting a list of them by the WinList function, instead of using the WinGetHandle to get a handle for only one.
Next, we somehow need to identify the gadget that we want hidden/visible. I’ve thought about it a little, and I couldn’t find a better way than to discriminate them based on size. (Any other ideas?) So if the gadget is not resizable, this is a good option actually, the probability that another gadget has exactly the same size is rather low. But, if it is resizable, then it is better to give some interval instead, as I’ve done here with my ToDo gadget. ($size is the width and $size is the height btw.)
You could be wondering how we got the classname and size, if you haven’t used AutoIt before. It comes with another cool utility called "Window Info”. Just open it up and point to the window you want. Well, these gadgets are actually windows. So point up to the gadget you want and note these values.
Oh, and we set the hotkey here at this line.
HotKeySet("!t", "ShowHideTodo") ;this sets it to be run when ALT+t is pressed
Just change the letter to anything else you want.
Hmm, but what if I want to hide all of them? (AFAIK, Windows doesn’t have a hotkey for this.)
Well, then just remove these two lines from the above script, that’s it. =)
If $size > 150 And $size > 150 Then
OK, gotcha, but how will I use this thing? Well, I didn’t make a ready-to-be-used executable because everyone could be trying to hide/show something else. Thus, you need to install AutoIt, open up the customized SciTE Script Editor for AutoItv3(or any other editor actually, but this one has auto-complete features for the language used), copy and paste the code that I’ve given above, modify it to your purposes, and save it with .au3 extension. By double clicking the file you will run it, and if you want it to be always open, just add a shortcut for it to the startup folder.
Well, I guess that is it for now. Have a nice day.