Are the following things possible using VBScript or any other programming language:
- detect screen shape - or whether computer is docked
- change the Windows taskbar location
What I am trying to achieve:
My laptop has a 14" widescreen: pretty wide, but not very high. I find it most convenient to have the Windows taskbar located on the left of the screen, since I can spare the width but not the vertical space.
However, when in the office, my computer sits in a docking station and is hooked up to a nice big squarish screen. Here I much prefer to have the taskbar in its default location i.e. at the bottom.
I know how to switch between the two taskbar locations manually in Taskbar Properties, of course. But I do this a few times daily, which is rather annoying. My question is: can I have the taskbar location change automatically?
For example, at startup (or wake up from hibernation) a script would run which detects either:
- Is screen shape taller than 4:3? (or whatever number)
- Is computer docked in docking station?
If yes, put taskbar at bottom, else at left.
Anyone know how to do this or can put me on the right track? Or is there already a utility out there that can do this?
//Normal augment on why this is not a good idea on someone else's machine omitted
A scripting language may not be a good choice here, you need something that pumps the message to listen to WM_DISPLAYCHANGE.
When you get the message you need to calculate the desired orientation of the task bar based on the resolutions of your monitors. Then you use RmShutdown to close Windows Explorer.
//undocumented behavior begins, may break anytime
The taskbar docking edge is stored in byte 13 (as one of the ABE values from APPBARDATA ) and the position is stored in byte 25-40 as a win32 RECT. You can modify the setting before restarting the explorer.
//undocumented behavior ends
Sample code (full source at https://github.com/jiangsheng/Samples/tree/master/AppBarTest):
You can do this in a simple batch or from a script. Set the registry value to position the taskbar based on the current resolution of your screen (if in the docking it will be higher) and then restart explorer.exe. So eg a batch to set the taskbar at the left of your screen would be (assuming you have the bottom.reg file in the d:\scripts folder)
The contents of bottom.reg are
and for left.reg
You will have some flickering but since you will do this when you start windows that won't be a problem i suppose. I tested this on Windows 7.
EDIT: made a vbscript that does the same thing based on screen resolution