[jawsscripts] Re: FindColors
- From: "Paul Magill" <magills@xxxxxxxxxxx>
- To: <jawsscripts@xxxxxxxxxxxxx>
- Date: Mon, 27 Jul 2009 18:20:30 +1000
Hi Gian ,
Below are 2 scripts I use for a similar purpose.
- you may be able to extract from them what you need.
The first 1 sets the color that the second script will use to search for. To
use the first script, just place the active cursor on the text with the
color that is to be searched for.
CONST
C_UserSection = "User Section",
C_ErrorColorKey = "Error Color"
Globals
INT G_TextColor
String Function GetConfigFilePath ()
RETURN (FindJAWSSettingsFile (GetActiveConfiguration () + ".jcf", True))
EndFunction
Script SetColorToFind ()
; obtains the color to find, & saves it to the configuration file
VAR
INT Dummy,
STRING ApproxColorName
LET G_TextColor = GetColorText () ; gets the color of the forground text at
the location of the active cursor
LET ApproxColorName = GetColorName (GetColorApproximation (G_TextColor,
Dummy))
IF IniWriteInteger (C_UserSection, C_ErrorColorKey, G_TextColor,
GetConfigFilePath (), True) THEN
SayUsingVoice (VCTX_Message, ApproxColorName + ", saved as search color",
OT_No_Disable)
ELSE ; failed to write the color to the mainframe.jcf file
SayUsingVoice (VCTX_Message, "Failed to save the color to file, " +
GetConfigFilePath (), OT_No_Disable)
ENDIF
EndScript
Script FindAndReadColoredText ()
VAR
INT Dummy,
STRING ApproxColorName,
STRING SaveColorMessage
LET SaveColorMessage =
"Place the active cursor on the text with the color to be saved, \R\Nand use
" + GetScriptKeyName ("SetColorToFind")
IF IsSameScript () THEN
SayUsingVoice (VCTX_Message, SaveColorMessage, OT_No_Disable)
RETURN
ENDIF; key hit twice for reminder notes
Delay (3) IF IsKeyWaiting () THEN RETURN ENDIF ; smooths double key hit
IF (G_TextColor == 0) THEN ; color has not been read from file or has not
been set yet
SayUsingVoice (VCTX_Message, "The color to find has not been saved, or has
failed to be read from file. \R\N" + SaveColorMessage, OT_No_Disable)
RETURN
ENDIF ; no color recorded to search for
; SaveCursor () ; so whichever cursor was active at the time, will be reset
when the script ends
LET ApproxColorName = GetColorName (GetColorApproximation (G_TextColor,
Dummy))
; if a particular cursor is preferred for the search, set that with an item
from the below line, or whichever of them was last active will be used
; InvisibleCursor () ; JAWSCursor ()
IF FindColors (G_TextColor, IgnoreColor , S_Top, True) THEN
Say (GetColorField (), OT_No_Disable)
ELSE ; no text of that color found
SayUsingVoice (VCTX_Message, ApproxColorName + " text not found",
OT_No_Disable)
ENDIF ; search for color successful or not
; RestoreCursor ()
EndScript
Regards, Paul from Aust
----- Original Message -----
From: "GianniP46" <giannip46@xxxxxxxxxxxxx>
Hey Guys,
I want to write some code that will search a line of text for a specific
color and if it finds that color, it will then say the word with that
color. Just assume the cursor is positioned at the beginning of the line.
The color is black on Gray80 and the RGB values are 000000000 and 204204204.
Here is the code that I came up with, but it doesn't work.
FindColors (000000000, 204204204, S_NEXT, 1)
SayWord ()
The cursor doesn't move at all
Any ideas?
Gian Pedulla
__________
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: