Sign in to follow this  
Followers 0
Arclite86

list, select next name

13 posts in this topic

I got a list : "$List1 = GUICtrlCreateList("", 0, 80, 89, 253, BitOR($WS_BORDER, $WS_VSCROLL))"

with a few names in it, 

I have a button that select the next name but its not working proporly:

$iIndex += 1
            If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List1, $iIndex)

when i press the button it selects the second one, and when i press agian nothing happens

could somebody please give me the correct code 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

Do you expect us to build a reproducer for you?

I mean, please post at least a working code with a GUI.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I already solved the problem

Share this post


Link to post
Share on other sites

but i have another question, how can you delete all names in al list with one function/button:

 
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
Global $iIndex = 0


$Form1 = GUICreate("Form1", 487, 437, 360, 120)

$List1 = GUICtrlCreateList("", 136, 24, 345, 392, BitOR($WS_BORDER, $WS_VSCROLL))
$Button1 = GUICtrlCreateButton("next", 8, 24, 113, 41)


GUISetState(@SW_SHOW)

GUICtrlSetData($List1, "name1|name2|name3|name4|name5")
_GUICtrlListBox_SetCurSel($List1, $iIndex)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1

            $iIndex += 1
            If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List1, $iIndex)

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

GUICtrlSetData

 

For Combo or List control :
If the "data" corresponds to an already existing entry it is set as the default.
If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks.

I have a 2 other questions:

1.How can I overwrite a name in a list instead of adding a string

 

2. and can I automaticly count the names in a list or txt.file and put it in a variable like: $listcount

and than a function:  $function X (times) $listcount     

Share this post


Link to post
Share on other sites

Thanks.

 

I have a 2 other questions:

 

1.How can I overwrite a name in a list instead of adding a string

_GUICtrlListBox_ReplaceString

 

2. and can I automaticly count the names in a list or txt.file and put it in a variable like: $listcount

and than a function:  $function X (times) $listcount

_GUICtrlListBox_GetCount for the count in the list box, and _FileCountLines or FileReadToArray and use UBound to see how many lines are in it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

_GUICtrlListBox_ReplaceString

 

_GUICtrlListBox_GetCount for the count in the list box, and _FileCountLines or FileReadToArray and use UBound to see how many lines are in it.

Ok and how can I repeat a function : Call ("function") as many as time it has counted the line/names in the list

Share this post


Link to post
Share on other sites

For loop?

Have you even tried reading the help file? Because this is basic stuff anyone could find in it within 10 seconds, even just looking at the Index tab should have given you something of a clue as to what might be what you need.

Loops are one of the most basic of programming functions, and if you don't even know this much, you need to spend a LOT more time learning the language and a LOT less time asking for help. I'm not seeing a lot of self-help initiative from you, I'm seeing someone way over their head trying to leech as much information out of others as possible without doing much of the work himself.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

_GUICtrlListBox_ReplaceString

 

_GUICtrlListBox_GetCount for the count in the list box, and _FileCountLines or FileReadToArray and use UBound to see how many lines are in it.

I want to replace a selected line/name in a list this is what i tried 

$replace = GUICtrlRead($List1)
 _GUICtrlListBox_ReplaceString($List1, $replace, "text")

but why is it not working?

Share this post


Link to post
Share on other sites

Have you even tried reading the help file?

 

GUICtrlRead

Return Value  : Combo, List - The value selected

_GUICtrlListBox_ReplaceString ( $hWnd, $iIndex, $sText )

$iIndex Specifies the 0-based index of the item

Share this post


Link to post
Share on other sites

It's not working because you are using it wrong. Did you try reading the help file for the function? The second parameter is not the text of the list box that is selected, it's the INDEX of the list that you want to replace.

To get the index you can use _GUICtrlListBox_GetCurSel or _GUICtrlListBox_GetSelItems if you're selecting more than one item.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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