IniWrite blank space before Key =

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ss2012
Posts: 4
Joined: 16 Oct 2021, 18:04

IniWrite blank space before Key =

16 Oct 2021, 18:20

Trying to get a blank space before the Key = as well as after in a .cfg file. Trying to get it while its changing the Value, not after like here, rather not use RegEx.

Code: Select all

if FileExist(AppDir "\App.exe") {
	IniWrite, %A_Space%"%NewValue1%", %AppDir%\App.cfg, Global, value1
	IniWrite, %A_Space%"%NewValue2%", %AppDir%\App.cfg, Global, value2
}
It writes the following to the bottom of the .cfg file.

Code: Select all

[Global]
value1= "3"
value2= "2"
It should find the Key and replace the Value in the .cfg file, no need to create the Section as well.

Code: Select all

value1 = "3"
value2 = "2"
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: IniWrite blank space before Key =

17 Oct 2021, 05:21

That's not how INI files work. They write and read their own format, which does not require spaces. They handle the formatting. You just need to specify the section, key, and value. If you are using a different approach to reading the file, then you can just use a plain text file instead.

Or:

Code: Select all

IniWrite,
(
a = "1"
b = "2"
), %A_ScriptDir%\test.ini, Global

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, RandomBoy and 413 guests