Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ;----------------------------------------------------------------------------
- ;Enter your TXT file path and prefix
- filePath = W:\Speedgames\Dragon Warrior 2\deaths.txt
- prefix := "COD Counter "
- StringLen, prefixLen, prefix
- FileReadLine, fileRead, %filePath%, 1
- StringTrimLeft, deathVar, fileRead, %prefixLen%
- ;Creates txt file if it doesn't exist.
- IfNotExist, %filePath%
- FileAppend, %prefix% 0, %filePath%
- ;When you press [Hotkey] it will increment and update the counter in the file
- NumpadMult::
- ;Reads counter from the file into the deathVar variable
- FileReadLine, fileRead, %filePath%, 1
- StringTrimLeft, deathVar, fileRead, %prefixLen%
- ;Increments and writes to file
- Var := ++deathVar
- FileDelete, %filePath%
- FileAppend, %prefix% %deathVar%, %filePath%
- return
- ;When you press [Hotkey] it will decrement and update the counter in the file
- NumpadDiv::
- ;Reads counter from the file into the deathVar variable
- FileReadLine, fileRead, %filePath%, 1
- StringTrimLeft, deathVar, fileRead, %prefixLen%
- ;Don't decrement if it is 0
- if deathVar = 0
- return
- ;Decrements and writes to file
- Var := --deathVar
- FileDelete, %filePath%
- FileAppend, %prefix% %deathVar%, %filePath%
- return
- ;Reset back to 0 when you press [Hotkey]
- NumpadAdd::
- ;writes to file
- deathVar := 0
- FileDelete, %filePath%
- FileAppend, %prefix% %deathVar%, %filePath%
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement