Jump to content

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

[SOLVED] Clear DropDownList Selection - Choose/ChooseString


  • Please log in to reply
17 replies to this topic
Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007
Ok this should be an easy one


When first looking at a DropDownList the selection is empty
So I select an entry using the following:
GuiControl, 1:ChooseString, DropDownListID, % "DDL Entry 1"
Now the entry with the name "DDL Entry 1" is selected


But how do I clear the DropDownList selection, back to empty like it was when the script first started?
I tried:
GuiControl, 1:Choose, DropDownListID, 0
And:
GuiControl, 1:ChooseString, DropDownListID, % ""
But neither work



SOLUTION:
Setup the DropDownList with a hwnd as follows:
Gui, Add, DropDownList, hwndDDL_ID, Item1|Item2|Item3
Then to clear it use:
SendMessage, 0x014E, -1, 0,, ahk_id %DDL_ID%


trik
  • Members
  • 1317 posts
  • Last active: Jun 11 2010 11:48 PM
  • Joined: 15 Jul 2007
isn't it something like

GuiControl,, DropDownListID, |

Try that.
Religion is false. >_>

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007
Are you sure that doesnt just clear the list?
Rather than keep the list but select nothing on it?

Anyway I'll report back

Edit:
Unfortinately I was right
It didnt select anything
But that was because there wasnt anything to select
It cleared the list rather than selecting nothing

But this could be a possible work around
To clear the list then repopulate it...

trik
  • Members
  • 1317 posts
  • Last active: Jun 11 2010 11:48 PM
  • Joined: 15 Jul 2007
It works. Don't worry about posting back.
Religion is false. >_>

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007

It works. Don't worry about posting back.

Actually it didnt, see my edit above

Superfraggle
  • Members
  • 1019 posts
  • Last active: Sep 25 2011 01:06 AM
  • Joined: 02 Nov 2004
PostMessage, 0x185, 0, -1, ListBox1
Have you tried that ?
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007
Ok the work around worked:
GuiControl, 1:, DropDownListID, |
GuiControl, 1:, DropDownListID, DLL Entry 1|DLL Entry 2|DLL Entry 3

But can anyone tell me the propper way to do this?

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007

PostMessage, 0x185, 0, -1, ListBox1
Have you tried that ?

Yes I already did, but didnt work
Apparently it is only for multiple-selection list boxs so not surprising there

Also tested
GuiControl, 1:Choose, DropDownListID, |
But that didnt work either

trik
  • Members
  • 1317 posts
  • Last active: Jun 11 2010 11:48 PM
  • Joined: 15 Jul 2007
WOOT :!: :!:

Gui, Add, DropDownList, W100 H50 vDLL, 1|2
Gui, Add, Button, W100 gSelect, Select 1
Gui, Show
Return

Select:
ControlSend, ComboBox1, {Down}

Religion is false. >_>

Superfraggle
  • Members
  • 1019 posts
  • Last active: Sep 25 2011 01:06 AM
  • Joined: 02 Nov 2004
If it's a Combobox the correct message is

Gui +LastFound
PostMessage, 0x014E, -1, 0, ComboBox1

tested and working ok.
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007
ComboBox what?
Its a DropDownList

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007
Thanks for the effort guys, but the functionallity I was after goes more like this:
Gui, Add, DropDownList, W100 H50 vDropDownListID, DLL Entry 1||DLL Entry 2|DLL Entry 3
Gui, Add, Button, W100 gSelect, Select 1
Gui, Show
Return

Select:
GuiControl, 1:, DropDownListID, | 
GuiControl, 1:, DropDownListID, DLL Entry 1|DLL Entry 2|DLL Entry 3

But without having to use
GuiControl, 1:, DropDownListID, | 
GuiControl, 1:, DropDownListID, DLL Entry 1|DLL Entry 2|DLL Entry 3

IMO Logically the correct syntax should be:
GuiControl, 1:Choose, DropDownListID, 0
Or:
GuiControl, 1:Choose, DropDownListID, -1
But neither are working

Superfraggle
  • Members
  • 1019 posts
  • Last active: Sep 25 2011 01:06 AM
  • Joined: 02 Nov 2004
I know it's a drop down list, but as far as the system calls it it is a ComboBox.

The example I posted works, Try it.....

heres the full code i used to test it


gui,add,[color=red]dropdownlist[/color], vban hwndhwnd,a|b|c|d|e|f
gui,show, ,Bleah
sleep 5000
Gui +LastFound
PostMessage, 0x014E, -1, 0, ComboBox1
sleep,5000
exitapp

Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007
Nice one Superfraggle
The reason it wasnt working for me was because I didnt use:
Gui, +LastFound

Then when I did it still wasnt working because I forgot to change to:
Gui, 2:+LastFound

TY

Edit:
I decided to use SendMessage instead to make sure it gets cleared before using:
Gui, Show


Superfraggle
  • Members
  • 1019 posts
  • Last active: Sep 25 2011 01:06 AM
  • Joined: 02 Nov 2004
lol the other way of doing it would be

gui,add,dropdownlist,  hwnd[color=red]hwndvar[/color],a|b|c|d|e|f
gui,show, ,Bleah
sleep 5000
Gui +LastFound
PostMessage, 0x014E, -1, 0,,ahk_id %hwndvar%
sleep,5000
exitapp

That's probably the better way of doing it if you use more than one ddl.
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle