*.ini file <=> *.ahk Topic is solved

Ask gaming related questions (AHK v1.1 and older)
WhoIsALI
Posts: 11
Joined: 25 Feb 2020, 10:36

*.ini file <=> *.ahk

11 Mar 2020, 11:34

Hi you all, i'm trying to create an app, with multiple input boxes,
here is a simple example with 3 different inputs, 1, 2 and 3.
and what i'm trying to do is, save last entered values in *.ini file, so when opening the programme next time, it load and show the last entered values. :crazy:
please help. :thumbup:

Code: Select all

SetWorkingDir %A_ScriptDir%
iniFile = Temp.ini
Gui, Add, Text, x12 y9 w360 h40, > AutoHotKey Forum < try to save the tree values, and show the after app`nreload.
Gui, Add, GroupBox, x22 y49 w350 h80, Inputs
Gui, Add, Edit, x32 y69 w100 h20 Number,
Gui, Add, Text, x32 y99 w100 h20 vInput1, Input 1
Gui, Add, Edit, x152 y69 w100 h20 Number vInput2,
Gui, Add, Text, x152 y99 w100 h20, Input 2
Gui, Add, DropDownList, x262 y69 w100 h60 vInput3 Choose2, Yes|No
Gui, Add, Text, x262 y99 w100 h20, Input 3
Gui, Add, Button, x250 y129 w100 h20 gReload, Reload
Gui, Add, Button, x32 y129 w100 h20 gSave, Save
Gui +AlwaysOnTop
Gui, Show, xCenter yCenter, Save Value
Return

GuiClose:
    {
     ExitApp
    }
  return

Reload:
    {
     Reload
    }
  return

Save:
    {
     GuiControlGet, Input1
     GuiControlGet, Input2
	 GuiControlGet, Input3
     IniWrite, %Input1%, %iniFile%, Section, Key
     IniWrite, %Input2%, %iniFile%, Section, Key
     IniWrite, %Input3%, %iniFile%, Section, Key

     IniRead, ReadReporting, %iniFile%, Section, Key
     IniRead, ReadXmax, %iniFile%, Xmax, Section, Key
     IniRead, ReadXmin, %iniFile%, Xmin, Section, Key

     GuiControl, Text, ControlID , Value
     GuiControl, Text, ControlID , Value
     GuiControl, Text, ControlID , Value
    }
i looked online, again there isn't much information/examples about it.
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: *.ini file <=> *.ahk  Topic is solved

11 Mar 2020, 15:13

Here is a working example:

Code: Select all

#SingleInstance, Force
SetWorkingDir %A_ScriptDir%
iniFile = Temp.ini

IniRead, V_Input1, %iniFile%, Section, Input1
IniRead, V_Input2, %iniFile%, Section, Input2
IniRead, V_Input3, %iniFile%, Section, Input3, No

Gui, Add, Text, x12 y9 w360 h40, > AutoHotKey Forum < try to save the tree values, and show the after app`nreload.
Gui, Add, GroupBox, x22 y49 w350 h80, Inputs
Gui, Add, Edit, x32 y69 w100 h20 Number vInput1, %V_Input1%
Gui, Add, Text, x32 y99 w100 h20, Input 1
Gui, Add, Edit, x152 y69 w100 h20 Number vInput2, %V_Input2%
Gui, Add, Text, x152 y99 w100 h20, Input 2
Gui, Add, DropDownList, x262 y69 w100 h60 vInput3 Choose2, Yes|No
GuiControl, Choose, Input3, %V_Input3%
Gui, Add, Text, x262 y99 w100 h20, Input 3
Gui, Add, Button, x250 y129 w100 h20 gReload, Reload
Gui, Add, Button, x32 y129 w100 h20 gSave, Save
Gui +AlwaysOnTop
Gui, Add, StatusBar,,

Gui, Show, xCenter yCenter, Save Value
Return

GuiClose:
{
     ExitApp
}

Reload:
{
	IniRead, V_Input1, %iniFile%, Section, Input1
	IniRead, V_Input2, %iniFile%, Section, Input2
	IniRead, V_Input3, %iniFile%, Section, Input3, No
	
	GuiControl, , Input1, %V_Input1%
	GuiControl, , Input2, %V_Input2%
	GuiControl, Choose , Input3, %V_Input3%
	SB_SetText("Inputs reloaded.")
	return
}


Save:
{
	GuiControlGet, Input1
	GuiControlGet, Input2
	GuiControlGet, Input3
	IniWrite, %Input1%, %iniFile%, Section, Input1
	IniWrite, %Input2%, %iniFile%, Section, Input2
	IniWrite, %Input3%, %iniFile%, Section, Input3
	
	SB_SetText("Inputs saved.")
	return
}
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: *.ini file <=> *.ahk

11 Mar 2020, 15:15

_
WhoIsALI
Posts: 11
Joined: 25 Feb 2020, 10:36

Re: *.ini file <=> *.ahk

12 Mar 2020, 03:36

@AHK_user super, worked,
PS: this is the only good working example on internet.
when i tried it on my official gui it showed the entered value + point comma eg : (12;1)
what do you think coused that, (x;1).
Screenshot attached.

the ; problem only in my gui, the one you made worked 100% correct.
Attachments
2020-03-12 09_28_55-eed.png
screenshot
2020-03-12 09_28_55-eed.png (3.5 KiB) Viewed 903 times
WhoIsALI
Posts: 11
Joined: 25 Feb 2020, 10:36

Re: *.ini file <=> *.ahk

12 Mar 2020, 03:59

i fixed it, thank you.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 30 guests