IniRead, IniWrite help please Topic is solved

Ask gaming related questions (AHK v1.1 and older)
kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

IniRead, IniWrite help please

Post by kn4yz » 08 Feb 2023, 17:22

Greetings, I need help with the implementation of the possibility through the IniRead, IniWrite tags. I would like to make it possible for users to enter the message they need through IniWrite, and then a message from setting.ini is displayed in one of the text lines

Code: Select all

:*?:/admtag::
SendInput, /admtag{space}
Input, InputAtag, V, {enter}
IniWrite, %InputAtag%, settings.ini, settings, admintag
msgbox, %InputAtag%
return

IniRead, %InputAtag%, settings.ini, settings, admintag

-------------------------------------------------------------------------------------------------------------------------------------------

:*?:dm1::/jail{Space} 60-120 DM | %admintag from setting.ini% {Left 23}

[Mod edit: Changed inline code (c) tags to [code][/code] tags. Please use them yourself when posting code.]

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: IniRead, IniWrite help please

Post by Rohwedder » 09 Feb 2023, 03:15

Hallo,
perhaps?:

Code: Select all

IniRead, InputAtag, settings.ini, settings, admintag

:*?B0:/admtag::
SendInput, {space}
Input, InputAtag, V, {enter}
IniWrite, %InputAtag%, settings.ini, settings, admintag
msgbox, %InputAtag%
return

-------------------------------------------------------------------------------------------------------------------------------------------

:*?x:dm1::Send, /jail{Space} 60-120 DM |%InputAtag%{Left 23}

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 04:47

Rohwedder wrote:
09 Feb 2023, 03:15
Hallo,
perhaps?:

Code: Select all

IniRead, InputAtag, settings.ini, settings, admintag

:*?B0:/admtag::
SendInput, {space}
Input, InputAtag, V, {enter}
IniWrite, %InputAtag%, settings.ini, settings, admintag
msgbox, %InputAtag%
return

-------------------------------------------------------------------------------------------------------------------------------------------

:*?x:dm1::Send, /jail{Space} 60-120 DM |%InputAtag%{Left 23}
Thanks, but using your code I have to set the value through the /admtag command with each reboot of the script, is there any way to make sure that the value is preserved and I do not have to re-enter it?

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: IniRead, IniWrite help please  Topic is solved

Post by Rohwedder » 09 Feb 2023, 04:58

For me, the script works exactly as desired.
Do you have the IniRead line in the automatic execution area?

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 05:01

I have everything in the code as you wrote above

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 06:18

kn4yz wrote:
09 Feb 2023, 05:01
I have everything in the code as you wrote above
But why doesn't it work that way.

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: IniRead, IniWrite help please

Post by boiler » 09 Feb 2023, 06:27

Did it create the .ini file? What does it show?

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 06:31

boiler wrote:
09 Feb 2023, 06:27
Did it create the .ini file? What does it show?
It creates a .ini file, and iniread reads it, but after rebooting, you have to write the /admtag command again so that the function argument appears in the .ini file.

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: IniRead, IniWrite help please

Post by boiler » 09 Feb 2023, 06:45

I don’t understand what you’re saying. You said it’s in the .ini file and the script reads it. What does rebooting have to do with anything? The .ini file is still there and it reads from it again after rebooting, right?

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 07:00

boiler wrote:
09 Feb 2023, 06:45
I don’t understand what you’re saying. You said it’s in the .ini file and the script reads it. What does rebooting have to do with anything? The .ini file is still there and it reads from it again after rebooting, right?
After rebooting the ahk file, the ini file seems to be deleted, I can't properly explain what I mean. The file seems to be deleted.

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: IniRead, IniWrite help please

Post by boiler » 09 Feb 2023, 07:42

Well, that would be the problem then. That’s not an AHK issue. In what folder is your script and the .ini file located on your drive? It’s best to locate them in a folder where Windows intends as your space, like in Documents.

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 07:53

boiler wrote:
09 Feb 2023, 07:42
Well, that would be the problem then. That’s not an AHK issue. In what folder is your script and the .ini file located on your drive? It’s best to locate them in a folder where Windows intends as your space, like in Documents.
Now I'll try, and I'll write

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 08:18

boiler wrote:
09 Feb 2023, 07:42
Well, that would be the problem then. That’s not an AHK issue. In what folder is your script and the .ini file located on your drive? It’s best to locate them in a folder where Windows intends as your space, like in Documents.
Can you please tell me how to make it save to documents? Or it doesn't work.

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 08:30

boiler wrote:
09 Feb 2023, 07:42
Well, that would be the problem then. That’s not an AHK issue. In what folder is your script and the .ini file located on your drive? It’s best to locate them in a folder where Windows intends as your space, like in Documents.
Now the .ini file is saved to documents, but after reloading the script, it does not display the value written through the /admtag command

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: IniRead, IniWrite help please

Post by boiler » 09 Feb 2023, 12:14

Both files -- the script and the .ini file -- need to be in the same directory unless you specify the path to the .ini file in your script.

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 12:17

boiler wrote:
09 Feb 2023, 12:14
Both files -- the script and the .ini file -- need to be in the same directory unless you specify the path to the .ini file in your script.
The path to the file is specified

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: IniRead, IniWrite help please

Post by boiler » 09 Feb 2023, 12:21

Show your script and the contents of the .ini file.

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 12:28

Code: Select all

:*?B0:/admtag::
SendInput, {space}
Input, InputAtag, V, {enter}
FileCreateDir, %A_MyDocuments%\NHelper
IniWrite, %InputAtag%, %A_MyDocuments%\NHelper\settings.ini, settings, admintag
msgbox, %InputAtag%
return

IniRead, InputAtag, %A_MyDocuments%\NHelper\settings.ini, settings, admintag
contents of the .ini file

Code: Select all

[settings]
admintag=fd
but for some reason, if you run the script when there is a value in the .ini file, it is simply not written until you write the /admtag command again


[Mod edit: Added [code][/code] tags and .ini codebox tags. Please use them yourself when posting code.]

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: IniRead, IniWrite help please

Post by boiler » 09 Feb 2023, 12:39

kn4yz wrote:
09 Feb 2023, 05:01
I have everything in the code as you wrote above
No, you did not. See if you can spot the difference. It wastes the time of those helping when you say the script is the same but you made changes that you think are not important but make all the difference.

kn4yz
Posts: 16
Joined: 08 Feb 2023, 17:19

Re: IniRead, IniWrite help please

Post by kn4yz » 09 Feb 2023, 12:45

boiler wrote:
09 Feb 2023, 12:39
kn4yz wrote:
09 Feb 2023, 05:01
I have everything in the code as you wrote above
No, you did not. See if you can spot the difference. It wastes the time of those helping when you say the script is the same but you made changes that you think are not important but make all the difference.
Oh, okay. I'll check nowI'll check it out now.

Post Reply

Return to “Gaming Help (v1)”