[jawsscripts] Re: Searching menu structures for a particular menu item

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Mon, 5 Jan 2009 12:05:54 -0500 (EST)

I had not noticed this problem, but just confirmed it.  Querying a menu
state through the Windows API apparently does not always report the
current state.  Weird.

Jamal
On Tue, 30 Dec 2008, Doug Lee wrote:

> Date: Tue, 30 Dec 2008 21:00:06 -0500
> From: Doug Lee <doug.lee@xxxxxxxxxxxxxxxx>
> Reply-To: jawsscripts@xxxxxxxxxxxxx
> To: jawsscripts@xxxxxxxxxxxxx
> Subject: [jawsscripts] Re: Searching menu structures for a particular
>     menu item
>
> Half a question, half a "beware" here:
>
> Jamal, you say the Homer Kit can identify the current state of menu
> items.  I've done that in MSAA as well, but what I found is that the
> state I got was actually the state last seen, not the state currently
> in effect.  This broke down into at least the following cases, and I
> want to know if this is the same situation you found when using the
> Windows API.  These cases are for menu check boxes:
>
> 1.  If the user never opened the menu, the reported state could be
> accurate, but honestly I don't remember the results for this case.
>
> 2.  If the user opened the menu but did not change something, the
> state would be accurate, reliably.
>
> 3.  If the user opened the menu but closed it by changing something,
> the state of that item would reliably be reported as the opposite of
> the state currently in effect.
>
> On Tue, Dec 30, 2008 at 05:14:37PM -0800, Victor Tsaran wrote:
> Thanks Jamal,
> I will definitely give your tools a whirl.
> Best,
> Victor
>
> On 12/30/2008 10:02 AM, Jamal Mazrui wrote:
> > Hey Vic,
> > It's possible to do that via the Windows API but not native JAWS
> > scripting functions, as far as I know.  WinDig is open source
> > http://EmpowermentZone.com/wdsetup.exe
> >
> > so feel free to look at the source code in WinDig.wbt (the WinBatch
> > language).
> >
> > I also wrote a utility dedicated to enumerating menu items which is
> > included in HomerKit
> > http://EmpowermentZone.com/kitsetup.zip
> >
> > MenuList.bas is in PowerBASIC.  The small executable, MenuList.exe,
> > creates a text file that lists all menu items, including their current
> > state (which addresses another question someone had about whether a menu
> > item is disabled).  Look at the UIAlterNateMenu script in Editor.jss for
> > an example of how the output is parsed.
> >
> > Jamal
> > On Wed, 24 Dec 2008, Victor Tsaran
> > wrote:
> >
> >> Date: Wed, 24 Dec 2008 12:10:48 -0800
> >> From: Victor Tsaran<vtsaran@xxxxxxxxx>
> >> Reply-To: jawsscripts@xxxxxxxxxxxxx
> >> To: jawsscripts@xxxxxxxxxxxxx
> >> Subject: [jawsscripts] Re: Searching menu structures for a particular
> >>      menu item
> >>
> >> Hey Jamal,
> >> A quick question for you: is there a way to retrieve text string
> >> associated with a menu ID without actually activating the menu item
> >> itself? I am not able to figure that one out and not sure if the method
> >> even exists..
> >> Thx,
> >> Vic
> >>
> >> Jamal Mazrui wrote:
> >>> I found a message I previously wrote explaining the SendMessage (or
> >>> PostMessage) technique for invoking a menu item.  Once again, WinDig is
> >>> available at
> >>> http://EmpowermentZone.com/wdsetup.exe
> >>>
> >>> You can get almost any of my programs from the Open Source Projects page
> >>> of
> >>> http://NonvisualDevelopment.org
> >>>
> >>> Jamal
> >>>
> >>> From: Jawsscripts-bounces@xxxxxxxxxxxxxxxxxxxx on behalf of Jamal Mazrui
> >>> [empower@xxxxxxxxx]
> >>> Sent: Friday, September 23, 2005 6:36 AM
> >>> To: jawsscripts@xxxxxxxxxxxxxxxxxxxx
> >>> Subject: Using WinDig output to invoke menu choices via SendMessage
> >>>
> >>> In the "Menus" section of WinDig output, the last piece of data on the
> >>> line for a menu item is its menu ID--if one exists.  If a menu item does
> >>> not have a hot key but does have a menu ID, you can create a hot key via a
> >>> JAWS script and the SendMessage function.  For example, the following line
> >>> of WinDig output is about the Paste Special menu item of WordPad:
> >>>
> >>> 2.5       Paste Special...        S       57639
> >>>
> >>> The 2.5 number is the outline number of the menu hierarchy, indicating
> >>> that the menu item is the fifth one down the second menu, the Edit menu.
> >>> The ... ellipses indicate that the menu item presents a dialog.  S is the
> >>> access letter, indicating that you can press it when the Edit menu is
> >>> dropped down to invoke this menu item.  Finally, the 57639 number is the
> >>> menu ID, similar to a control ID.
> >>>
> >>> This review of the WinDig output for WordPad showed no accelerator key for
> >>> PasteSpecial but a menu ID was available.  I am not suggesting that
> >>> scripts are needed for every menu item without a hot key--this is just to
> >>> illustrate the technique, and you would judge whether such a script adds
> >>> significant value in the context of the application.
> >>>
> >>> Although it is also possible to invoke a menu item by sending keystrokes
> >>> to the application, that technique is less reliable because it is affected
> >>> by the current keyboard focus.  It also tends to produce extra speech
> >>> which you may then need to silence with SpeechOff and Delay functions.
> >>>
> >>> The SendMessage approach, on the other hand, does not actually activate
> >>> and navigate the menus of the application's user interface.  It uses a
> >>> Windows message constant, WM_COMMAND, which is passed with a menu ID to
> >>> the application window associated with the menu of interest.  The relevant
> >>> window handle is usually the one returned by GetAppMainWindow, but the
> >>> InvokeMenuItem wrapper function below does not assume this in case you
> >>> wish to use another window, including a window of an application other
> >>> than the one with focus.
> >>>
> >>>    The code below consists of a generic function called InvokeMenuItem, 
> >>> and
> >>> a sample script called PasteSpecial, which might be attached to
> >>> Control+Shift+V. Note that a limitation of this approach is that it only
> >>> works if the application implements standard menus of the Win32 API.
> >>> Unfortunately, many applications do not, such as those in the Microsoft
> >>> Office suite.
> >>>
> >>> Jamal
> >>>
> >>>
> >>> Int Function InvokeMenuItem(Handle h, Int i)
> >>> Var
> >>> Int WM_COMMAND
> >>>
> >>> Let WM_COMMAND = 273
> >>> Return SendMessage(h, WM_COMMAND, i, 0)
> >>> EndFunction
> >>>
> >>> Script PasteSpecial()
> >>> Var
> >>> Handle h,
> >>> Int i
> >>>
> >>> Let h = GetAppMainWindow(GetFocus())
> >>> Let i = 57639 ; menu ID of Paste Special in WordPad
> >>>
> >>> InvokeMenuItem(h, i)
> >>> EndScript
> >>>
> >>>
> >>> _____________________________________________________________
> >>>
> >>> To leave this list, send a blank message to
> >>> jawsscripts-unsubscribe@xxxxxxxxxxxxxxxxxxxxx
> >>> Information about all of our lists:
> >>> http://blindprogramming.com/mailman/listinfo
> >>> Other blindness lists:
> >>> http://www.visionrx.com/library/resources/resource_int1.asp
> >>> Web site address: http://www.BlindProgramming.com
> >>>
> >>>
> >>> _______________________________________________
> >>> Jawsscripts mailing list
> >>> Jawsscripts@xxxxxxxxxxxxxxxxxxxx
> >>> http://blindprogramming.com/mailman/listinfo/jawsscripts_blindprogramming.com
> >>>
> >>> __________
> >>> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
> >>>
> >>> View the list's information and change your settings at
> >>> //www.freelists.org/list/jawsscripts
> >>>
> >>>
> >> __________
> >> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
> >>
> >> View the list's information and change your settings at
> >> //www.freelists.org/list/jawsscripts
> >>
> > __________
> > Visit and contribute to The JAWS Script Repository http://jawsscripts.com
> >
> > View the list's information and change your settings at
> > //www.freelists.org/list/jawsscripts
> >
> >
>
> __________?
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> //www.freelists.org/list/jawsscripts
>
> --
> Doug Lee, Senior Accessibility Programmer
> SSB BART Group - Accessibility-on-Demand
> mailto:doug.lee@xxxxxxxxxxxxxxxx  http://www.ssbbartgroup.com
> "While they were saying among themselves it cannot be done,
> it was done." --Helen Keller
> __________ 
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> //www.freelists.org/list/jawsscripts
>
__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: