Sign in to follow this  
Followers 0
bobheart

combo box?

18 posts in this topic

With the autoit builder it has a combo box /drop down list thingy and well how do you use it ?

I have this code I made and was thinking on using the drop down lisy thinng to have a code in it and then it if you click on it it would load the code in the list box .

How would I go about showing it in the dropdown and print with a click to the list ?

Code

;Generated with AutoBuilder 0.3

Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)

GuiCreate("MyGUI", 718,485,10,10,0x04CF0000)
$list_1 = GUISetControl("list", "List 1", 10,10, 540,470)
$combo_1 = GUISetControl("combo", "Combo 1", 580,40, 120,40)

GuiShow()

While 1
    sleep(100)
    $msg = GuiMsg(0)
    Select
    Case $msg = -3
  Exit
    Case $msg = $list_1
    ;;;
    Case $msg = $combo_1
    "if (y<room_height-120)"
    ;;;
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

* You may want to upgrade to AutoBuilder 0.4 :D I really need to post an update for AutoBuilder; it's now buried on the third page of the Scripts and Scraps!

* If you need advance listbox stuff, take a look at GuiMsg wrappers

* You might want to increase the height of your combobox. Windows XP seems to ignore the height, but it makes a big difference on Windows 98 and 2000. (height = the max height of the box that drops down from the combobox.)

* Finally, here is an example that populates the listbox with different data depending on what option you choose in the combo box. If you have a lot of data, it might be better to use an array instead of the hard-coded variables in my code:

Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 718,485,10,10,0x04CF0000)

$list_1 = GUISetControl("list", "List 1", 10,10, 540,470)
$combo_1 = GUISetControl("combo", "Combo 1", 580,140, 120,40)
GuiSetControlData($combo_1, "option A|option B|option C")

GuiShow()

While 1
sleep(100)
$msg = GuiMsg(0)

Select
Case $msg = -3
   ExitLoop
Case $msg = $list_1
 ;;;
Case $msg = $combo_1
   $selectedItem = GuiRead($combo_1)
   Select
      Case $selectedItem = "option A"
         GuiSetControlData($list_1, "");clear list
         GuiSetControlData($list_1, "apple|aardvark|airplane")
      Case $selectedItem = "option B"
         GuiSetControlData($list_1, "");clear list
         GuiSetControlData($list_1, "banana|bird|bus")
      Case $selectedItem = "option C"
         GuiSetControlData($list_1, "");clear list
         GuiSetControlData($list_1, "coconut|cat|car")
   EndSelect
EndSelect

WEnd
Exit
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

thank you for the help and all grab the new one you have done right now ..

Share this post


Link to post
Share on other sites

Ok I wanted to be able to copy the txt in the box so changed it to a edit box and changed what I though needed to be changed but getting a error .

Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 718,485,10,10,0x04CF0000)

$edit_1 = GUISetControl("edit", "Edit 1", 10,10, 540,470)
$combo_1 = GUISetControl("combo", "Combo 1", 580,140, 120,40)
GuiSetControlData($combo_1, "option A|option B|option C|Test D")

GuiShow()

While 1
sleep(100)
$msg = GuiMsg(0)

Select
Case $msg = -3
  ExitLoop
Case $msg = $edit 1
;;;
Case $msg = $combo_1
  $selectedItem = GuiRead($combo_1)
  Select
     Case $selectedItem = "option A"
        GuiSetControlData($edit 1, "");clear list
        GuiSetControlData($edit 1, "apple|aardvark|airplane")
     Case $selectedItem = "option B"
        GuiSetControlData($edit 1, "");clear list
        GuiSetControlData($edit 1, "banana|bird|bus")
     Case $selectedItem = "option C"
        GuiSetControlData($edit 1, "");clear list
        GuiSetControlData($edit 1, "coconut|cat|car")
        Case $selectedItem = "Test D"
        GuiSetControlData($edit 1, "");clear list
        GuiSetControlData($edit 1, "dog|duck|drak")
  EndSelect
EndSelect

WEnd
Exit

Error

---------------------------

AutoIt Error

---------------------------

Line 17  (File "E:\Programs\AutoIt3\Examples\june28\5.au3"):

Case $msg = $edit 1

Case $msg = ^ ERROR

Error: Variable used without being declared.

What did I do worng ?

Share this post


Link to post
Share on other sites

<snip>

* You might want to increase the height of your combobox.  Windows XP seems to ignore the height, but it makes a big difference on Windows 98 and 2000.  (height = the max height of the box that drops down from the combobox.)

<snip>

CBS_NOINTEGRALHEIGHT

Specifies that the size of the combo box is exactly the size specified by the application when it created the combo box. Normally, the system sizes a combo box so that it does not display partial items.

Setting $CBS_NOINTEGRALHEIGHT when creating a combo-box (Or $LBS_NOINTEGRALHEIGHT for a ListBox) creates the box the size you specified instead of letting Windows do it's usual routine which is to attempt to make sure an item isn't partially shown.

Share this post


Link to post
Share on other sites

***Bump***

Share this post


Link to post
Share on other sites

Ok wow you looked and looked and didn't see that . lol

But now when I try to use the drop down list and click on a name I get this.

---------------------------

AutoIt Error

---------------------------

Line 29 (File "E:\Programs\AutoIt3\Examples\june28\5.au3"):

GuiSetControlData($edit 1, "");clear list

GuiSetControlData(^ ERROR

Error: Variable used without being declared.

Share this post


Link to post
Share on other sites

Setting $CBS_NOINTEGRALHEIGHT when creating a combo-box (Or $LBS_NOINTEGRALHEIGHT for a ListBox) creates the box the size you specified instead of letting Windows do it's usual routine which is to attempt to make sure an item isn't partially shown.

mmm....thanks 4 the tip. :D

Share this post


Link to post
Share on other sites

Well i found the error .

($edit 1 needed to be ($edit_1

But now nothing shows in the big edit box ?

Share this post


Link to post
Share on other sites

Well i found the error .

($edit 1  needed to be ($edit_1

But now nothing shows in the  big edit box ?

GuiSetControlData is not the right function to update a "edit" control you have to use GuiWrite

That's the doc say about it

GuiSetControlData

Define data info for Combo or List Control.

Good luck

:D

Share this post


Link to post
Share on other sites

Now the drop down has nothing in it ?

Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 718,485,10,10,0x04CF0000)

$edit_1 = GUISetControl("edit", "Edit 1", 10,10, 540,470)
$combo_1 = GUISetControl("combo", "Combo 1", 580,140, 120,40)
GUIWrite($combo_1, "option A|option B|option C|Test D")

GuiShow()

While 1
sleep(100)
$msg = GuiMsg(0)

Select
Case $msg = -3
  ExitLoop
Case $msg = $edit_1
;;;
Case $msg = $combo_1
  $selectedItem = GuiRead($combo_1)
  Select
     Case $selectedItem = "option A"
        GUIWrite($edit_1, "");clear list
        GUIWrite($edit_1, "apple|aardvark|airplane")
     Case $selectedItem = "option B"
        GUIWrite($edit_1, "");clear list
        GUIWrite($edit_1, "banana|bird|bus")
     Case $selectedItem = "option C"
        GUIWrite($edit_1, "");clear list
        GUIWrite($edit_1, "coconut|cat|car")
        Case $selectedItem = "Test D"
        GUIWrite($edit_1, "");clear list
        GUIWrite($edit_1, "dog|duck|drak")
  EndSelect
EndSelect

WEnd
Exit

Share this post


Link to post
Share on other sites

Now the drop down has nothing in it ?

Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 718,485,10,10,0x04CF0000)

$edit_1 = GUISetControl("edit", "Edit 1", 10,10, 540,470)
$combo_1 = GUISetControl("combo", "Combo 1", 580,140, 120,40)
GUIWrite($combo_1, "option A|option B|option C|Test D")

GuiShow()

While 1
sleep(100)
$msg = GuiMsg(0)

Select
Case $msg = -3
  ExitLoop
Case $msg = $edit_1
;;;
Case $msg = $combo_1
  $selectedItem = GuiRead($combo_1)
  Select
     Case $selectedItem = "option A"
        GUIWrite($edit_1, "");clear list
        GUIWrite($edit_1, "apple|aardvark|airplane")
     Case $selectedItem = "option B"
        GUIWrite($edit_1, "");clear list
        GUIWrite($edit_1, "banana|bird|bus")
     Case $selectedItem = "option C"
        GUIWrite($edit_1, "");clear list
        GUIWrite($edit_1, "coconut|cat|car")
        Case $selectedItem = "Test D"
        GUIWrite($edit_1, "");clear list
        GUIWrite($edit_1, "dog|duck|drak")
  EndSelect
EndSelect

WEnd
Exit
Tha's what is implemented too. if you want something displayed you have to defined a default value

but you have to use for combo the GuiSetControlData not the GuiWrite

GuiSetControlData ($combo_1, "option A|option B|option C|Test D","option A" )

:D

Share this post


Link to post
Share on other sites

I tried that And I still can't get it to work . :D

Share this post


Link to post
Share on other sites

****BUMP***

Share this post


Link to post
Share on other sites

In General:

Use GuiSetControlData for "list" and "combo" controls

Use GuiWrite for "edit" and "input" controls

Also pay careful attention to the parameters:

GUIWrite ( controlref ,state ,info, ...)

GUISetControlData ( controlref, data,...)

Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 718,485,10,10,0x04CF0000)

$edit_1 = GUISetControl("edit", "Edit 1", 10,10, 540,470)
$combo_1 = GUISetControl("combo", "Combo 1", 580,140, 120,40)
GuiSetControlData($combo_1, "option A|option B|option C|Test D")

GuiShow()

While 1
sleep(100)
$msg = GuiMsg(0)

Select
Case $msg = -3
 ExitLoop
Case $msg = $edit_1
;;;
Case $msg = $combo_1
 $selectedItem = GuiRead($combo_1)
 Select
    Case $selectedItem = "option A"
       GuiWrite($edit_1, -1, "");clear edit
       GuiWrite($edit_1, -1, "apple|aardvark|airplane")
    Case $selectedItem = "option B"
       GuiWrite($edit_1, -1, "");clear edit
       GuiWrite($edit_1, -1, "banana|bird|bus")
    Case $selectedItem = "option C"
       GuiWrite($edit_1,-1, "");clear edit
       GuiWrite($edit_1, -1, "coconut|cat|car")
       Case $selectedItem = "Test D"
       GuiWrite($edit_1, -1, "");clear edit
       GuiWrite($edit_1, -1, "dog|duck|drak")
 EndSelect
EndSelect

WEnd
Exit

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Thank you that worked , it strings them dog|duck|drak but I can work around that ..

Share this post


Link to post
Share on other sites

How can I add html code in the

GuiWrite($edit_1, -1, "dog|duck|drak"& @CRLF & "")
.

If I try to html code in it , it thinks the html is autoit code ..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0