Normally, using timers will be polling the system unnecessarily, it is recommended to use the shell messages that Windows taskbar itself relies on, as mentioned here you register your process as a shell message client or hook the shell message, that depends on you. In the previous picture, you can see the hierarchy of child Windows inside the main taskbar's Shell_TrayWnd window handle, the child that contains the running applications is named ReBarWindow32 which has its own coordinates within that taskbar window, you just modify it using a timer or a shell event whenever a new process is started, or existing one is closed, or switched to another virtual desktop, and maybe other events, all that in order to re-adjust its location (centering in your case). With that coordinates you will get its real width inside taskbar window, and using SetWindowPos modify its position in its taskbar area using its child windows container. Once found the exact location of the taskbar list icons, pick the first one's left position and then the last one's right position. Once you found them, using that tool as a guide, find the exact running applications list in that accessibility tree, for each taskbar instance (main monitor and secondary monitors). What TaskbarX and other similar tools do for Windows 10 and prior versions, is to calculate the taskbar icons location using accessibility functions like UIAutomation or MSAA.Īs shown in the picture above, using UI Accessibility Checker tool by Microsoft, this is showing the MSAA tree of the explorer.exe process, specially that instance that holds the taskbar.įirst, find the taskbars instances, using EnumWindows and pick those beloging to explorer.exe process that has as Win Class Name "Shell_TrayWnd" (for primary monitor) and "Shell_SecondaryTrayWnd" (for the other monitors). On Windows 10, you can't center icons just by modifying the Windows Registry.īut on Windows 11 you just modify TaskbarAl (0 = left, 1 = centered) value in \HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced.
0 Comments
Leave a Reply. |