Jump to content

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

[Solved]manipulate DROPDOWNLIST items



  • Please log in to reply
4 replies to this topic
tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Gui, Add, DropDownList, x6 y7 w100 h80 vmyDrop, 
Gui, Add, Button, x116 y7 w90 h20 gAddItem Default, add item
Gui, Add, Button, x116 y37 w90 h20 gChangeItem, change item
; Generated using SmartGUI Creator 4.0
Gui, Show, x131 y91 h67 w227, New GUI Window
Return

GuiClose:
ExitApp

AddItem:
Gui, Submit , NoHide
InputBox,newItem,Add an Item
GuiControl,Text,myDrop,%newItem%
Return
ChangeItem:
Gui, Submit , NoHide
;~ Need some code that will return the entire list from myDrop  and remove i can then use string replace to modify
Return

basically i would like to be able to dynamically add (doable already) and then change or delete options(cant find how to do)
i then need to be able to parse each item from the list and return the value which i will use in excel
soemthing equve to vb additem and removeitem
Never lose.
WIN or LEARN.

heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008
hi tank you can do that by sendmessages here's simple example
please be aware that i've omitted WinTitle due to +LastFound
hope this helps

Gui, +LastFound
Gui, Add, DropDownList, r5 w100
Gui, Add, Button,, AddItem
Gui, Add, Button,, InsertItem
Gui, Add, Button,, ChangeItem
Gui, Add, Button,, RemoveItem
Gui, Add, Button,, ResetItems
Gui, Add, Button,, GetAllItems
Gui, Show 
Return

GuiClose:
ExitApp

ButtonAddItem:
InputBox,addItem,Add Item
SendMessage,0x143,,&addItem,ComboBox1 ;CB_ADDSTRING
SendMessage,0x14E,%Errorlevel%,,ComboBox1 ;CB_SETCURSEL
Return

ButtonInsertItem:
InputBox,insertItem,Insert Item
SendMessage,0x147,,,ComboBox1 ;CB_GETCURSEL
OldPos := Errorlevel
SendMessage,0x14A,%Errorlevel%,&insertItem,ComboBox1 ;CB_INSERTSTRING
SendMessage,0x14E,%OldPos%,,ComboBox1 ;CB_SETCURSEL
Return

ButtonChangeItem:
InputBox,changeItem,change Item
SendMessage,0x147,,,ComboBox1 ;CB_GETCURSEL
Pos := Errorlevel
SendMessage,0x144,%Errorlevel%,,ComboBox1 ;CB_DELETESTRING
SendMessage,0x14A,%Pos%,&changeItem,ComboBox1 ;CB_INSERTSTRING
SendMessage,0x14E,%Pos%,,ComboBox1 ;CB_SETCURSEL
Return

ButtonRemoveItem:
SendMessage,0x147,,,ComboBox1 ;CB_GETCURSEL
PriorSel := Errorlevel-1
SendMessage,0x144,%Errorlevel%,,ComboBox1 ;CB_DELETESTRING
SendMessage,0x14E,%PriorSel%,,ComboBox1 ;CB_SETCURSEL
Return

ButtonResetItems:
SendMessage,0x14B,,,ComboBox1 ;CB_RESETCONTENT
Return

ButtonGetAllItems:
Result := ""
SendMessage,0x0146,,,ComboBox1 ;CB_GETCOUNT
Loop, %Errorlevel%
{
    SendMessage,0x149,% A_Index-1,,ComboBox1 ;CB_GETLBTEXTLEN
    VarSetCapacity(buffer, Errorlevel) ;prepare buffer
    SendMessage,0x148,% A_Index-1,&buffer,ComboBox1 ;CB_GETLBTEXT
    Result .= buffer "`n"
    VarSetCapacity(buffer,0) ;empty for next wheel
}
MsgBox, %Result%
Return

Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
tested genious when searching for this i noticed there had been lots of other similar requests might you be willing to post your example on the scripts and functions?
Never lose.
WIN or LEARN.

heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008
✓  Best Answer
i've wrapped it all as functions. thanks for your suggestion tank

CB_*() - ComboBox / DropDownList manipulation functions
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Thanks now i can credit you correctly when i write(finish actually) my browser macro recorder and dom maacro writer that im working on and a dynamic drop down was just what i needed
Never lose.
WIN or LEARN.