Sign in to follow this  
Followers 0
Arclite86

making a list counter

17 posts in this topic

I would like to make a counter that count from a list every time the next name is selected 

with this code:

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

(selects the next name in $list1)

I have made a input were i want the number to be displayed

$listcounter = GUICtrlCreateInput("1", 232, 32, 41, 21) 

I tried to do something like this:, every time i press the next button

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

GUICtrlSetData($listcounter,+1)

but it doesnt work, and like this it wil keep counting every time i press is it even when the list is done..

could someody help me with this?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,
You remind me a guy on this forum who kept asking questions, those questions could be answered easily with some practice and by reading the helpfile.

What do you think this does ?

GUICtrlSetData($listcounter,+1)

Unfortunately not what you're expecting.

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

Hi,

You remind me a guy on this forum who kept asking questions, those questions could be answered easily with some practice and by reading the helpfile.

What do you think this does ?

GUICtrlSetData($listcounter,+1)

Unfortunately not what you're expecting.

alright I already got it ,its

GUICtrlSetData($listcounter,$iIndex)

but now im trying to make an other counter that when its hits the nummer 20 it returns to 0 and starts all over again

I have looked in the helpfile but could not find what i was looking for

I have tried these things:

GUICtrlSetData($listcounter,$iIndex)
$rt = GUICtrlRead($listcounter)
GUICtrlSetData($listcounter2,$rt )

If $iIndex = 20 Then $listcounter2 =0
GUICtrlSetData($listcounter,$iIndex)
$rt = GUICtrlRead($listcounter)
GUICtrlSetData($listcounter2,$rt )

If $iIndex = 20 Then $listcounter2 =$listcounter2-20

but instead of returing to 0 it stays stuck at 20

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Where is $listcounter2 var set to?

Others : I know what's wrong, I'm trying to guide him to the problem.

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

#5 ·  Posted (edited)

Where is $listcounter2 var set to?

Others : I know what's wrong, I'm trying to guide him to the problem.

im sorry I forgot to give the info of the second input

$listcounter2 = GUICtrlCreateInput("0", 272, 32, 41, 21)

I hope thats answers  your question

What should i do now...?

Edited by Arclite86

Share this post


Link to post
Share on other sites

 

What should i do now...?

Open the help file and read it thoroughly.

Another extremely simple question that would be answered by doing some of the work yourself for once.


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

Open the help file and read it thoroughly.

Another extremely simple question that would be answered by doing some of the work yourself for once.

then show me where i can find this part in the helpfile because I cant find it, I already told that

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Questions to answer are : What GUICtrlCreate* functions return? Can this return variable be directly assigned to change the control value?

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

Questions to answer are : What GUICtrlCreate* functions return? Can this return variable be directly assigned to change the control value?

I used multiple, GUICtrlCreate* input,label,edit but they al wont work if i use my code,

I did figured out how to get it to "0" with this

GUICtrlSetData($listcounter,$iIndex)
$rt = GUICtrlRead($listcounter)
GUICtrlSetData($listcounter2,$rt )

 If $iIndex = 5 Then $listcounter2 = GUICtrlSetData($listcounter2,0)

But i just cant figure out how to make it count after it returns to "0"

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

when I also use something like this

Local $i = 0
While $i <= 10
     GUICtrlSetData($listcounter2,$i)
    $i = $i + 1
WEnd
For $counter = 1 to 10
   GUICtrlSetData($listcounter2,$counter)
Next

It should work but when i press one time it shows the number 10 and stays at that  number how is that possible, I have also tried different  GUICtrlCreate,  what am i doing wrong?

can  somebody explain this please ?

Edited by Arclite86

Share this post


Link to post
Share on other sites

Explain me this line :

If $iIndex = 5 Then $listcounter2 = GUICtrlSetData($listcounter2,0)

 

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

#12 ·  Posted (edited)

 

Explain me this line :

If $iIndex = 5 Then $listcounter2 = GUICtrlSetData($listcounter2,0)

I tried when the $index is 5 then set the input to 0  but i have a better code

For $counter = 1 to 10
   GUICtrlSetData($listcounter2,$counter)
Next

I tried to make it count every time I hit the button until 10 and then restart, but when I press it the first time it doesnt count but directly shows the number 10..

I dont know what to do, I'm looking in the helpfile for a while now but I cant find the solution, help please.

Edited by Arclite86

Share this post


Link to post
Share on other sites

This is not what I asked, I know what you're trying to do.


 

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

#14 ·  Posted (edited)

This is not what I asked, I know what you're trying to do.

If $iIndex = 5 Then $listcounter2 = GUICtrlSetData($listcounter2,0)

when the $index is 5 then display 0 

right?

Edited by Arclite86

Share this post


Link to post
Share on other sites

Partly yes, but that's not all. And that's the rest which causes a problem.


 

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

Partly yes, but that's not all. And that's the rest which causes a problem.

but when i use  this

Local $i = 0
While $i <= 10
     GUICtrlSetData($listcounter2,$i)
    $i = $i + 1
WEnd

how can this not work?

Share this post


Link to post
Share on other sites

I don't see the point of your while code since it will set the data from 0 to 10 and you won't have enough time to see it has changed. So it's the same as setting the data to 10.

So I wanted you to find out that you are resetting the value of the $listcounter2 variable in this code :

If $iIndex = 5 Then $listcounter2 = GUICtrlSetData($listcounter2,0)

Because the function GUICtrlSetData return either 0, 1 or -1 (see helpfile).

Hence, you can't reuse this variable to handle the input.

At start, the variable contained the id of the input.

And please, read the helpfile.

Br, 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

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