Page 1 of 2

IniRead, IniWrite help please

Posted: 08 Feb 2023, 17:22
by kn4yz
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.]

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 03:15
by Rohwedder
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}

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 04:47
by kn4yz
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?

Re: IniRead, IniWrite help please  Topic is solved

Posted: 09 Feb 2023, 04:58
by Rohwedder
For me, the script works exactly as desired.
Do you have the IniRead line in the automatic execution area?

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 05:01
by kn4yz
I have everything in the code as you wrote above

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 06:18
by kn4yz
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.

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 06:27
by boiler
Did it create the .ini file? What does it show?

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 06:31
by kn4yz
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.

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 06:45
by boiler
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?

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 07:00
by kn4yz
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.

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 07:42
by boiler
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.

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 07:53
by kn4yz
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

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 08:18
by kn4yz
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.

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 08:30
by kn4yz
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

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 12:14
by boiler
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.

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 12:17
by kn4yz
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

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 12:21
by boiler
Show your script and the contents of the .ini file.

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 12:28
by kn4yz

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.]

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 12:39
by boiler
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.

Re: IniRead, IniWrite help please

Posted: 09 Feb 2023, 12:45
by kn4yz
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.