OK, that code works fine, but the bit I was missing was grabbing the text
from an MSAA call.  Now up and running with this - thanks to all concerned
and apologies for being slow on the uptake. 


Best wishes.

Tim Burgess
Raised Bar Ltd
Phone:  +44 (0)1827 719822

Don't forget to vote for improved access to music and music technology at

http://www.raisedbar.net/petition.htm
 
-----Original Message-----
From: Jamal Mazrui [mailto:[EMAIL PROTECTED] 
Sent: 08 October 2008 00:01
To: gw-scripting@gwmicro.com
Subject: RE: How to do this with VBScripting

Suppose the control ID of a window to speak is 100, and that window is a
child of the active window.  Using the functions below, the text of the
window could be spoken as follows:

Set oWindow = WindowFindControlID(ActiveWindow, 100) sText =
WindowGetText(oWindow) Speak sText

Function WindowFindControlID(oParent, iID) Dim oChildren, oChild

Set WindowFindControlID = Nothing
If TypeName(oParent) <> "Window" Then Exit Function

Set oChildren = oParent.Children
For Each oChild in oChildren
If TypeName(oChild) = "Window" Then
If oChild.IsValid And oChild.Control.ID = iID Then Set WindowFindControlID =
oChild Exit Function End If End If Next

Set oChildren = Nothing
End Function

Function WindowGetText(oWindow)
Dim oText, oRectangle, oClips
Dim sText

WindowGetText = ""
If TypeName(oWindow) <> "Window" Then Exit Function

Set oText = Text
Set oRectangle = oWindow.Rectangle.ScreenRectangle oText.EnclosingRectangle
= oRectangle oText.Point = ScreenPoint(oRectangle.Left, oRectangle.Top)

Do While True
Set oClips = oText.NextLine
If TypeName(oClips) <> "Clips" Then Exit Do If oClips.Count = 0 Then Exit Do

If Len(sText) > 0 Then sText = sText & vbCrLf sText = sText &
oClips.ClipsText Loop

WindowGetText = sText
End Function



Reply via email to