AutoHotkey Community

It is currently May 26th, 2012, 10:10 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: DropDownList from Ini
PostPosted: May 19th, 2005, 9:29 am 
Offline

Joined: April 20th, 2005, 8:44 am
Posts: 25
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2005, 9:44 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2005, 10:33 am 
Offline

Joined: April 20th, 2005, 8:44 am
Posts: 25
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2005, 9:48 am 
Offline

Joined: April 20th, 2005, 8:44 am
Posts: 25
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2005, 2:27 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2005, 2:33 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2005, 3:38 am 
Offline

Joined: April 20th, 2005, 8:44 am
Posts: 25
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2005, 12:32 pm 
Add a
Code:
GoSub, DDLGoSub
at the end of the auto-exec section.
That should solve it.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: [VxE], iBob35555VR, krajan and 74 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group