Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 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 := "E:\Games\Steam\steamapps\common\Dark Souls Prepare to Die Edition\deathCounter\deathCounter.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)
- */
- ;
- PgUp::
- ChangeNumber(1)
- Return
- ;
- PgDn::
- 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()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement