Jump to content

Reading Toolbar Contents


Recommended Posts

Perhaps (and hopefully) I've just overlooked a command that would make this incredibly easy.

Here's the deal; I need to read the toolbar so my program can act accordingly. By toolbar, I am referring to the bar across the top of all windows which normally contains the likes of "File", "Edit", and "View".

Additionally, if there's any function similiar to IsChecked () that would evaulate the 'check'-ed status of the dropdown options from this toolbar, i.e. View --> Status Bar, that would be equally helpful.

Many thanks!

Link to comment
Share on other sites

It sounds like you're speaking of the menu bar. Although it technically might be equivalent to a toolbar, it's generally called a menu bar. The ones with icons right on the bar are generally called toolbars.

At any rate, I had the same issue as you, it sounds like. In an explorer window I wanted to turn on the status bar. This is how I worked it.

Send("!v")
  ; View menu open. Let's look for a checkmark in front of "Status Bar"
  ; If we don't find one, send a "b" to turn it on
  ; Otherwise send an escape to close the menu
   Sleep(100); give the menu time to display
   PixelSearch(77, 73, 86, 82, 0, 0)
   If @error = 1 Then
      Send("b")
   Else
      Send("{ESC}")
   EndIf

Here, with an Exporer window already open and active, we sent an Alt-v to drop down the View menu. Then we scan the area right in front of the "Status Bar" text, looking for a black pixel. If we find one that means there's a checkmark there and we don't need to do anything so we send an escape to close the menu. If no black pixel was found then there's not a checkmark so we send a "b" to turn on the status bar.

Now, unfortunately this only works with a pretty standard theme such as Windows XP's default. I would imagine it would fail if someone had, for instance, changed the normally black text color to something else, or changed the fonts displayed in menus. Ideally there'd be code here to handle those situations, but in my case I don't need it.

HTH

My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!
Link to comment
Share on other sites

Yes, I am currently using the same "pixel checking" theory, to see if a certain pixel where the checkmark should be is black. However, I am hoping to generate a program that will be compatible with many different setups and I'm striving to make it as generic as possible to accommodate as many different computer settings as possible.

ADD: Internet Explorer is not my primary emphasis, but the software I hope to automate does have a very similiar menu bar, with options checked. My primary concern at the moment is being able to know what menus are on the menu bar, as some can be turned on and off.

Edited by esfalk
Link to comment
Share on other sites

Don't miss these bits of insight as well ..

http://www.hiddensoft.com/forum/index.php?...findpost&p=1100

http://www.hiddensoft.com/forum/index.php?...findpost&p=6093

.. gleaned from a search of these forums. You may find other useful information be employing the same approach - I just picked out a couple which I thought might be pertinent. :huh2:

Hope this helps :D

Link to comment
Share on other sites

If you write it to look for black, it will never work on my PC. Why? Checkboxes (In menu's at least) are white because I use a theme.

The moral of the story is:

Make sure it's impossible for different theme's to be applied on the target computer(s).

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...