Page 1 of 1

{help}insert 0001 to 9999 with a hotkey

Posted: 06 Jan 2018, 11:15
by nightguerreiro
Hi there, never used AHK before,i've looked in the forum to see if i could find the solution for my problem but couldnt find it, so what im looking is:
lets say my hotkey is F3
i need a script that every time a press F3 it types for me the number from 0001 to 9999
so lets say i press F3 it would type 0001 then i press it again and it would type 0002
and so go on, also if i could selection from where it would start, let say i used the key to go till 2000 the i turn off my pc and go to sleep, next day i wanna start from 2000 so i dont have to start from 0001 again, i know i would have to edit the script but as long it has a place where i can edit the number.

I hope i made it as cleary as possible, would be awesome if someone could help with it, thanks a heaps!!

Re: {help}insert 0001 to 9999 with a hotkey  Topic is solved

Posted: 06 Jan 2018, 11:35
by noname

Code: Select all

F3::
IniRead, n, %A_ScriptDir%\number.ini, Section, counter, 0000
n++
m_new:=format("{1:04}",n)
send %m_new%
IniWrite,%m_new%, %A_ScriptDir%\number.ini, Section, counter
return

Re: {help}insert 0001 to 9999 with a hotkey

Posted: 06 Jan 2018, 11:51
by GreatGazoo

Re: {help}insert 0001 to 9999 with a hotkey

Posted: 06 Jan 2018, 16:06
by garry
@noname , thank you works fine
changed a little , so not each time write to ini

Code: Select all

#warn
IniRead, n, %A_ScriptDir%\number.ini, Section, counter, 0000

F3::
n++
m_new:=format("{1:04}",n)
msgbox, 262208, , %m_new%,1
return

esc::
IniWrite,%m_new%, %A_ScriptDir%\number.ini, Section, counter
msgbox, 262208, ,Script now close and save number,2
exitapp

Re: {help}insert 0001 to 9999 with a hotkey

Posted: 06 Jan 2018, 16:16
by BoBo
garry wrote:@noname , thank you works fine
changed a little , so not each time write to ini

Code: Select all

#warn
IniRead, n, %A_ScriptDir%\number.ini, Section, counter, 0000

F3::
n++
m_new:=format("{1:04}",n)
msgbox, 262208, , %m_new%,1
return

esc::
IniWrite,%m_new%, %A_ScriptDir%\number.ini, Section, counter
msgbox, 262208, ,Script now close and save number,2
exitapp
OnExit :?:

Re: {help}insert 0001 to 9999 with a hotkey

Posted: 06 Jan 2018, 16:27
by garry
@BoBo , you mean when close the script in tray menu
it's better then use ESC button by mistake

Code: Select all

#warn
#Persistent
OnExit, ExitSub
IniRead, n, %A_ScriptDir%\number.ini, Section, counter, 0000
return

F3::
n++
m_new:=format("{1:04}",n)
msgbox, 262208, , %m_new%,1
return

exitsub:
IniWrite,%m_new%, %A_ScriptDir%\number.ini, Section, counter
msgbox, 262208, ,Script now close and save number,2
exitapp

/*
esc::
IniWrite,%m_new%, %A_ScriptDir%\number.ini, Section, counter
msgbox, 262208, ,Script now close and save number,2
exitapp
*/

Re: {help}insert 0001 to 9999 with a hotkey

Posted: 06 Jan 2018, 17:26
by nightguerreiro
noname wrote:

Code: Select all

F3::
IniRead, n, %A_ScriptDir%\number.ini, Section, counter, 0000
n++
m_new:=format("{1:04}",n)
send %m_new%
IniWrite,%m_new%, %A_ScriptDir%\number.ini, Section, counter
return
Worked like a charm, thanks you so much! i had some problems to select where the number could start in case i wanna go to a specific number, but then i just noticed i just needed to edit the number.ini file.
thanks once again

and thanks everyone else in this post for trying to help, you guys are awesome!!