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

  • From: Doug Lee <doug.lee@xxxxxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Tue, 23 Dec 2008 17:12:43 -0500

Notice the NextLine() calls in each of the loops.  That means the
loops are moving down through menu items.  There are then checks for
specific items, which indicates that the loops are searching for items
and then acting on them.  In short, this code emulates what you might
do manually:  Open the menu bar, bring down a menu, find an item,
press Enter for a submenu, find a subitem, etc.

On Tue, Dec 23, 2008 at 05:00:54PM -0500, Andy Borka wrote:
What's up with the loops though?

Twitter: www.twitter.com/sonfire


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Doug Lee
Sent: Tuesday, December 23, 2008 4:51 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Searching menu structures for a particular menu
item

I only whizzed through that, but I can tell you two things anyway:
First, it looks like it's running menus by sending keystrokes and
waiting/watching for their results to happen.  Second,
ActivateMenuBar() is a JAWS scripting function that actually turns the
menu bar on if it's off and off if it's already on; so that funny If
with one above and two below the Else is really just making sure the
menu bar is freshly activated, i.e., no menu is open and the cursor is
sitting on item #1.

On Tue, Dec 23, 2008 at 04:36:28PM -0500, Andy Borka wrote:
Can anybody make heads or tails out of this code? I am trying to figure it
out and possibly use it as an example template to follow when accessing menu
items but can't figure it out for the life of me.


var
Int IMenuActive, ;See if the menu is active
int ISafety1, ;Safety for another while loop
Int ISafety ;Safety for the while loop
Let IMenuActive =MenusActive ()
Let ISafety =0 ;Set ISafety to 0
Let ISafety1 =0
SpeechOff ()
PCCursor ()
If IMenuActive ==0 then
ActivateMenuBar ()
else
ActivateMenuBar ()
ActivateMenuBar ()
EndIf
Pause ()
While (GetWord () !="New" &&ISafety <=20)
NextLine ()
If GetWord () =="New" then
Let ISafety =50 ;End the while loop.
EnterKey ()
EndIf
Let ISafety =ISafety +1 ;Count the while up.
EndWhile
Pause ()
While (GetLine () !="Address Book Card" &&ISafety1 <=7)
NextLine ()
If GetLine () =="Address Book Card" then
Let ISafety1 =40
EnterKey ()
EndIf
Let ISafety1 =ISafety1 +1
EndWhile
SpeechOn ()
RestoreCursor ()

Twitter: www.twitter.com/sonfire


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Bryan Garaventa
Sent: Tuesday, December 23, 2008 4:28 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Searching menu structures for a particular menu
item

This is copied from one of my prior scripts.

SpeechOff ()

var object o, int cid,

string stv, handle gw

{alt+o}

Pause ()

let o = GetObjectAtPoint (cid, GetCursorCol (), GetCursorRow ())

o.accDoDefaultAction(6)

Pause ()

; ... script continues with SpeachOn(), etc.


The only way I was able to make this work, was by first manually activating 
the menu, so Doug is right, I believe it does have to be visible first.


----- Original Message ----- 
From: "Doug Lee" <doug.lee@xxxxxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Tuesday, December 23, 2008 1:05 PM
Subject: [jawsscripts] Re: Searching menu structures for a particular menu 
item


> Come to think of it, this probably won't really help much after all.
> You can find menus and menu items in MSAA, but I don't think you can
> activate a menu option without first making it visible on screen.  I
> believe the menuItem codes mentioned earlier in this thread, locatable
> with WinDig, would allow you to execute menu items.  The JAWS
> SendMessage function should let you do that without AutoIt though.
>
> As far as sample code, there was some in the Skype scripts, probably in
> SkypeUtil.jsl; but I don't think it's there anymore.  I don't have to
> do this very often.
>
> On Tue, Dec 23, 2008 at 03:58:27PM -0500, Andy Borka wrote:
> Hi. Do you have any example code that searches for particular menu items?
> How do you deal with the top level menus in the menu bar (telling what one
> is what)?
>
>
> Twitter: www.twitter.com/sonfire
>
>
> -----Original Message-----
> From: jawsscripts-bounce@xxxxxxxxxxxxx
> [mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Doug Lee
> Sent: Tuesday, December 23, 2008 2:50 PM
> To: jawsscripts@xxxxxxxxxxxxx
> Subject: [jawsscripts] Re: Searching menu structures for a particular menu
> item
>
> It's a bit more involved than I can recall or fully describe here, but
> here are the main ingredients I remember:
>
> 1.  Get the menubar object with
> GetObjectFromEvent(getTopLevelWindow(getFocus()), ObjID_Menu, 0, childID).
> ChildID is a placeholder.
>
> 2.  The menubar's items will be indexable by childIDs starting at 1,
> so for "File View Window Help," "Window" should be o.accName(3).  To
> get its object, do o.accChild(3).  You can of course search through
> these with a loop that runs from 1 through o.accChildCount inclusive.
>
> 3.  A menubar item has one child in MSAA:  The pop-up menu associated with
> it.
> To get that, do .accChild(1) on what you got in the previous step.
>
> 4.  The menu you now have has menu items much like the menubar did,
> each with its own pop-up menu where applicable.  Start again at step 2
> to search deeper.
>
> Tip:  JAWS now has functions that search MSAA object trees for names.
> If this works for menu hierarchies, and depending on your needs once
> you find something, that may significantly decrease the level of
> effort required for your situation.
>
> On Tue, Dec 23, 2008 at 02:37:38PM -0500, Jamal Mazrui wrote:
> There is not a way to do this natively through JAWS, except possibly by
> searching the MSAA hierarchy associated with a menu.  I don't know how
> to do that, but Doug Lee might ....
>
> If you are willing to install a free COM server, AutoIt,
> http://AutoItScript.com
>
> includes the method documented below.  Another approach is to get the ID
> of the menu item of interest via WinDig
> http://EmpowermentZone.com/wdsetup.exe
> and invoke it with a PostMessage call.
>
> Jamal
>
>
> WinMenuSelectItem
>
>
> Invokes a menu item of a window.
>
> WinMenuSelectItem "title", "text", "item" [, "item" [, "item" [, "item"
> [,
> "item" [, "item" [, "item"]]]]]]
>
>
> Parameters
> titleThe title of the window to read.
> textThe text of the window to read.
> itemText of Menu Item
> item(optional) Text of SubMenu item
> item(optional) Text of SubMenu item
> item(optional) Text of SubMenu item
> item(optional) Text of SubMenu item
> item(optional) Text of SubMenu item
> item(optional) Text of SubMenu item
>
>
> Return Value
> Success:Returns 1.
> Failure:Returns 0 if the menu could not be found.
>
>
> Remarks
> You should note that underlined menu items actually contain a &
> character to
> indicate the underlining. Thus, the menu item File would actually
> require the
> text "&File", and Convert would require "Con&vert" You can access menu
> items
> up to six levels deep; and the window can be inactive, minimized, and/or
> even
> hidden.
>
> WinMenuSelectItem will only work on standard menus. Unfortunately, many
> menus
> in use today are actually custom written or toolbars "pretending" to be
> menus.
> This is true for most Microsoft applications.
>
>
> Related
> ControlCommand, Send
>
> Example
> Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
>
> ' This will select File, Page Setup in notepad
> oAutoIt.WinMenuSelectItem "Untitled - ", "", "&File", "Page Set&up..."
>
> On
> Tue, 23 Dec
> 2008, Andy Borka wrote:
>
>> Date: Tue, 23 Dec 2008 08:35:46 -0500
>> From: Andy Borka <andy@xxxxxxxxxxxxxxxxxxx>
>> Reply-To: jawsscripts@xxxxxxxxxxxxx
>> To: jawsscripts@xxxxxxxxxxxxx
>> Subject: [jawsscripts] Searching menu structures for a particular menu
>>     item
>>
>> I have a particular menu structure that I need to search through in order
> to
>> get to a particular menu item. I know the text on the menu item I want to
>> find but the placement of the menu items change depending on what "view"
> you
>> are on in the program. How would I go about searching for and then
>> activating the menu item (or giving an error message if it can't be
> found)?
>> Twitter: www.twitter.com/sonfire
>>
>>
>>
>>
>> __________?
>> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>>
>> View the list's information and change your settings at
>> http://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
> http://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
> http://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
> http://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
> http://www.freelists.org/list/jawsscripts
>
>
> _______________________________________
> No viruses found in this incoming message
> Scanned by iolo AntiVirus 1.5.6.3
> http://www.iolo.com
> 

__________?
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
http://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 
http://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 
http://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 
http://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 
http://www.freelists.org/list/jawsscripts

Other related posts: