Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Plug'n'Play GUI Settings Editor for your scripts (Version 6)


  • Please log in to reply
154 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
This function is now a joint effort by me and toralf

Background:
I made a script that was to be used by others. It saved its settings in a .ini file but to configure it I didn't create a GUI (why... coz its too much work, and one might as well use notepad to edit a damn ini file!). But i recd requests from friends that its too geeky to edit settings in notepad and they're having trouble so i should give them a better user interface! (damn!)

So instead of building a simple settings editor in that script I went the loooong waaaay... I made a function that can be just plugged into any script that saves its options in a .ini and you'll get an instant Settings Editor GUI !!

Ok, that was the background... (i know you didn't ask for it, but bear with me)


Back to Current Day:
toralf made wonderful improvements to the original function and took it to newer heights and added many features to it. Then i did some mods to it and then he modded my mod which was originally his mod which in turn was my original script. (blah.. blah)

Anyways, today we have a great working function that can easily be plugged into any script that saves its settings in a .ini file, and it has an instant Settings/Options window (screenshot below). And it doesn't use a single global variable (that was the tricky part for me!), so its completely compatible with any script.

Ini Editor:
Also, toralf made a very nice editor for .ini files (screenshot below), to be used specifically with the above function. Though any .ini can be directly used with the function without any modification, this editor enables you to avail some great features of the function.


Downloads:
(Usage instructions in the function file)
Ini Settings Editor Function Version 6
Ini File Creator Version 8 (requires Anchor 3.3)


Screenshots:

Ini Editor Function
Posted Image

Ini File Creator
Posted Image

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Kerry
  • Members
  • 144 posts
  • Last active: Sep 25 2006 07:33 PM
  • Joined: 20 Jul 2006
Wow, that's perfect, I was thinking I might have to do something like this myself, just started to use INI's pretty frequently, and trying to make my programs as simple as possible of the computer illiterate, and this will be perfect! haven't tested it yet but will very shortly!

Thank you,
Kerry

Kerry
  • Members
  • 144 posts
  • Last active: Sep 25 2006 07:33 PM
  • Joined: 20 Jul 2006
Hey, I got an error while trying to use:

Error: This variable or function name contains an illegal character. The Current Thread Will Exit

IDInstallation Options
ID%CurrSec% := TV_Add(CurrSec)

any suggestions?

EDIT:

The error is that it doesn't like sections with spaces between them, don't know how to fix this myself, nor if you want to go through the trouble to do so.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Thanks, that is a wonderful idea. I was creating the settings dialog for my GUIs always from scratch. This will make a lot of things easier. I'll take a look at the code later. Thanks for sharing.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Thalon
  • Members
  • 641 posts
  • Last active: Jan 02 2017 12:17 PM
  • Joined: 12 Jul 2005
Nice idea!
And yes, I love you ;D

I have only two possible improvement for reliability:

1)
You should use "Gui, Destroy" instead of "Gui, Submit".
The reason why should be clear after this lines of code:
EditSettings("Rajat", A_ScriptDir . "\test.ini")
msgbox
EditSettings("Rajat", A_ScriptDir . "\test.ini")
This causes a wonderfull new style for your GUI ;)

2)
You could replace
;a Gui that would probably not exist in parent script
	Gui, 54:Default
by something like this:
Loop, 86
	{
		Index := A_Index + 12		 ;overjumps the first few normally used GUI-Numbers...
		Gui %Index%:+LastFoundExist
		IfWinNotExist
		{
			Gui, %Index%:Default
			break
		}
	}
But this may also cause problems with later appearing Sub-Windows...

Thalon

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
Kerry,
spaces did occur to me while making this but i only thought about keys, and they probably don't support spaces so i thought no problem... but thanks for bringing this to my notice. i first thought of useing my Hex2Asc / Asc2Hex to fix spaces but now i've thought of a better approach that just might work... keep watching ths space! :)

Thalon,
hey that Gui Destory thing is really good, thanks for that! and about the other tip, it might (as u've already mentioned) mess with future GUIs in script so i guess i'll be sticking with Gui, 54! :)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
I created a mod. And over time it evolved.

See Rajat's first post for our joint work.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Added key types "file" and "folder", with functionality
Added key types "Float" and "Integer", with consistancy check

to the above script.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
wow toralf! you've greatly improved the function! (and made it too complicated for me to understand! ;) )

for supporting spaces i'd also thought of using IDs instead of names to make variable names. i've not yet seen what've u used to replace the 0.5s sleep.

by the way for future enhancements:
- i don't think editing desc/key/section is reqd, as i've not yet seen an app that allows to 'ADD' options to it, instead of modifying them.
- adding support for date and hotkey controls could be useful

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
by the way i've updated my function above to accept all chars including spaces too... though toralf has already beaten me to it! :)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005

wow toralf! you've greatly improved the function! (and made it too complicated for me to understand! ;) )

Common Rajat, you started this, I had to digest your code first. And it is as always excellent. You'll get it, I'm sure.

for supporting spaces i'd also thought of using IDs instead of names to make variable names. i've not yet seen what've u used to replace the 0.5s sleep.

It is only the order when the code breaks the loop if the GUI is closed. Your code left the loop before the sleep. By accident I closed the GUI during the sleep, the next lines tried to get the value which was nothing since the GUI was closed and wrote an empty value to the ini. No the loop is left after the sleep.

by the way for future enhancements:
- i don't think editing desc/key/section is reqd, as i've not yet seen an app that allows to 'ADD' options to it, instead of modifying them.
- adding support for date and hotkey controls could be useful

I agree. I was thinking to be able to build an ini with this during coding. But it will make the code much more complex. I guess the INI was to be written by hand or with a mod of Titans VisualIni script.

The date and hotkey key parameters are a good idea, but how to do a consitancy check? Maybe replace the Edit control with a date and hotkey control?!?
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
yeah the edit control can be hidden for these value types and the hotkey and calender controls can be un-hidden just like the Browse button.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Added key types "DateTime" and "Hotkey" with their own controls
in above script
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
man u're fast!

next request:
- a button, when pressed gives me 100 bucks

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
BtnRajat:

  MsgBox, Paypal wires you 100 Bucks

Return
Something like this?
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.