This is going to be a complicated question but I'll do my best...
c:\MyTextFile.txt contains:
Code: Select all
one
two
three
four
five
six
seven
eight
nine
ten
A single click of WheelDown will show a tooltip saying "one". Another click of WheelDown will show a tooltip saying "two". A third click shows "three" and so on.
The same for WheelUp, except is goes upwards. So on each WheelUp click it will show a tooltip of "ten", "nine", "eight" and so on.
When the clicks hit each end (meaning when the click reaches "one" on one end or "ten" on the other, it will not wrap around- it hits the boundary at either end (and yes this is the intended action). So if it's at "ten", the next click says "ten" again and so on. Same for "one".
So basically the WheelUp and WheelDown clicks will go up and down the text file and not go past the boundary on either end.
Which leads the the question: right now the code is always reading from the text file on each WheelUp/WheelDown click.
How would I go about loading the text file into a variable first and then reading each line from this variable instead of the file? Because right now it's a little slow when having to read from the hard disk every time a WheelUp/WheelDown event occurs. If it was reading from the variable instead then I'm guessing it might speed things up quite a bit? Here's the code (which I didn't write, someone was nice enough to provide this a few years back):
Code: Select all
check = 0
fileread,content,c:\MyTextFile.txt
arr:=strsplit(content,"`r","`n")
cnt:= arr.length()
wheeldown::
upwards:=% ++check > cnt ? "Out-of-bounds" : arr[check]
;msgbox, % --check < 1 ? "Out-of-bounds" : arr[check]
FileReadLine, Line_Contents, c:\MyTextFile.txt, %check%
tooltip, %upwards% and the line content is %Line_Contents%
sleep, 50
check := Min(check,cnt+1)
return
wheelup::
downwards:=% --check < 1 ? "Out-of-bounds" : arr[check]
FileReadLine, Line_Contents, c:\MyTextFile.txt, %check%
tooltip, %downwards% and the line content is %Line_Contents%
sleep, 50
check := Max(check,0)
return