[jawsscripts] Re: How to

  • From: Anna Giller <anna.giller@xxxxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Mon, 10 May 2010 16:26:36 -0400

Hi Martin!
Would you please advise me on where to learn about SendMessage function.
Thank you very much,
Anna


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Martin Slack
Sent: Friday, April 16, 2010 4:25 AM
To: JAWSScripts
Subject: [jawsscripts] Re: How to

Hi Anna,

  My first thought was to search the current window contents using 
FindString then the call JawsPageDown to bring up the next windowful of text

and so on.  However this was very slow and JawsPageDown doesn't return 
anything to say when the bottom of the file has been reached.  Both of these

problems can be worked around by using SendMessage to communicate directly 
with the window.  Not only is this fast, but an integer is returned which is

zero when and only when there is no more text to display.

  The code below works on my XP machine running JAWS 11.  Note the constant 
definitions which need to be placed outside the script itself.  A similar 
script could be devised to search backwards, although it's no problem now to

return to the top of the file and search again.

  hth

Martin...


Const
  SB_PAGEUP = 2,
  SB_PAGEDOWN = 3,
  WM_VSCROLL = 0x0115

Script test ()
var
  int l, int r, int t, int b,
  int found,
  int scrolling,
  handle hwnd

; say something to indicate script key has been pressed
SayString ("next ")

; initialise variables
let found = 0
let scrolling = 1
let hwnd = GetFocus ()
GetWindowRect (hwnd, l, r, t, b)

; step over any previous find
NextWord ()

; search to the bottom of the current window contents
let found = FindString (hwnd, "+++", S_NEXT, S_UNRESTRICTED, FALSE)

if not found then
  ; move PC cursor to top left of window
  ; so entire window will be searched from now on
  MoveTo (l+8, t+8)
endif

; keep paging down until a find occurs
While (not found) && (scrolling)
  ; ask window to scroll
  let scrolling = SendMessage (hwnd, WM_VSCROLL, SB_PAGEDOWN, 0)

  ; search the current contents of the window
  let found = FindString (hwnd, "+++", S_NEXT, S_UNRESTRICTED, FALSE)
endWhile

; note: FindString searches using the Jaws cursor
; find why the loop terminated

PCCursor ()
if (scrolling > 0) then
  ; move the PC cursor to the start of the matching string and speak it
  RoutePcToJAWS ()
  Pause ()
  SayWord ()
else
  ; move PC cursor to end of file
  JAWSBottomOfFile ()
  SayString ("end of file")
endif

EndScript

__________ 
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


__________пїЅ

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

Other related posts: