[jawsscripts] Best way to click a button?

Hello all. I am trying to find and click a preview button. This button always 
has the same control ID, and generally I can click the button with my script. 
If I put an if then statement in it, then the statement evaluates to false, 
even though the button is available. This button can appear in different 
windows within the program, and so I've been playing with find Descendant 
window, find window etc. If I leave the if statement out of the script, things 
work well, 90% of the time. Any tips as to how I could make this work better 
would be greatly appreciated.
Code below.
Script ClickPreviewButton ()

If FindString (GetAppMainWindow (GetCurrentWindow ()), "preview", s_bottom, 
s_unrestricted) then

LeftMouseButton ()

PCCursor ()

Else

SayMessage (ot_error, "Preview button was not found", "Preview not found")

EndIf

EndScript



Casey Mathews
Web Friendly Help | Demystifying Tech
www.webfriendlyhelp.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

Other related posts: