Page 1 of 1

Help making a file reset to 20.

Posted: 25 Feb 2019, 20:53
by intel339
Hello,
I cant figure out how to use auto key to open an existing file and change its value always to 20 and save.

WhatI i want is to use my numeric keypad's number 5 button to reset a text file's existing number of whatever to "20."

I have the following, but I cant figure out how to make the edit in the background, and save it so its reflected. I dont want it opened up. i just want it changed / or "reset" to 20 eveery time I hit the numpad5 button.
does this make sense?

NUMPAD5::
Send, 20
Run, edit "C:\Users\office339\Desktop\MTG files\testing counter Guest Side.txt"
return

unfortunatley when I hit the numpad5 key, it opens the text file, but dosent change anything without opening up a duplicate file.....

Re: Help making a file reset to 20.

Posted: 26 Feb 2019, 00:11
by hd0202

Code: Select all

NUMPAD%::
file := "C:\Users\office339\Desktop\MTG files\testing counter Guest Side.txt"
filedelete, % file
fileappend, 20, % file
return
But what do you mean: without opening up a duplicate file..... :?:
Hubert

Re: Help making a file reset to 20.

Posted: 26 Feb 2019, 23:00
by intel339
Awesome. It was opening up the file over and over before your help.
This works great now.

Is there a way using script to write a value inside a text file ?
For example, i want to have my text file start at 20 and then go down one number every time I hit the minus key? 19,18, 17 and so on...And conversly add 1 everytime i hit the plus Symbol , it would increase 1 number?
I want the file,to be saved everytime I increase or decrease the number.

Re: Help making a file reset to 20.

Posted: 26 Feb 2019, 23:47
by hd0202

Code: Select all

#persistent

number = 20
gosub, write_to_file
return

numpadadd::
number++
gosub, write_to_file
return

numpadsub::
number--
gosub, write_to_file
return

write_to_file:
file := "C:\Users\office339\Desktop\MTG files\testing counter Guest Side.txt"
filedelete, % file
fileappend, % number, % file
return
Hubert