So, some of these new people (Or lazy coders, I'm not judging.) might want to use this.
So here it is!
The INI File Helper!
Here's the code. Make sure to keep the whole code for it to work!
Code: Select all
/*
/=========|
/ |
/ HH HH |
| HH HH |
| HHHHHHH |
| HH HH |
| HH HH |
| |
|===========|
AutoHotkey Version: 1.1.26.00
Language: English
Platform: Win XP, Win 7, Win 8.1, Win 10
Author: Delta
Contact information: octalblockmc@gmail.com
|=======================================================|
| Hotkeys: |
| None |
|=======================================================|
*/
#NoEnv
#SingleInstance Force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#NoTrayIcon
; #Include <Notify> ; Personal Library, unneeded here.
Process, Priority,, H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode, Input
Menu, Tray, Icon, %A_AHKPath%, 2
; Even though NoTrayIcon is set,
; it still sets the Gui's Icon to be the white file with the capital H
Gui, INI: -MinimizeBox
Gui, INI:Add, Tab3, x0 y0 w470 h330 +0x2, Write|Read
Gui, INI:Tab, Write, 1
Gui, INI:Font,, Segoe UI
Gui, INI:Add, GroupBox, x10 y15 w435 h50, The Text or Variable to Write [Be sure to add the `% signs acordingly!]
Gui, INI:Add, Edit, x20 y35 w415 h20 vOutA, `%Var`%
Gui, INI:Add, GroupBox, x10 y70 w435 h50, The File to Write in
Gui, INI:Add, Edit, x20 y90 w330 h20 vFileA, %A_Desktop%\Config.ini
Gui, INI:Add, Button, x360 y90 w75 h23 vFileSelectA gSelectA, Select File
Gui, INI:Add, GroupBox, x10 y125 w435 h50, The Category to Write in
Gui, INI:Add, Edit, x20 y145 w415 h20 vCatA, Settings
Gui, INI:Add, GroupBox, x10 y180 w435 h50, The Key to Write to
Gui, INI:Add, Edit, x20 y200 w415 h20 vKeyA, KeyA
Gui, INI:Add, Button, x375 y275 w70 h25 gUpdate, Update
Gui, INI:Font,, Consolas
Gui, INI:Add, Edit, x15 y250 w430 h20 vUPWrite ReadOnly
Gui, INI:Tab, Read, 1
Gui, INI:Font,, Segoe UI
Gui, INI:Add, GroupBox, x10 y15 w435 h50, The Text or Variable to Read [There's no need for the `% signs here.]
Gui, INI:Add, Edit, x20 y35 w415 h20 vOutB, Var
Gui, INI:Add, GroupBox, x10 y70 w435 h50, The File to Read From
Gui, INI:Add, Edit, x20 y90 w330 h20 vFileB, %A_Desktop%\Config.ini
Gui, INI:Add, Button, x360 y90 w75 h23 vFileSelectB gSelectB, Select File
Gui, INI:Add, GroupBox, x10 y125 w435 h50, The Category to Read From
Gui, INI:Add, DDL, x20 y145 w415 h200 vCatB, Settings||
Gui, INI:Add, GroupBox, x10 y180 w435 h50, The Key to Read From
Gui, INI:Add, Edit, x20 y200 w415 h20 vKeyB, KeyA
Gui, INI:Add, Button, x375 y275 w70 h25 gUpdate, Update
Gui, INI:Font,, Consolas
Gui, INI:Add, Edit, x15 y250 w430 h20 vUPRead ReadOnly
Gui, INI:Show, w465 h335, INI File Helper
GoSub, Update
Return
Update:
Gui, INI:Submit, NoHide
GuiControl INI:, UPWrite, % "IniWrite, " OutA ", " FileA ", " CatA ", " KeyA
GuiControl INI:, UPRead , % "IniRead, " OutB ", " FileB ", " CatB ", " KeyB
Return
SelectA:
FileSelectFile, FileA, 8, %A_Desktop%\, Please Create an INI File to Use., Configuration Files (*.ini)
GuiControl, INI:, FileA, % FileA
Return
SelectB:
FileSelectFile, FileB, 8, %A_Desktop%\, Please Create an INI File to Use., Configuration Files (*.ini)
SplitPath, % FileB,,, OutExtension
If (ErrorLevel or (OutExtension != "ini"))
Return
GuiControl, INI:,FileB, % FileB
IniRead, OutputVarSectionNames, % FileB ; retrieves a linefeed (`n) delimited list of section names
GuiControl, INI:,CatB, % "|" StrReplace(OutputVarSectionNames, "`n", "|") ; fill the drop down list with the section names of the selected ini file
GuiControl, INI:Choose, CatB, 1
Return
Close:
INIGuiClose:
ExitApp
Return