 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
BradleyS
Joined: 20 Sep 2005 Posts: 100
|
Posted: Sat Aug 16, 2008 9:49 am Post subject: DDL ini file entry |
|
|
Hi
I wonder if someone can help me resolve this issue I have with a DDL reading the information from an ini file.
All the other fields (edit, checkbox) read from the ini file OK.
I just can't figure out why the DDL doesn't work the same way.
Working code shown below:
| Code: | #NoEnv
#SingleInstance force
IfNotExist C:\MyFiles
FileCreateDir, C:\MyFiles
SetWorkingDir, C:\MyFiles
IniRead, FirstNum, MySettings.ini, 1stNum, FirstNum, %A_space%
Gui, Add, Edit, x12 y18 w135 h20 vFirstNum, %FirstNum%
IniRead, SecondNum, MySettings.ini, 2ndNum, SecondNum, %A_space%
Gui, Add, Edit, x12 y38 w135 h20 vSecondNum, %SecondNum%
IniRead, MyItems, MySettings.ini, DDL, MyItems, 0
Gui, Add, DDL, vMyItems Choose%MyItems%, Item 1|Item 2|Item 3
IniRead, MyBox, MySettings.ini, Tickbox, MyBox, 0
Gui, Add, Checkbox, gMyBox vMyBox Checked%MyBox%
Gui, Add, Button, w50 h20 gOK, OK
Gui, Show
MyBox:
GuiControlGet, MyBox, , MyBox
If MyBox=1
{
Gui, Submit, NoHide
GuiControl, Enable%MyBox%, MyItems
return
}
If MyBox=0
{
GuiControl, Enable%MyBox%, MyItems
return
}
return
!b::
OK:
Gui, Submit ; Save the input from the user to each control's associated variable.
Iniwrite, %FirstNum%, MySettings.ini, 1stNum, FirstNum
Iniwrite, %SecondNum%, MySettings.ini, 2ndNum, SecondNum
Iniwrite, %MyItems%, MySettings.ini, DDL, MyItems
Iniwrite, %MyBox%, MySettings.ini, Tickbox, MyBox
ExitApp |
|
|
| Back to top |
|
 |
svi
Joined: 09 Oct 2006 Posts: 126 Location: Finland
|
Posted: Sat Aug 16, 2008 12:26 pm Post subject: |
|
|
| The Manual wrote: | | Alternatively, include in Options the word Choose followed immediately by the number to pre-select. |
So, you have to extract the number by using eg. StringSplit:
| Code: | IniRead, MyItems, MySettings.ini, DDL, MyItems, 0
StringSplit, number, MyItems, %A_Space%
Gui, Add, DDL, vMyItems Choose%number2%, Item 1|Item 2|Item 3 |
For other readers: DDL means DropDownList
Edit: Added morer color +:
If you were going to change item texts to have no numbers, then the simpliest way could be using arrays, but if the text contains a space, then it'll be more complicated (but not difficult).
Edit2:
I thougth there could be another way, and found option AltSubmit, which makes it posiible to use arrays also when the item texts contain spaces. _________________ Pekka Vartto |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|