/*
Simple AHK script to change a number in a textfile to count stuff.
You need to have AutoHotey installed: ahkscript.org
- Edit this script accordingly:
- Change the hotkeys to increase/decrease the number
- Just remove the second hotkey if you don't need one to decrease
the number (comment out or remove the whole section)
- Change the file name/path if necessary
- You can have some text added behind the number if you want
- Run the script with AutoHotkey and use the hotkey, it should create
the file, which you can then add in your streaming program as source
for a text layer
*/
; The file to read from/write the number to
filepath := "test.txt"
; Add some text behind the number
appendText := ""
/*
Add window name if it should be restricted
(http://ahkscript.org/docs/commands/_IfWinActive.htm)
*/
#IfWinActive
/*
This are the actual hotkeys
(how to define: http://ahkscript.org/docs/Hotkeys.htm)
*/
; Hotkey to increase number
!q::
ChangeNumber(1)
Return
; Hotkey to decrease number
!w::
ChangeNumber(-1)
Return
#IfWinActive
; Function to change the number in the file
ChangeNumber(Add)
{
global filepath
global appendText
file := FileOpen(filepath, "rw", "UTF-8")
Num := RegExReplace(file.Read(), "[^0-9]*")
if (StrLen(Num) = 0) {
Num := 0
}
Num := Num + Add
if (Num < 0) {
Num := 0
}
Output := Num . appendText
;MsgBox, Writing: %Output%
file.Length := 0
file.Seek(0, 0)
file.Write(Output)
file.Close()
}
Comments