 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
macaddress
Joined: 29 Apr 2008 Posts: 18
|
Posted: Sun May 11, 2008 3:00 pm Post subject: Help required with DDL [Solved] |
|
|
Hi people!!
I´m gettin troubles with a simple script:
Here is the script:
| Code: |
;----------------product selection variables------------------
WISHLIST = DIGITAL_TV|CAR|COMPUTER
;----------------manufacturer selection variables-------------
DIGITAL_TV = |LG|SAMSUNG|PHILIPS
CAR = |FORD|FIAT|GM
COMPUTER = |HP|IBM|ASUS
;----------------tv screen size selection variables-----------
LG = |19|21|29
SAMSUNG = |14|15|19
PHILIPS = |29|32|40
;----------------car model selection variables----------------
FORD = |FUSION|KA|ECOSPORT
FIAT = |UNO|PUNTO|IDEA
GM = |ASTRA|MERIVA|VECTRA
;----------------computer model selection variables----------------
HP = |COMPAQ|PAVILION|PAVILION SLIMLINE
IBM = |LENOVO 3010|LENOVO 3020|LENOVO 4000
ASUS = |NOTEBOOK W2V|NOTEBOOK W2JC|NOTEBOOK W2P
;----------------GUI------------------------------------------
Gui, Add, ListBox, x26 y10 w200 h90 vproduct gUpdate1, ;PRODUCT SELECTION LISTBOX
Gui, Add, DropDownList, x26 y110 w200 vmanufacturer gUpdate2 Disabled, ;MANUFACTURER SELECTION DDM
Gui, Add, DropDownList, x26 y147 w200 vchoice3 Disabled, ;SCREEN SIZE SELECTION DDM
Gui, Add, Button, x26 y187 w100 h30 Disabled, Submit ;THIS BUTTON WILL BE USED LATER FOR OTHER FUNCTION (IS NOT THE SUBJECT OF THIS QUESTION)
Gui, Show
GuiControl, , product, %WISHLIST%
return
Update1:
Gui, Submit, NoHide
GuiControl,Enable , manufacturer
choicem := %product%
GuiControl, , manufacturer, %choicem%
return
Update2:
Gui, Submit, NoHide
GuiControl,Enable , choice3
choices := %manufacturer%
GuiControl, , choice3, %choices%
return
GuiEscape:
GuiClose:
ExitApp
|
The first time i proceed with the section till the last menu everything is just fine. But when i try to select the product on the listbox again (once the script is already launched) the containing var of the last DDM still showing with the last selection i did.
Is there a way to clean the variable on the last DDM when i select a new product on the listbox?
This is just a small part of an form filler application that im building.
Thanks in advance.
Last edited by macaddress on Mon May 12, 2008 11:10 pm; edited 1 time in total |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Sun May 11, 2008 3:05 pm Post subject: |
|
|
Your variables are global, simply empty them "afterwards"
| Code: | Update1:
Gui, Submit, NoHide
GuiControl,Enable , manufacturer
choicem := %product%
GuiControl, , manufacturer, %choicem%
choicem =
return
Update2:
Gui, Submit, NoHide
GuiControl,Enable , choice3
choices := %manufacturer%
GuiControl, , choice3, %choices%
choices =
return |
|
|
| Back to top |
|
 |
macaddress
Joined: 29 Apr 2008 Posts: 18
|
Posted: Sun May 11, 2008 3:36 pm Post subject: |
|
|
| Quote: |
Your variables are global, simply empty them "afterwards"
|
It did not work. Any other sugestions? |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Sun May 11, 2008 4:01 pm Post subject: |
|
|
| Quote: | | But when i try to select the product on the listbox again (once the script is already launched) the containing var of the last DDM still showing with the last selection i did. |
When you select the listbox, Update1 get's triggered, which only updates the first DDM, not the second (last) DDM (that does your Update2). |
|
| Back to top |
|
 |
macaddress
Joined: 29 Apr 2008 Posts: 18
|
Posted: Sun May 11, 2008 4:05 pm Post subject: |
|
|
| Quote: | | When you select the listbox, Update1 get's triggered, which only updates the first DDM, not the second (last) DDM (that does your Update2). |
You get to the point n-l-i-d. But is there a way to update both DDM without affect the script function? |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Sun May 11, 2008 4:17 pm Post subject: |
|
|
Take a look at LV_GetCount/LV_GetNext/LV_GetText. A_GuiEvent and the AltSubmit option might also be interesting.
ListView Documentation |
|
| Back to top |
|
 |
sinkfaze
Joined: 19 Mar 2008 Posts: 113
|
Posted: Sun May 11, 2008 5:32 pm Post subject: |
|
|
I've modified your GUI using AltSubmit commands, I think this will work better. I changed many of your variables around to improve my own readability so I apologize if it doesn't make sense. Feel free to ask me:
| Code: | ;----------------manufacturer selection variables-------------
BrandChoice1 = |LG|Samsung|Phillips
BrandChoice2 = |Ford|Fiat|GM
BrandChoice3 = |HP|IBM|ASUS
;----------------tv screen size selection variables-----------
TVChoice1 = |19`"|21`"|29`"
TVChoice2 = |14`"|15`"|19`"
TVChoice3 = |29`"|32`"|40`"
;----------------car model selection variables----------------
CarChoice1 = |Fusion|Ka|Ecosport
CarChoice2 = |Uno|Punto|Idea
CarChoice3 = |Astra|Meriva|Vectra
;----------------computer model selection variables----------------
ComputerChoice1 = |Compaq|Pavilion|Pavilion Slimline
ComputerChoice2 = |Lenovo 3010|Lenovo 3020|Lenovo 4000
ComputerChoice3 = |Notebook W2V|Notebook W2JC|Notebook W2P
;----------------GUI------------------------------------------
Gui, Add, Text, x21 y9 w200 h16, Please select an item from the Wish List:
Gui, Add, ListBox, x21 y25 w200 h90 vProduct gWishList AltSubmit, Digital TV|Car|Computer ; select product type
;
Gui, Add, Text, x21 y114 w200 h16, Select a manufacturer:
Gui, Add, DropDownList, x21 y130 w200 vManufacturer gManufacturer AltSubmit, ; select manufacturer
;
Gui, Add, Text, x21 y159 w200 h16, Select a model:
Gui, Add, DropDownList, x21 y175 w200 vMake , ; select model
;
Gui, Add, Button, x21 y207 w100 h30 Disabled, Submit
Gui, Show, w242 h255
return
WishList:
Gui, Submit, NoHide
Choice := BrandChoice%product% ; establishes the manufacturer dropdown
GuiControl, , manufacturer, %choice% ; puts that dropdown in place
GuiControl, , Make, | ; empties the model dropdown in case it contains data
return
Manufacturer:
Gui, Submit, NoHide
if Product = 1 ; will run if Digital TV was chosen
{
Model := TVChoice%Manufacturer%
GuiControl, , Make, %Model%
return
}
else if Product = 2 ; will run if Car was chosen
{
Model := CarChoice%Manufacturer%
GuiControl, , Make, %Model%
return
}
else if Product = 3 ; will run if Computer was chosen
{
Model := ComputerChoice%Manufacturer%
GuiControl, , Make, %Model%
return
}
GuiEscape:
GuiClose:
ExitApp |
I also removed the Disabled attributes, as it didn't make sense to me to have the fields disabled one time per run of the program. I made it so if the proper choices aren't made the dropdowns will be blank.
EDIT: Posted a cleaner version of the GUI. |
|
| Back to top |
|
 |
macaddress
Joined: 29 Apr 2008 Posts: 18
|
Posted: Sun May 11, 2008 7:43 pm Post subject: |
|
|
It works great!!!!
I was trying to avoid the if/than/else and gLabel stuff to keep the script simple, but sometimes you have to use them.
Sometimes people just post the quote : "refer to documentation on subject ...", but the samples on the ahk help are not much clear ( and not specific for what we want to do ) and you get lost easily.
Thank you so much sinkfaze. Thats exactly the kind of explanation i was looking for.
I thank you once more for the help.
Best regards. |
|
| Back to top |
|
 |
Troll Guest
|
Posted: Mon May 12, 2008 1:15 am Post subject: |
|
|
Edit your main post to have [Solved] in the title.
KThxBye |
|
| Back to top |
|
 |
macaddress
Joined: 29 Apr 2008 Posts: 18
|
Posted: Mon May 12, 2008 11:09 pm Post subject: |
|
|
As you command my Lord!!!!!!  |
|
| 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
|