[jawsscripts] Re: GetTextInFrame

  • From: "Geoff Chapman" <gch@xxxxxxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Sat, 9 Jan 2010 03:10:10 +1100

Hi Gian.

well, I also never worked out how to achieve with direct scripting calls,
what can
be done more specificly using menu/wizard style front end within frames
manager itself,
regarding grabbing text of only certain colors within the Frames Construct
from within a script.

so, what I ended up dooen to get around this in my work, was I started using
another function called

GetTextInRect ()

instead.  and then carefully worked out the actual absolute screen Left,
top, right and bottom coordinates of that rectangle/frame, which of course
make up the first 4 parameters of the GetTextInRect function.
This is not actually quite as easy as it may sound, because when you put
your mouse on a line of text, and mark the top left, and bottom right hand
corners of the frame,
Jaws Makes some smart adjustments/tweaks to those coordinates, such that all
the pixels which make up the text, are properly included in the frame size,
no matter what their height/font size might be.
check out the positioning tab, in the Frames Properties, remembering though
that they have been taken relative to application window boarders, and not
to absolute screen boarders, which is all that Alt+delete out of the box,
reports.
usually though you can subtract 3 pixels each way, to arrive at an absolute
coordinate, seems to be about standard.

and so you have to insure manually that you replicate this, when you define
your absolute screen coordinates
e.g. ... ok this gets a bit complicated.  and I don't know if you've got hsc
connected to this scratchLive aplication or not.  but it is critical if you
wanna use GetTextInRect, that
you get these absolute screen coordinates accurate, such that they properly
encompass the text at that location correctly. In my testings here, I found
that
the leftHand Coordinate, could be left pretty much at the same absolute x
screen coordinate that alt+delete reports, when your jaws cursor is on the
first letter of the text of the relevant frame.
For the top coordinate though, I've found that often, subtracting about 7
pixels
from the alt+delete Y coordinate readOut at that same spot, would often
suffice for the top of the rectangle coordinate.
For the RightHand coordinate, after taking the jaws cursor to the far right
hand
letter, or position where letters can be written, you might add, about
8 pixels to this figure, before plugging it into the rightHand coord of
GetTextInRect.
and for the Bottom, I'd look at the height of the Frame, in the positioning
tab, and make a guestimate on that. because it can depend on how large the
font is, of the text your talking about, as to the necessary height.  the
Frames manager,
as I say, makes intelligent judgements about that during the definition
process, so, the idea is to try and build your getTextInRect off that.

thus, if the frame height was, say, 13 pixels high, then you'd add 13 pixels
to your top coordinate, to arrive at your bottom edge coordinate.


Here's the fsdn take on GetTextInRect.  I usually leave a 0 as the fifth
parameter, and as it points out, the IgnoreColor, if I don't know the
foreground or background color of my text.
Do you have the fsdn and are you familiar with searching it for some
admittedly terseish definitions of functions?

Function: GetTextInRect
Description
This function gets text inside a rectangle specified by four points on the
screen representing the top, bottom, left, and right boundaries of the
rectangle.
Returns
Type: String
Description: Text inside the rectangle.
Parameters
Param 1:
Type: Int
Description: Left edge of rectangle.
Include: Required
Param 2:
Type: Int
Description: top edge of rectangle.
Include: Required
Param 3:
Type: Int
Description: right edge of rectangle.
Include: Required
Param 4:
Type: Int
Description: bottom edge of rectangle.
Include: Required
Param 5:
Type: Int
Description: attributes of text to include. Use 0 to include all text or use
a combination of attribute flags to only return text with those attributes.
Include: Optional
Param 6:
Type: Int
Description: color of text to include, use IgnoreColor constant for any
color.
Include: Optional
Param 7:
Type: Int
Description: background color of text to include.
Include: Optional
Param 8:
Type: Int
Description: Whether or not to add line breaks or to get the text as one
long string.
Include: Optional
Param 9:
Type: Int
Description: The prefered coordinate system in which the value should be
returned This is only a recommendation and will not work in all places. See
the COORDSYS_xxx constants in hjconst.jsh.
Include: Optional
Version
This function is available in the following releases:
PAC Mate 1.10 and later
JAWS 4.51 and later
Magic 10.5 and later




----- Original Message ----- 
From: "GianniP46" <giannip46@xxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Friday, January 08, 2010 5:33 PM
Subject: [jawsscripts] Re: GetTextInFrame


> ok, thanks I got this working now, but I only need text with certain
colors spoken.  I know how to do this in the frame manager, but can you get
this to work with the GetTextInFrame Function?
> In other words can you only get text with specific attributes?
>   ----- Original Message ----- 
>   From: Geoff Chapman
>   To: jawsscripts@xxxxxxxxxxxxx
>   Sent: Thursday, January 07, 2010 9:57 PM
>   Subject: [jawsscripts] Re: GetTextInFrame
>
>   hi Gian.
>
>   I can probably speak somewhat into this one, but I just haven't been
able to
>   make the time to do it properly! never enough time!
>
>   but, in very basic untested form, which I realize is not how you've
asked
>   for it, wouldn't you just wanna do something like:
>   define CrateName as a local or global string variable, let's say local
for
>   sake of argument near the beginning of your script, after the term
>   var
>   to denote variable list, (though in all standard protocol you should
really
>   probably call it,
>   var
>   string sCrateName
>
>   ; (the preceeding lower case s, indicating that it's a string  variable,
>   ; wouldn't you then just do something like:
>   let sCrateName = GetTextInFrame ("MyFrameName")
>   if StringContains (sCrateName, "TextToWatchFor") then
>   ; do whatever you need.
>   EndIf
>
>   something like that?
>
>   however what I'm not sure about here is, and what I do keep insisting
you
>   reeally need to work on getting down too if your gunna work with frames,
is
>   to insure that their validation criteria is accurate.  i.e. that their
>   WindowTitle, or Class parameter, far more often the former than the
latter
>   is problematic in my experience,
>   is not breaking the frame from working.
>
>   gotta run. see how you go with this so far.
>
>
>
>   ----- Original Message ----- 
>   From: "GianniP46" <giannip46@xxxxxxxxxxxxx>
>   To: "JawsScriptsList" <JawsScripts@xxxxxxxxxxxxx>
>   Sent: Tuesday, January 05, 2010 2:57 PM
>   Subject: [jawsscripts] GetTextInFrame
>
>
>   > Hi all,
>   > Can someone give me some sample code to get the text that is in a
frame
>   that is already defined and have that text assigned to a string variable
>   called CrateName.
>   > I am trying to check a frame to see if it contains certain text.  If
it
>   does, then I need to do something in particular.
>   > Thanks!
>   >
>   >
>   > Gian Pedulla
>   > GianniP46@xxxxxxxxxxxxx
>   >
>   > LETS! GO! METS!
>   > __________
>   > 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
>
>
>
> --------------------------------------------------------------------------
----
>
>
>
>   No virus found in this incoming message.
>   Checked by AVG - www.avg.com
>   Version: 9.0.725 / Virus Database: 270.14.129/2606 - Release Date:
01/07/10 14:35:00
>
> __________
> 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

Other related posts: