Sign in to follow this  
Followers 0
dzony91

ListBox Search...Litle bug in script :S

10 posts in this topic

Hi everyone... i have small bug but i don't know where :S

I want to detect item from ListBox, if exists to show it, else if does not exists to show in TrayTip Added: name...

here is my example script with bug :)

#include <GUIConstants.au3>
#include <GUIListBox.au3>
$guiname = "ASD"
$Form1 = GUICreate("Form1", 488, 418, -1,-1)
$nweb = GUICtrlCreateInput("", 8, 16, 400, 21)
$new = GUICtrlCreateButton("OK", 410,15,63,23, $BS_DEFPUSHBUTTON)
$List1 = GUICtrlCreateList("", 8, 48, 465, 357)
GUICtrlSetData(-1, "a2a|sasd|dasd|gasdasda|xasdasdasd|asdasdasd|sd|sd|sda|sdasda")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $new
            $newitem = GUICtrlRead($nweb)
            If $newitem >= 0 Then
                Local $FindExAdd = _GUICtrlListBox_FindInText($List1, $newitem)
                    If $newitem <> _GUICtrlListBox_GetText($List1,$FindExAdd) Then
                        TrayTip($guiname,"Added: "& $newitem &"!!!",5,1)
                ;ElseIf _GUICtrlListBox_GetText($List1,$FindExAdd) = 0 Then
                ;   TrayTip($guiname,"Already exists :)",5,1)
                Else
            ;   If $FindExAdd = 1 Then
                        TrayTip($guiname,"Already exists: " & _GUICtrlListBox_GetText($List1,$FindExAdd),5,1)
                ;Else
            ;       TrayTip($guiname,"Added: " & $newitem,5,1)
            ;   EndIf
                EndIf
            EndIf
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi everyone... i have small bug but i don't know where :S

I want to detect item from ListBox, if exists to show it, else if does not exists to show in TrayTip Added: name...

here is my example script with bug biggrin.gif

So?

Something like this?

#include <GUIConstants.au3>
#include <GUIListBox.au3>
$guiname = "ASD"
$Form1 = GUICreate("Form1", 488, 418, -1,-1)
$nweb = GUICtrlCreateInput("", 8, 16, 400, 21)
$new = GUICtrlCreateButton("OK", 410,15,63,23, $BS_DEFPUSHBUTTON)
$List1 = GUICtrlCreateList("", 8, 48, 465, 357)
GUICtrlSetData(-1, "a2a|sasd|dasd|gasdasda|xasdasdasd|asdasdasd|sd|sd|sda|sdasda")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $new
            if Guictrlread($nweb) = "" AND Guictrlread($list1) = "" Then
                    TrayTip($guiname,"Select from List or Input Value!", 5,1)
            Else
                if GUICtrlRead($nweb) Then
                    $newitem = guictrlread($nweb)
                elseif guictrlread($List1) Then
                    $newitem = Guictrlread($List1)
                EndIf
                if _GUICtrlListBox_FindString($List1, $newitem, True) > -1 Then
                    TrayTip($guiname,"Already exists: " & $newitem, 5,1)
                Else
                    guictrlsetdata($List1, $newitem)
                    TrayTip($guiname,"Added: " & $newitem, 5,1)
                EndIf
            EndIf
    EndSwitch
WEnd

Is that what you needed? Keep in mind, because you didn't say you wanted to SAVE any Added items, i didn't include that. :) Any values that are added to the list will only be for the current session.

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites

Yo man, Thank you, this is very better :)

Share this post


Link to post
Share on other sites

Of course, i understand that :)

But i have 1 more bug...

I added this in line 30:

_GUICtrlListBox_SetCurSel($List1, _GUICtrlListBox_FindInText($List1, $newitem))

So, when add this "aaaaaaaaad" he is selected and that its ok, but when add after that this: "aaaad" i get still selected this "aaaaaaaaad",why ?

How to fix that ?

...Sorry for bad english :)

Share this post


Link to post
Share on other sites

Of course, i understand that :)

But i have 1 more bug...

I added this in line 30:

_GUICtrlListBox_SetCurSel($List1, _GUICtrlListBox_FindInText($List1, $newitem))

So, when add this "aaaaaaaaad" he is selected and that its ok, but when add after that this: "aaaad" i get still selected this "aaaaaaaaad",why ?

How to fix that ?

...Sorry for bad english :)

Searches for an item that contains the specified text anywhere in its text


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Well, is it possible for searching with 'match case' like in notepad or something like that ? ?

Share this post


Link to post
Share on other sites

Well, is it possible for searching with 'match case' like in notepad or something like that ? ?

Look at _GUICtrlListBox_FindString


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

hehe, thx :)

Share this post


Link to post
Share on other sites

One more thing, why not fork _GUICtrlListBox_Sort in this example? :)

#include <GUIConstants.au3>
#include <GUIListBox.au3>
$guiname = "ASD"
$Form1 = GUICreate("Form1", 488, 418, -1,-1)
$nweb = GUICtrlCreateInput("", 8, 16, 400, 21)
$new = GUICtrlCreateButton("Replace", 410,15,63,23, $BS_DEFPUSHBUTTON)
$List1 = GUICtrlCreateList("", 8, 48, 465, 357)
GUICtrlSetData(-1, "a2a|sasd|dasd|gasdasda|xasdasdasd|asdasdasd|sd|sd|sda|sdasda")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $new
            _GUICtrlListBox_ReplaceString($List1,1,"zzzzzzz")
            _GUICtrlListBox_Sort($List1)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Any1 :)

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