Sign in to follow this  
Followers 0
ssah8

Not working in loop

6 posts in this topic

Why does this not work in a loop?

$counter = GUICtrlCreateLabel ($counter + 1, 220, 152, 127, 17)

Share this post


Link to post
Share on other sites



Am I allowed to ask a question as simple as this? Or does this somehow break any rules this website has?

Share this post


Link to post
Share on other sites

This oneliner couldn't run.

Share this post


Link to post
Share on other sites

For $i = 1 To 10

$counter = GUICtrlCreateLabel ($counter + 1, 220, 152, 127, 17)

Next

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Also not runable, there is no GUI. Make a runable (reproducer script) for get better help. Until this learn the basics maybe this script helps:

;https://autoit.de/index.php/Thread/83656-Button-Klick-erkennen-wenn-Funktion-l%C3%A4uft-so-wie-ein-Hotkey/?postID=669356#post669356
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$gui = GUICreate("KLeines 1 X 1", 400, 130)
$Start = GUICtrlCreateButton("&Start", 10, 10)
$PauseResume = GUICtrlCreateButton("&Pause", 10, 40)
$Label = GUICtrlCreateLabel("", 100, 70, 280, 22)
$Anzeige = GUICtrlCreateLabel("", 10, 95, 380, 22)
GUISetState()
Global $sIPAddress


While 1
    _EventHandler()
WEnd

Func _EventHandler()
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            GUICtrlSetState($Start, $GUI_DISABLE)
            For $i = 1 To 10
                For $j = 1 To 10
                    GUICtrlSetData($Anzeige, $j & " * " & $i & " = " & $i * $j)
                    _MySleep(500)
                Next
            Next
            GUICtrlSetState($Start, $GUI_ENABLE)
        Case $PauseResume
            If GUICtrlRead($PauseResume) = "&Pause" Then
                GUICtrlSetData($PauseResume, "&Weiter")
                While GUICtrlRead($PauseResume) <> "&Pause"
                    _MySleep(50)
                WEnd
            Else
                GUICtrlSetData($PauseResume, "&Pause")
            EndIf
    EndSwitch
EndFunc   ;==>_EventHandler

Func _MySleep($iMSec)
    Local $iStart = TimerInit()
    Do
        _EventHandler()
    Until TimerDiff($iStart) >= $iMSec
EndFunc   ;==>_MySleep

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

I figured it out myself. I used GUICtrlSetData. Thank you anyways. (Your code explains it aswell)

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