Skip to content

Commit

Permalink
Get the list of windows to monitor from a separate file rather than i…
Browse files Browse the repository at this point in the history
…t being hardcoded, so you can modify it easier.
  • Loading branch information
Piotr Machacz authored and Piotr Machacz committed Jun 13, 2020
1 parent 7f9014a commit f536662
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
20 changes: 11 additions & 9 deletions rts.au3
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
#include "tolk.au3"
$watchlist="Output|Choices|Player|Monster|Relic|hand"

$WindowList=StringSplit($watchlist, "|")
dim $OldText[$WindowList[0]]
$WindowList=FileReadToArray("watchlist.txt")
If @error then
Msgbox(16, "Error", "Couldn't read Watchlist. The file may either be empty, inaccessible or not exist.")
exit
EndIf
dim $OldText[UBound($WindowList)]
Tolk_Load()
if not Tolk_IsLoaded() then
Msgbox(16, "Error", "Tolk failed to load!")
exit
EndIf
func speak($text)
If $text>"" then tolk_output($text)
If $text>"" then tolk_output($text);Suppress blank lines because NVDA gets chatty
endFunc
func Quit()
Speak("Exitting")
exit
EndFunc
HotKeySet("^q", "Quit")
while 1
for $i=1 to $WindowList[0] step 1
for $i=0 to UBound($WindowList)-1 step 1
$text=ControlGetText($WindowList[$i], "", "[CLASS:Edit]")
If $text <> $OldText[$i-1] then; speak the new text!
If $text <> $OldText[$i] then; speak the new text!
Speak($WindowList[$i]);announce what window the output came from
If $WindowList[$i]="Output" then ;The entire output Window should always be reread since that's generally requested by the player
Tolk_Output($text)

else ;For other windows, compare the old and newly changed text line by line to only anounce the ones that changed.
$OldArray=StringSplit($OldText[$i-1], @crlf, 1)
$OldArray=StringSplit($OldText[$i], @crlf, 1)
$NewArray=StringSplit($text, @crlf, 1)
For $i2=1 to $NewArray[0] step 1
If $i2<uBound($OldArray) then;line numbers that exist in both strings
Expand All @@ -36,7 +38,7 @@ EndIf
next
EndIf;Output or other windows check
EndIf;Speak if the text was different
$OldText[$i-1]=$text;Set the old text to the new
$OldText[$i]=$text;Set the old text to the new
next

sleep(10)
Expand Down
5 changes: 5 additions & 0 deletions watchlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Output
Choices
Player
Monster
Relic

0 comments on commit f536662

Please sign in to comment.