104 lines
No EOL
2.9 KiB
JavaScript
Executable file
104 lines
No EOL
2.9 KiB
JavaScript
Executable file
; Copyright 2022 Freedom Scientific Inc.
|
|
; Copyright 2025 TheAdam <theadam.eu>
|
|
|
|
import "uia.jsb"
|
|
include "hjconst.jsh"
|
|
include "common.jsm"
|
|
include "uia.jsh"
|
|
|
|
const
|
|
TerminalClassName = "TermControl"
|
|
|
|
|
|
globals
|
|
int WindowsTerminalObjectID,
|
|
object WindowsTerminalTextProvider,
|
|
int WindowsTerminalLastKeyPress
|
|
|
|
Script ScriptFileName()
|
|
ScriptAndAppNames("Windows Terminal")
|
|
EndScript
|
|
|
|
void function ProcessSayAppWindowOnFocusChange(handle AppWindow, handle FocusWindow)
|
|
EndFunction
|
|
|
|
void function ProcessSayRealWindowOnFocusChange( handle AppWindow, handle RealWindow, string RealWindowName, handle FocusWindow)
|
|
EndFunction
|
|
|
|
Int Function IgnoreObjectAtLevel(int level)
|
|
var
|
|
int type = GetObjectSubTypeCode()
|
|
if type == WT_LISTBOX ||
|
|
type == WT_LISTBOXITEM
|
|
return true ; prevent overspeaking with Ctrl+Tab
|
|
EndIf
|
|
return FALSE
|
|
EndFunction
|
|
|
|
string function GetTextInConsoleWindow()
|
|
var
|
|
object oNull,
|
|
object visibleRanges,
|
|
object range
|
|
if GetObjectClassName() != "TermControl"
|
|
return ""
|
|
EndIf
|
|
if !WindowsTerminalTextProvider
|
|
WindowsTerminalTextProvider = FSUIAGetFocusedElement().GetTextPattern()
|
|
EndIf
|
|
visibleRanges = WindowsTerminalTextProvider.GetVisibleRanges()
|
|
range = visibleRanges(0)
|
|
return range.GetText(-1)
|
|
EndFunction
|
|
|
|
script VirtualizeWindow()
|
|
var string text = StringTrimTrailingBlanks(GetTextInConsoleWindow())
|
|
if !text then
|
|
SayMessage(OT_ERROR,cmsgNoTextToVirtualize_L,cmsgNoTextToVirtualize_S)
|
|
return
|
|
endIf
|
|
SayMessage(ot_JAWS_Message,cmsgVirtualizeWindow_L,cmsgVirtualizeWindow_S)
|
|
UserBufferClear()
|
|
UserBufferAddText(text)
|
|
UserBufferActivate()
|
|
JAWSBottomOfFile()
|
|
EndScript
|
|
|
|
string function ProcessUiaText(string text)
|
|
var stringArray lines = StringSplit (text, "\n", false)
|
|
var int x = 0
|
|
var string out = ""
|
|
if ArrayLength(lines) == 1
|
|
out = StringConcatenate (out, lines[x])
|
|
EndIf
|
|
For x = 0 to ArrayLength(lines)
|
|
if StringLength (stringStripAllBlanks (lines[x+1])) < 2 & lines[x+1] != "\n" & x != ArrayLength(lines)
|
|
out = StringConcatenate (out, StringReplaceChars (lines[x], "\n", " "))
|
|
else
|
|
out = StringConcatenate (out, lines[x], "\n")
|
|
EndIf
|
|
EndFor
|
|
out = StringConcatenate (out, lines[x+1], "\n")
|
|
return out
|
|
EndFunction
|
|
|
|
Void Function KeyPressedEvent (int nKey, string strKeyName, int nIsBrailleKey, int nIsScriptKey)
|
|
if (nKey > 100000)
|
|
WindowsTerminalLastKeyPress = WindowsTerminalLastKeyPress+1
|
|
else
|
|
WindowsTerminalLastKeyPress = 0
|
|
EndIf
|
|
EndFunction
|
|
|
|
void function UIANotificationEvent(int notificationKind, int notificationProcessing, string displayString, string activityId, string appname)
|
|
var string ki = ProcessUiaText(displayString)
|
|
;Say (IntToString (WindowsTerminalLastKeyPress) , OT_NONHIGHLIGHTED_SCREEN_TEXT)
|
|
if WindowsTerminalLastKeyPress >= 2
|
|
WindowsTerminalLastKeyPress = 0
|
|
ENDIF
|
|
if WindowsTerminalLastKeyPress == 0
|
|
Say (ki, OT_NONHIGHLIGHTED_SCREEN_TEXT)
|
|
else
|
|
WindowsTerminalLastKeyPress = WindowsTerminalLastKeyPress+1
|
|
ENDIF
|
|
EndFunction |