Jump to content

[Solved] How can I know If the MenuBar in IE is Focussed or Not?


Zohar
 Share

Recommended Posts

Hello

I need to know If the MenuBar in IE is Focussed or not.

I used this simple code for testing which control is foccused. I connected it to some HotKey:

Sleep(2000)
MsgBox(0,"",ControlGetFocus(""))

Apparently, when I focus on the URL TextBox and do MsgBox ControlGetFocus(""), it works great and gives me Edit1.

Also when I focus on the Browser Control and do MsgBox ControlGetFocus(""), it also works great and gives me Internet Explorer_Server1.

But If I press Alt, so the Focus will move to the MenuBar, and then MsgBox ControlGetFocus(""), I do not get the right result..

How can I get it correctly?

I need to be able to know whether the MenuBar currently has the focus, or not..

I use IE8, but I had this exact problem in IE7 too.

Thank you

Edited by Zohar
Link to comment
Share on other sites

Important Update:

If we try to use ControlGetFocus("") to know if IE's MenuBar is Focussed or not, the resulting behavior is weird, and goes as follows:

  • If the last focussed control is the Browser control, then I the result will be Internet Explorer_Server1, eventho the focus has moved to the MenuBar.
  • If the last focussed control is the URL TextBox, then the result is some unknown control..

I found a workaround for that, I am posting it here for anyone that might have this problem in the future:

If we press Alt and the focus moves to the MenuBar, the StatusBar's Text changes to

"Contains commands for working with the selected items."

When the focus is not ton the MenuBar, the StatusBar's Text will be anything else, but not the sentence above.

So I use that as an indicator for knowing whether the MenuBar is focussed or not.

like this:

MsgBox(0,"",StatusbarGetText("","",1)="Contains commands for working with the selected items.")

It works nicely =)

Edited by Zohar
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...