0.1.0 • Published 5 months ago

rd-config-ahk v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

INI file access for Autohotkey V1.1

Potential Breaking Change from v0.2.0+

If you used the following class variables in your code

rd_WinIniFile.BOOLEAN_TRUE
rd_WinIniFile.NOT_FOUND
rd_ConfigWithDefaults.BOOLEAN_TRUE
rd_ConfigWithDefaults.NOT_FOUND

they should be updated to

rd_ConfigUtils.BOOLEAN_TRUE
rd_ConfigUtils.NOT_FOUND

Installation

In a terminal or command line, navigate to your project folder:

npm install rd-config-ahk

In your code include the following to access those classes:

#Include, %A_ScriptDir%\node_modules\rd-regexp-ahk\rd_RegExp.ahk
#Include, %A_ScriptDir%\node_modules\rd_ConfigUtils.ahk
#Include, %A_ScriptDir%\node_modules\rd-config-ahk\rd_WinIniFile.ahk
; and additionally if needed
#Include, %A_ScriptDir%\node_modules\rd-config-ahk\rd_ConfigWithDefaults.ahk
#Include, %A_ScriptDir%\node_modules\rd_WinIniFileC.ahk
#Include, %A_ScriptDir%\node_modules\rd_ConfigWithDefaultsC.ahk

Description

These are classes to manage Windows INI files in Autohotkey.

All methods have function comments and if you're looking for examples check out the tests.

If you use the VS Code AutoHotkey Plus Plus extension, you might also want to check out Peak Definition (Alt+F12) or Go To Definition (F12).

These classes will throw an exception in case of a serious error by default which works well in combination with a global error handler. This behavior can be changed by setting class.throwExceptions := false.

Classes for INI File Access

Class rd_WinIniFile

A class to read/write Windows INI files

MethodDescription
writeStringWrites string to INI file
writeSectionWrites complete section to INI file, an existing section will be overwritten
writeArrayWrites an array of values with identical keys to an INI file
getStringGet value from INI file
getBooleanGet boolean value from INI file
getSectionRetrieve complete section from INI file as an array of key=value pairs
getSectionExRetrieve complete section from INI file as an object
getArrayRead all values of a section for identical keys into an array
getSectionNamesRead all section names of INI file into an array

Class rd_ConfigWithDefaults

A class to manage app settings stored in default and user INI files, where the user INI file can override the default INI file.

MethodDescription
getStringGet value from INI file
getBooleanGet boolean value from INI file
getArrayGet all values of a section for identical keys from INI file
getMergedSectionMerge INI section of user, default, returns contents as object

Classes for INI File Access with Customized Settings

The rd_WinIniFileC and rd_ConfigWithDefaultsC classes provide support for customized settings per INI section on a window/app basis, basically on any condition possible with a Autohotkey WinTitle string.

[customized-apps]
app1=ahk_exe app1.exe

[line-down]
keys={Left}{Up}
; ...

; merges custom setting with global setting
[line-down.custom.app1]
keys={Left 2}{Up}
; ...

Class rd_WinIniFileC (extends rd_WinIniFile)

Class to read/write Windows INI files with customized settings.

MethodDescription
writeStringWrites string to INI file
writeStringCWrites customized string setting to INI file
writeArrayCWrites a customized array of values with identical keys to an INI file
getCustomizedStringCGet customized setting string
getStringCGet standard or customized setting string
getCustomizedArrayCGet customized setting array
getArrayCGet standard or customized setting array
getBooleanCGets custom/standard boolean value from ini-file
getCustomizedSectionCGets customized section
getMergedSectionCMerges standard section with section defined for customized app

Class rd_ConfigWithDefaultsC (extends rd_ConfigWithDefaults)

A class to manage app settings stored in default and user INI files, including customized settings, both in default/user, where the user INI can override the default INI.

Configuration chain of settings, by priority

  1. User, customized settings
  2. Default, customized settings
  3. User
  4. Default
MethodDescription
getStringCGet string value from INI files, including customized settings
getBooleanCGet boolean value including customized settings
getArrayCGet array value from INI files, including customized settings
getMergedSectionCMerge INI section of user, default, custom settings
0.3.0

5 months ago

0.4.0

5 months ago

0.2.0

6 months ago

0.1.0

2 years ago