 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
olaf
Joined: 20 Apr 2005 Posts: 25
|
Posted: Thu May 19, 2005 8:29 am Post subject: DropDownList from Ini |
|
|
I'm trying to use Choose in the ddl with an ini selection, and then grab the actual text from the ddl. It works, except, something has to be selected first.
When starting, either for the first time or after ini is created, the Text is not shown. How can the Text be shown without having to select it first?
| Code: |
#singleinstance force
Gosub, ReadIni
Gosub, Maingui
Return
Maingui:
Gui, 1:Add, DropDownList, vDdlVar gDdlGosub r7 Choose%SelectDdl% AltSubmit, this|that|thing|theother
Gui, 1:Add, Button, ys x+5 gButtonGo, Testddl
Gui, 1:Show, x170 y110 h204 w334, ddltest
Return
ButtonGo:
Gui, Submit, NoHide
msgbox, SelectDdl = %SelectDdl%`n`nDdlVar = %DdlVar%`n`nSelectDdlText = %SelectDdlText%
return
DdlGoSub:
Gui, Submit, NoHide
GuiControlGet, SelectDdl,, DdlVar
GuiControlGet, SelectDdlText,, DdlVar, Text
;msgbox, SelectDdl = %SelectDdl%`n`nDdlVar = %DdlVar%`n`nSelectDdlText = %SelectDdlText%
return
GuiClose:
GuiEscape:
Gui, Cancel
Gosub, WriteIni
ExitApp
return
ReadIni:
IniRead, SelectDdl, ddltest.ini, Section, SelectDdl, 3
return
WriteIni:
Gui, Submit
IniWrite, %SelectDdl%, ddltest.ini, Section, SelectDdl
return
|
olaf _________________ Berserker |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Thu May 19, 2005 8:44 am Post subject: |
|
|
insert this line into your button routine and it works | Code: | | GuiControlGet, SelectDdlText,, DdlVar, Text |
The submit doesn't give you the text, since you gave AltSubmit to the control and the gui stores the number in the control variable. How should the GUI know where to put the text? _________________ Ciao
toralf  |
|
| Back to top |
|
 |
olaf
Joined: 20 Apr 2005 Posts: 25
|
Posted: Thu May 19, 2005 9:33 am Post subject: |
|
|
| toralf wrote: | insert this line into your button routine and it works | Code: | | GuiControlGet, SelectDdlText,, DdlVar, Text |
The submit doesn't give you the text, since you gave AltSubmit to the control and the gui stores the number in the control variable. How should the GUI know where to put the text? |
thanks toralf, that helps. _________________ Berserker |
|
| Back to top |
|
 |
olaf
Joined: 20 Apr 2005 Posts: 25
|
Posted: Fri May 20, 2005 8:48 am Post subject: |
|
|
I should have posted this question first. This uses a slightly different setup.
I'm trying to get the ddl to work on the second gui. It works on the first.
I've tried but have not found the simple solution.
To see it not work, comment the two in the first gui and uncomment in the second.
| Code: |
ScriptName = ddltest
#singleinstance force
Gosub, ReadIni
Gosub, FirstGui
Gosub, SecondGui
Return
FirstGui:
Gui, 1:+MinimizeBox +Resize
Gui, 1:Add, Button, ys x+1 gButtonOptions, Options
Gui, 1:Add, Button, ys x+5 vButtonGo gButtonGo, Go
; these two
Gui, 1:Add, Checkbox, xs+10 ys+30 vTestCheck Checked%TestCheck%, Enable DDL
Gui, 1:Add, DDL, xs+10 ys+60 vDDLVar gDDLGoSub r7 Choose%SelectOption% AltSubmit, This|That|Thing|TheOther|Something
Gui, 1:Show,,%ScriptName%
return
ButtonGo:
Gui, 1:Submit, NoHide
GuiControlGet, SelectedDDL,, DDLVar, Text
Gosub, Opts
msgbox, %Exec%
return
GuiClose:
GuiEscape:
Gui, 2:Cancel
Gosub, WriteIni
ExitApp
return
ButtonOptions:
Gui, 2:Show,, SecondGui - %ScriptName%
return
SecondGui:
Gui, 2:+ToolWindow +Owner1
Gui, 2:Add, Tab, xm w200 r5 Section, Tabtest
Gui, 2:Tab, Tabtest
; Gui, 2:Add, Checkbox, xs+10 ys+30 vTestCheck Checked%TestCheck%, Enable DDL
; Gui, 2:Add, DDL, xs+10 ys+60 vDDLVar gDDLGoSub r7 Choose%SelectOption% AltSubmit, This|That|Thing|TheOther|Something
Gui, 2:Tab
Gui, 2:Add, Button, xm Section gButtonApply, &Apply
Gui, 2:Add, Button, ys gButtonCancel, &Cancel
return
Opts:
Exec = test.exe
If (TestCheck)
Exec = %Exec% %SelectedDDL%
return
DDLGoSub:
GuiControlGet, SelectOption,, DDLVar
return
ButtonApply:
Gui, 2:Submit
return
2GuiClose:
2GuiEscape:
ButtonCancel:
Gui, 2:Cancel
return
ReadIni:
IniRead, TestCheck, %ScriptName%.ini, TestSection, TestCheck, 0
IniRead, SelectOption, %ScriptName%.ini, TestSection, SelectOption, 4
return
WriteIni:
Gui, 1:Submit
IniWrite, %TestCheck%, %ScriptName%.ini, TestSection, TestCheck
IniWrite, %SelectOption%, %ScriptName%.ini, TestSection, SelectOption
return
|
olaf _________________ Berserker |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Fri May 20, 2005 1:27 pm Post subject: |
|
|
Hi Beserker,
Here is a code that works. It is a strong simplification of your code, but yours was to hard to get too to find the bug. | Code: | Gosub, FirstGui
Gosub, SecondGui
Return
FirstGui:
Gui, 1:Add, Button, gButtonShow, Show Second Gui
Gui, 1:Add, Button, vButtonGo gButtonGo, Show Selection from DDL
; this one
Gui, 1:Add, DDL, vDDLVar r7 AltSubmit, This|That|Thing|TheOther|Something
Gui, 1:Show,,First
return
ButtonGo:
Gui, 1:Submit, NoHide
GuiControlGet, SelectedDDL,, DDLVar, Text
MsgBox, Selected on Gui1: %SelectedDDL%`nSelected on Gui2: %SelectedDDL2%
return
ButtonShow:
Gui, 2:Show,, Second
return
SecondGui:
Gui, 2: +Owner1
Gui, 2:Add, Tab, xm w200 r5 Section, Tabtest
Gui, 2:Tab, Tabtest
;with this one
Gui, 2:Add, DDL, xs+10 ys+60 vDDLVar2 r7 AltSubmit, This|That|Thing|TheOther|Something
Gui, 2:Tab
Gui, 2:Add, Button, xm Section gButtonApply, &Apply
return
ButtonApply:
GuiControlGet, SelectedDDL2,, DDLVar2, Text
Gui, 2:Submit
return
2GuiClose:
GuiClose:
ExitApp |
The problem in your code is (I think, because I didn't double checked) the line | Code: | | GuiControlGet, SelectedDDL,, DDLVar, Text | in the ButtonGo routine. When you have the DDL in the second gui active, the gui is already closed, so that command will get nothing and put a empty sting into the SelecedDLL var. If you remove that line, everything should be fine, since you have the DDLGoSub routine, that does it for you. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Fri May 20, 2005 1:33 pm Post subject: |
|
|
I doublechecked, and I was half right and half wrong. the new routien, should look like | Code: | DDLGoSub:
GuiControlGet, SelectedDDL,, DDLVar, Text ;this line comes from the ButtonGo routine
GuiControlGet, SelectedOption,, DDLVar
return |
and (as I said before) comment out the line in the buttonGo routine. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
olaf
Joined: 20 Apr 2005 Posts: 25
|
Posted: Sat May 21, 2005 2:38 am Post subject: |
|
|
Toralf, your help is Greatly appreciated.
It's still not quite working yet, though.
Here is more simplified code from the first post.
Basically the script needs to get the DDL Text as soon as the script is
launched, without having to select it first.
The bug right now, is you have to make a selection before the var is known.
Everthing else is working. The ini is read, stored, retrieved and the selection is preselected when viewing the options.
And of course, the main thing is that the DDL must be in the second gui.
| Code: |
ScriptName = ddltest
#singleinstance force
Gosub, ReadIni
Gosub, FirstGui
Gosub, SecondGui
Return
FirstGui:
Gui, 1:+MinimizeBox +Resize
Gui, 1:Add, Button, ys x+1 gButtonOptions, Options
Gui, 1:Add, Button, ys x+5 vButtonGo gButtonGo, Go
Gui, 1:Show,,%ScriptName%
return
ButtonGo:
Gui, 1:Submit, NoHide
Gosub, Opts
msgbox, %Exec%
return
ButtonOptions:
Gui, 2:Show,, SecondGui - %ScriptName%
return
SecondGui:
Gui, 2:+ToolWindow +Owner1
Gui, 2:Add, Tab, xm w200 r5 Section, Tabtest
Gui, 2:Tab, Tabtest
Gui, 2:Add, Checkbox, xs+10 ys+30 vTestCheck Checked%TestCheck%, Enable DDL
Gui, 2:Add, DDL, xs+10 ys+60 vDDLVar gDDLGoSub r7 Choose%SelectOption% AltSubmit, This|That|Thing|TheOther|Something
Gui, 2:Tab
Gui, 2:Add, Button, xm Section gButtonApply, &Apply
Gui, 2:Add, Button, ys gButtonCancel, &Cancel
return
Opts:
Exec = List
If (TestCheck)
Exec = %Exec% %SelectedDDL%
return
DDLGoSub:
GuiControlGet, SelectedDDL,, DDLVar, Text
GuiControlGet, SelectOption,, DDLVar
return
ButtonApply:
Gui, 2:Submit
return
2GuiClose:
2GuiEscape:
ButtonCancel:
Gui, 2:Cancel
return
GuiClose:
GuiEscape:
Gui, 2:Cancel
Gosub, WriteIni
ExitApp
return
ReadIni:
IniRead, TestCheck, %ScriptName%.ini, TestSection, TestCheck, 0
IniRead, SelectOption, %ScriptName%.ini, TestSection, SelectOption, 4
return
WriteIni:
Gui, 1:Submit
IniWrite, %TestCheck%, %ScriptName%.ini, TestSection, TestCheck
IniWrite, %SelectOption%, %ScriptName%.ini, TestSection, SelectOption
return
|
olaf _________________ Berserker |
|
| Back to top |
|
 |
toralf as guest Guest
|
Posted: Sat May 21, 2005 11:32 am Post subject: |
|
|
Add aat the end of the auto-exec section.
That should solve it. |
|
| 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
|