davidnnc Posted January 20, 2009 Report Share Posted January 20, 2009 Does anyone have a way to detect whether or not the windows taskbar is currently displayed or hidden (via autohide)? I have a macro that resizes and repositions the current window so that it maximizes the window but doesn't cover the taskbar. It detects what side (left, right, top or bottom) the taskbar is on and how much the of the taskbar is exposed. The only time it doesn't work is when the taskbar autohides. I haven't been able to detect whether or not if the taskbar is hidden or not. I know that I can set the taskbar to remain on top and then maximize the window, but that's not what I want. The best I've been able to determine, the taskbar acts like a window in some respects, but not all. So some of the normal window commands do not seem to work on the taskbar window. Thanks, David Wilkinson Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 21, 2009 Report Share Posted January 21, 2009 Does anyone have a way to detect whether or not the windows taskbar is currently displayed or hidden (via autohide)? I have a macro that resizes and repositions the current window so that it maximizes the window but doesn't cover the taskbar. It detects what side (left, right, top or bottom) the taskbar is on and how much the of the taskbar is exposed. The only time it doesn't work is when the taskbar autohides. I haven't been able to detect whether or not if the taskbar is hidden or not. I know that I can set the taskbar to remain on top and then maximize the window, but that's not what I want. The best I've been able to determine, the taskbar acts like a window in some respects, but not all. So some of the normal window commands do not seem to work on the taskbar window. Thanks, David Wilkinson David, You should be able to do it using ME's Registry commands. I'm pretty sure the relevant key is here: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2 The actual value with it OFF is 28 00 00 00 ff ff ff ff 02 00 00 00 03 00 00 00 6b 00 00 00 1e 00 00 00 fe ff ff ff 94 04 00 00 82 07 00 00 b2 04 00 00 And when it's ON that changes to 28 00 00 00 FF FF FF FF 03 00 00 00 01 00 00 00 3F 00 00 00 1E 00 00 00 FE FF FF FF FE FF FF FF 02 04 00 00 1C 00 00 00 So the only thing that changes is the 9th pair, from 02 to 03, From some googling here is the full set of options for that binary value: SINGLE OPTIONS: 08 = No Settings Enabled 09 = Auto Hide 00 = Show Clock 0A = Always on Top 0C = Show small icons in Start Menu MULTIPLE OPTIONS: 01 = Auto Hide and Show Clock 02 = Always on Top and Show Clock 03 = Always on Top and Auto Hide and Show Clock 04 = Show small icons in Start Menu and Show Clock 0E = Always on Top and Show small icons in Start Menu 0F = Always on Top and Auto Hide and Show small icons in Start Menu 06 = Always on Top and Show small icons in Start Menu and Show Clock 07 = All Options Enabled 0B = Always on Top and Auto Hide 0D = Auto Hide and Show small icons in Start Menu After reference to Joe Weinpert's 'Macro Express Explained', which informed me that this type of entry was Decimal and was supported by ME, I then tried to write what I assumed would be a simple macro to read that setting. But so far I've failed. // Toggle Autohide ON/OFF using XP Registry Read Registry Value "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2\" into %D[1]% Text Box Display: Macro Return <COMMENT Value="Toggle Autohide ON/OFF using XP Registry"/> <READ REGISTRY VALUE Key="HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects2\\" Destination="%D[1]%"/> <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 D1 = %D[1]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <MACRO RETURN/> That just returns 0.0 I then tried the equivalent with ME 3: <REGRDEC:1:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2><TBOX4:T:1:CenterCenter000278000200:000:D1 = %D1%> That gave me the obscure message (not mentioned in Help) : "You can only read a string from the default value. The macro will be aborted." So I'm now awaiting some expert help please! -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
floyd Posted January 21, 2009 Report Share Posted January 21, 2009 Does anyone have a way to detect whether or not the windows taskbar is currently displayed or hidden (via autohide)? I have a macro that resizes and repositions the current window so that it maximizes the window but doesn't cover the taskbar. It detects what side (left, right, top or bottom) the taskbar is on and how much the of the taskbar is exposed. The only time it doesn't work is when the taskbar autohides. I haven't been able to detect whether or not if the taskbar is hidden or not. Is the goal then to maximize a window as if the taskbar was showing whether or not it is? Quote Link to comment Share on other sites More sharing options...
kevin Posted January 21, 2009 Report Share Posted January 21, 2009 The binary value in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2 is only updated when you log off and back on to Windows. If the user has changed the Auto Hide taskbar setting StuckRects2 will not reflect the AutoHide status. When a decimal variable is written to the registry it is stored as a binary value. That does not mean that all binary values in the registry can be read into a decimal variable. Macro Express and Macro Express Pro do not have commands to read binary values from the registry. If a macro attempts to read just any binary value from the registry into a decimal variable the result is unpredictable. Quote Link to comment Share on other sites More sharing options...
kunkel321 Posted January 21, 2009 Report Share Posted January 21, 2009 If your taskbar is a different color than your desktop picture, maybe you can use the trusty old "get pixel color" (?) Quote Link to comment Share on other sites More sharing options...
stevecasper Posted January 21, 2009 Report Share Posted January 21, 2009 If your taskbar is a different color than your desktop picture, maybe you can use the trusty old "get pixel color" (?) Which is exactly what I was thinking... A cool back-door way to determine it would be interesting. Terry's suggestion seemed pretty good, though I honestly get nervous when dealing with registry keys. I don't understand them well enough to mess with them (if I broke something, I wouldn't know how to fix it). At the very least, a series of Get Pixel Colors that check the bottom-left then the top-left corners for the Windows Logo. Check for the red, green, blue, and yellow squares in their usual places. If any of them fail in the bottom-left, check the top-left, if any of them fail, then it stands to reason that the task bar is hidden. Maybe preempt the Get Pixel search with a mouse move to the center of the screen to make doubly sure the mouse isn't hovering in that area, causing the bar to pop up. Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 21, 2009 Report Share Posted January 21, 2009 The binary value in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2 is only updated when you log off and back on to Windows. If the user has changed the Auto Hide taskbar setting StuckRects2 will not reflect the AutoHide status. When a decimal variable is written to the registry it is stored as a binary value. That does not mean that all binary values in the registry can be read into a decimal variable. Macro Express and Macro Express Pro do not have commands to read binary values from the registry. If a macro attempts to read just any binary value from the registry into a decimal variable the result is unpredictable. Is Joe therefore mistaken when he says in his table on page 267 of 'Macro Express Explained' that the REG-BINARY value type is supported by ME and uses a Decimal variable? If I've understood you correctly, you're implying that some values can and some can't? If so, is there any way of defining which please? -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
kevin Posted January 21, 2009 Report Share Posted January 21, 2009 Is Joe therefore mistaken when he says in his table on page 267 of 'Macro Express Explained' that the REG-BINARY value type is supported by ME and uses a Decimal variable?When a decimal variable is written to the registry it is stored as a binary value. If a binary value in the registry not written by Macro Express happens to be similar to what a decimal variable would look like, then a macro can read it. Otherwise, reading the binary value will be unpredictable. If so, is there any way of defining which please?A decimal variable written to the registry by your macro can be read into a decimal variable. Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 21, 2009 Report Share Posted January 21, 2009 Which is exactly what I was thinking... A cool back-door way to determine it would be interesting. Terry's suggestion seemed pretty good, though I honestly get nervous when dealing with registry keys. I don't understand them well enough to mess with them (if I broke something, I wouldn't know how to fix it). I reckon I can do it via the registry. Although as ME Pro's Registry commands don't seem to work in this case, I had to work externally, so it's pretty tortuous, and also relies on a utility most won't have. 1. Open the registry using regedit in the Run box 2. Use Alt, a to get to Favourites, in which this key is already saved 3. Tab to 'Settings' and use Enter to open the 'Edit Binary Value' window 4. Use my OCR-based utility Kleptomania to capture the 9th pair 5. Paste value to clipboard 6. Test; 02 = ON, 03 = OFF Checking pixels of the Start logo sounds good to me. Although I'm always nervous about long term session-to-session reliance on such precise pixel positioning in areas like this: -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
floyd Posted January 21, 2009 Report Share Posted January 21, 2009 The binary value in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2 is only updated when you log off and back on to Windows. If the user has changed the Auto Hide taskbar setting StuckRects2 will not reflect the AutoHide status. Kevin is absolutely correct, which is why I could not recommend the solution. So let me repeat my question so we can help find the correct solution: Is the goal then to maximize a window as if the taskbar was showing whether or not it is? Quote Link to comment Share on other sites More sharing options...
davidnnc Posted January 22, 2009 Author Report Share Posted January 22, 2009 Kevin is absolutely correct, which is why I could not recommend the solution. So let me repeat my question so we can help find the correct solution: Is the goal then to maximize a window as if the taskbar was showing whether or not it is? Well, this is exciting. I didn't know that I was going to stir up so much reaction. Anyway, my goal was to resize the window so that it occupied the whole screen except for the screen area occupied by the taskbar. Now if the taskbar happens to be hidden via autohide, then the window would occupy the whole screen. But this would be accomplished by resizing the window not just maximizing it. Thanks, David Quote Link to comment Share on other sites More sharing options...
Cory Posted January 22, 2009 Report Share Posted January 22, 2009 FLOOOOOOOOOOOOYD! "Good morning, Worm your honor!" I haven't heard from you in a coon's age. How ya been? You ever noticed how people don't like answering your questions? "Call the schoolmaster!" I actually watched the movie two nights ago, sorry. Some random thoughts: 1- Could one use controls to look at something like the 'on top', or 'is visible' of the system tray? 2- Open Notepad, maximize, get window height. If this height equals screen height Autohide is on. Quote Link to comment Share on other sites More sharing options...
davidnnc Posted January 22, 2009 Author Report Share Posted January 22, 2009 FLOOOOOOOOOOOOYD! "Good morning, Worm your honor!" I haven't heard from you in a coon's age. How ya been? You ever noticed how people don't like answering your questions? "Call the schoolmaster!" I actually watched the movie two nights ago, sorry. Some random thoughts: 1- Could one use controls to look at something like the 'on top', or 'is visible' of the system tray? 2- Open Notepad, maximize, get window height. If this height equals screen height Autohide is on. I'm using controls now to locate the taskbar, but I can't get the "control visible" or "not visible" to work. I think I can use the "control left", "control top" etc. command to determine the if a taskbar control is off the screen, but I was hoping for something a little more concise. That's why I was hoping to get the control visible/ not visible to work. Maybe I just haven't played with it enough. Quote Link to comment Share on other sites More sharing options...
floyd Posted January 22, 2009 Report Share Posted January 22, 2009 FLOOOOOOOOOOOOYD! "Good morning, Worm your honor!" I haven't heard from you in a coon's age. How ya been? You ever noticed how people don't like answering your questions? "Call the schoolmaster!" I actually watched the movie two nights ago, sorry. It's good to be back. I see things have changed er, very little. Was feeling Comfortably Numb for a while and then I went on the Run and ended up on the Dark Side of the Moon .. were I was Wish[ing] You Were Here. Always good stuff Cory. Thanks. And thanks for filling the void! I guaranteee it is appreciated by all! Well I've been playing with Macro Express Pro for a while now and I find it to be a tremendous tool. This, despite some obvious and inconvenient bugs. I have faith that ISS will do their usual good job of making things better. They've never failed me yet in all these years. And my oh my ... but that External Script command just, well, it just brings a tear to my eye. But okay ... I don't want to thread-jack this fella's post. --------- Well your solution seems plausible except that it would create an unwanted "flash" and it would only work if the "Keep the taskbar on top of other windows" box was checked (Taskbar Properties dialog). Quote Link to comment Share on other sites More sharing options...
floyd Posted January 22, 2009 Report Share Posted January 22, 2009 Well, this is exciting. I didn't know that I was going to stir up so much reaction.Thanks. We try to keep the excitement level, you know, up there. Truly, we do. Anyway, my goal was to resize the window so that it occupied the whole screen except for the screen area occupied by the taskbar. Now if the taskbar happens to be hidden via autohide, then the window would occupy the whole screen. But this would be accomplished by resizing the window not just maximizing it.I see. So maximizing without, er, maximizing. Got it. Seems that we need to find a way to determine desktop client height and width rather than just desktop height and width. Quote Link to comment Share on other sites More sharing options...
floyd Posted January 22, 2009 Report Share Posted January 22, 2009 Is Joe therefore mistaken when he says in his table on page 267 of 'Macro Express Explained' that the REG-BINARY value type is supported by ME and uses a Decimal variable?Must be a mistake. He probably threw a few zingers in the book to see if anyone would notice ... but hey, you didn't hear that from me. Quote Link to comment Share on other sites More sharing options...
joe Posted January 26, 2009 Report Share Posted January 26, 2009 ... but I was hoping for something a little more concise. Well here is something you can use. The attached zip contains both an executable and a Macro Express Pro library file (mex). Have at it. From the Notes tab of the macro: {Taskbar Client Desktop Metrics} Returns taskbar and client desktop metrics to MX Pro. Client desktop metrics exclude space used by the taskbar if it is visible. Macro author: Joseph Weinpert (Macros Limited LLC) Executable by: Floyd P Watergil (Macros Limited LLC) based on code writtten by Bruce Huber Released: Jan-25-2009 Known issues 1) Can produce strange but understandable results when using multiple monitors if the taskbar is positioned off of the primary monitor. 2) Not tested with Vista but should be okay. Runtime program locations We keep executable programs such as this within the Macros Limited LLC subfolder %MacrosLimitedPath% but it doesn't mean that you have to. Feel free to place them wherever it suits best. Just be sure to change the required variables in the script. Return value MX Pro launches the executable and then waits for a string to be returned from it, which takes only a couple of milliseconds. The return string is a locally scoped variable named %returnValue% that contains 10 elements separated by commas. The first 6 elements are metrics about the taskbar. The last 4 elements deal with the client desktop metrics. Taskbar - 1. Visible or Hidden 2. Positioned Left, Right, Top, Bottom, or Unknown 3. X position 4. Y position 5. Width 6. Height Client desktop - 7. X position 8. Y position 9. Width 10. Height Notes 1) If the taskbar is hidden the width and height of the client desktop will match that of the whole desktop. 2) The whole desktop size is inclusive of all monitors. TaskbarClient.zip Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 26, 2009 Report Share Posted January 26, 2009 Hey, great stuff, thanks! I don't really need the tool itself, but I'm going to study your macro to learn more about handling variables. One minor quirk: my Taskbar (always visible) is being reported as 4 pixels wider than my screen. Obviously connected with that negative X-position value. But it looks OK. Return String Visible,Bottom,-2,1172,1924,30,0,0,1920,1172 Taskbar [1] Visible [2] Bottom location [3] -2 X-position [4] 1172 Y-position [5] 1924 width [6] 30 height Client Desktop [7] 0 X-position [8] 0 Y-position [9] 1920 width [10] 1172 height -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
floyd Posted January 26, 2009 Report Share Posted January 26, 2009 One minor quirk: my Taskbar (always visible) is being reported as 4 pixels wider than my screen. Obviously connected with that negative X-position value. But it looks OK. The taskbar metrics are reported using an API call. What you see is what Windows reports. It is anybody's guess why it reports what it reports. Quote Link to comment Share on other sites More sharing options...
davidnnc Posted January 29, 2009 Author Report Share Posted January 29, 2009 For any who are interested here is what I did to determine if the taskbar is hidden via autohide. I've tried it on two different systems with monitors at two different resolutions. Both were running XP. I don't know what will happen on a multi-monitor system or if the taskbar is hidden via some means other than autohide. The following code just determines if the taskbar is visible or not, if not resizes the window to match the monitor. There is more code that follows if the taskbar is visible. The only other thing I noticed. While I was working on this macro, (over several days) I did a Windows update. I can't prove it, but I think the control for the taskbar changed after the upgrade. The Get Control worked fine before the upgrade and then afterward started to fail until I went back and grabbed it again. The second time looked different than the first one. Anyway it's worked since then. Get Control: (EXPLORER.EXE) -> %TaskBar% // Get information on the taskbar and store it in the %TaskBar% variable. Uses the control area of the taskbar where the running applications are shown. Between the START button and the SYSTRAY. // Store information about the monitor dimensions and the taskbar size and location. Variable Set Integer %BarLeft%: Set to a Control's Left (%TaskBar%) // Determine the location in pixels of the left side of the taskbar Variable Set Integer %BarTop%: Set to a Control's Top (%TaskBar%) // Determine the location in pixels of the top of the taskbar Variable Set Integer %BarWidth%: Set to a Control's Width (%TaskBar%) // Determine the width of the taskbar in pixels Variable Set Integer %BarHeight%: Set to a Control's Height (%TaskBar%) // Determine the height of the taskbar in pixels Variable Modify Integer: %BarRight% = %BarLeft% + %BarWidth% // Determines the position in pixels of the right side of the taskbar Variable Set Integer %MonWidth%: Set to a Monitor's Width (0) // Retrieve monitor width in pixels Variable Set Integer %MonHeight%: Set to a Monitor's Height (0) // Retrieve monitor height in pixels // Determine if the taskbar is hidden via Autohide. If Variable %BarTop% Is Greater Than "%MonHeight%" // Taskbar is hidden off the bottom of the screen Or If Variable %BarLeft% Is Greater Than "%MonWidth%" // Taskbar is hidden off the right of the screen Or If Variable %BarTop% Is Less Than "0" // Taskbar is hidden off the top of the screen Or If Variable %BarRight% Is Less Than "0" // Taskbar is hidden off the left of the screen // If any of the above IF statements are true, then the taskbar is considered hidden via Autohide. So the current window is resized to match the size of the monitor. Window Resize: <Current Window> Size: %MonWidth%, %MonHeight% // Taskbar is hidden so set window to the size of the monitor Window Reposition: <Current Window> Move to the top-left corner Macro Stop End If Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.