Help making a file reset to 20.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
intel339
Posts: 5
Joined: 25 Feb 2019, 20:46

Help making a file reset to 20.

25 Feb 2019, 20:53

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.....
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Help making a file reset to 20.

26 Feb 2019, 00:11

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
intel339
Posts: 5
Joined: 25 Feb 2019, 20:46

Re: Help making a file reset to 20.

26 Feb 2019, 23:00

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.
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Help making a file reset to 20.

26 Feb 2019, 23:47

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, RandomBoy and 403 guests