ScriptTip#110: CopyTextFromScreen. Synopsis: Copys specified text from the screen.
1. Hit Control+Shift+0 to launch the Script Manager with the default.jss file loaded into the editor.
2. Hit Control+End to reach the bottom of this file, then hit Enter a few times to give yourself room to work.
3. Type in, or cut and paste, the following script:
***
;Grabs text from screen and writes it to clipboard.
;6/16/99 by Dennis Brown, brown99@mindspring.com.
;Modified by David Truong, dtruong@enterprise.powerup.com.au
;6/17/99 DM: Added menu selection routine.
Script CopyTextFromScreen ()
Var ;create a couple variables to hold the text.
string Char, ; will hold the current character at the cursor.
string Word, ;will hold the current word.
string Line, ;will hold the current line.
string Window, ;will hold current window's text.
String MyMenu, ;text for menu display.
Int index ; will hold menu item number.
;First, assign the text at the current active cursor's position
;to the appropriate variables.
let Char=GetCharacter()
let Word=GetWord()
let Line=GetLine()
let Window=GetWindowText(GetFocus(),FALSE)
;Now, create menu.
let MyMenu="|Character" +
"|Word" +
"|Line" +
"|Current window"
Let index=DlgSelectItemInList (MyMenu, "Copy text from screen menu", False)
;Ok, take the menu item you selected and run it through these condition
;statements to execute the appropriate associated tasks!
If (index==1) then ;You want to save just a single character?
CopyToClipboard (Char) ;Ok, put that character onto the clipboard.
Say(Char,ot_string) ;Announce what you just saved!
ElIf (index==2 ) then ;You want to save just the current word?
CopyToClipboard (Word) ;Ok, place it onto the clipboard,
Say(Word,ot_string) ;and announce that word.
ElIf (index==3 ) then ;You want to save the current line?
CopyToClipboard (Line) ;Ok, place that line onto the clipboard,
Say(Line,ot_string) ;and announce the line.
ElIf (index==4 ) then ;So you want the entire window?
CopyToClipboard (Window) ;Ok, place it onto the clipboard,
Say(Window,ot_string) ;and announce the window.
EndIf
EndScript
***
4) While in this script, hit Control+D to edit it's properties.
5) Tab down through the fields, making sure that the "Can be assigned to key is checked, and fill in the "Synopsis:" and "Description:" fields.
6) Tab to the "Assign to keystroke..." field and hit whatever key combination you want to use to trigger this script, such as Alt+Control+G.
7) Tab to, then select Ok, and when back in the editor, hit Control+S to compile the modifications.
You may need to recycle JFW from memory before the changes are activated.