Sign in to follow this  
Followers 0
PaulIA

ToolbarWindow32

15 posts in this topic

I'm doing an unattended installation and need to work with a ToolbarWindow32 control. The control is in "My Computer" (what you get when you launch Explorer.exe). I need to be able to read the state of the "Status Bar" check box under the "View" menu.

Since the ToolbarWindow32 control does not implement a a standard menu, I can't find anything in AutoIt that will enable me to do this. I'm sure somebody out there has already figured this out. Any help or appropriate suggestions would be appreciated.


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites



This is probably a quicker approach:

Global $g_nExitCode = Main()
Exit $g_nExitCode

Func Main()
    Opt("WinTitleMatchMode", 4)
    Local $hControl = ControlGetHandle("classname=CabinetWClass", "", "msctls_statusbar321")
    If $hControl Then
        If BitAND(WinGetState($hControl), 2) Then
            MsgBox(4096, "", "Statusbar is visible.")
        Else
            MsgBox(4096, "", "Statusbar is not visible.")
        EndIf
    Else
        MsgBox(4096, "", "No Explorer windows open.")
    EndIf
EndFunc ; Main()

Share this post


Link to post
Share on other sites

Oops! Probably should have stated that the "Status Bar" scenario was just an example. (Clever solution though!)

Actually, what I'm looking for is a generic way to be able to read the menus associated with ToolbarWindow32 and Explorer. I need to maniplate the "Show in Groups", "Auto Arrange", etc. so I was looking for something that I could actually query the menus with. I can set the individual menu items, but the "Status Bar" type ones will toggle on you if they're already set.

However, if you've got a couple of more tricks up your sleeve, I wouldn't have to mess with it anymore. :)

Thanks!


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I believe Explorer uses a standard menu. It's not a toolbar. You need to look on MSDN how to manipulate menus.

I guess it is a toolbar. I would go a completely different way. I'd look at the object model for the shell and see if I could use it's COM interface to get/set the things you want. Alternatively, I'd set the registry entries directly and then reboot so they would take effect. I think you'll find automating Explorer via the UI will be quite difficult. Since the menu is a toolbar, I suspect it's probably a group of buttons that when clicked cause a popup menu to appear. This will likely prove very difficult to automate unless you use keystrokes to do it.

Edited by Valik

Share this post


Link to post
Share on other sites

Yeah, it's becoming a real pain the the back side. I have all of the code to return a collection of buttions, identify the text, command ids, button, styles, window rects, etc. I can send the WM_COMMAND to set the state of each item in the menus. The only thing I don't have is a method to determine what state the check box items are in so I'm not toggling them off if they're already on.

Thought about looking at IShellFolder and did a little research, but for the life of me couldn't see where you could set these items. Interfaces are definitely not my strength though, so I may have missed it.

Registry would definitely work (and be a heck of a lot simpler), but I was looking for a more universal approach to dealing with this specific control class so that I could put in in the library.

Thanks for the help. Its always good to get insight from somebody else. I might mull over going back and giving the interface some more research. I'm so close to having this done, I'd hate to give up on it.


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Yeah, it's becoming a real pain the the back side. I have all of the code to return a collection of buttions, identify the text, command ids, button, styles, window rects, etc. I can send the WM_COMMAND to set the state of each item in the menus. The only thing I don't have is a method to determine what state the check box items are in so I'm not toggling them off if they're already on.

Thought about looking at IShellFolder and did a little research, but for the life of me couldn't see where you could set these items. Interfaces are definitely not my strength though, so I may have missed it.

Registry would definitely work (and be a heck of a lot simpler), but I was looking for a more universal approach to dealing with this specific control class so that I could put in in the library.

Thanks for the help. Its always good to get insight from somebody else. I might mull over going back and giving the interface some more research. I'm so close to having this done, I'd hate to give up on it.

Out of curiosity, would it be possible to check the current values in the registry, and then use what you have stated above in conjunction with that to complete your objective?

I hope that helps a bit,

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

You should be able to use GetMenuState() to check for MF_CHECKED. See MSDN for GetMenuState() for more information.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Out of curiosity, would it be possible to check the current values in the registry, and then use what you have stated above in conjunction with that to complete your objective?

Yes, I could check the registry for this specific instance, but I'm trying to come up with a standard approach to reading menus derived from ToolbarWindow32 controls. I guess my Explorer example was a bad choice. :) Edited by PaulIA

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Explorer was a horrible choice. In fact, picking any Microsoft product is a horrible choice because Microsoft rarely use the coding conventions they provide.

Share this post


Link to post
Share on other sites

Explorer was a horrible choice. In fact, picking any Microsoft product is a horrible choice because Microsoft rarely use the coding conventions they provide.

I have noticed.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

You should be able to use GetMenuState() to check for MF_CHECKED. See MSDN for GetMenuState() for more information.

This is what I'm currently trying to get sorted out. Unfortunately, the ToolbarWindow32 class is not a menu, just a tool bar. None of the menu calls will work on it. I have used the TB_BUTTON type calls to query all of the buttons to get the text, size, command ids, etc.

However (going back to the Explorer example), a menu doesn't appear until you actually press one of the toolbar buttons. For example, if I press the "View" button, the toolbar creates a popup menu (dialog #32768). I'm thinking that I should be able find this new window and use the GetMenu calls on that dialog then. Just trying to figure out the code to do this right now. It really gets complicated because you can press "View" | "Arrange Icons by" and now you've got TWO dialogs to deal with. :)

Thanks for the input guys, I really appreciate it.


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

I have all of the code to return a collection of buttions, identify the text, command ids, button, styles, window rects, etc. I can send the WM_COMMAND to set the state of each item in the menus. The only thing I don't have is a method to determine what state the check box items are in so I'm not toggling them off if they're already on.

For a ToolbarWindow32? Nice! Would you mind sharing that code? :)

Share this post


Link to post
Share on other sites

For a ToolbarWindow32? Nice! Would you mind sharing that code?

I sure will. But first I've got to figure out the menu problem so I can finish this project at work. After that, I'll put in the documentation/examples and it should be ready to go.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

@sohfeyr: I put out a new release of Auto3Lib that has support for ToolbarWindow32 controls. It also supports the toolbar/menu combination (like in Explorer and IE) so that you can now properly manipulate the buttons and menu items.


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

@sohfeyr: I put out a new release of Auto3Lib that has support for ToolbarWindow32 controls. It also supports the toolbar/menu combination (like in Explorer and IE) so that you can now properly manipulate the buttons and menu items.

Sweet! And I bet I'm not the only one who's going to get a lot of use out of that...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0