Sign in to follow this  
Followers 0
stallion

For Next problem --- count problem

3 posts in this topic

#1 ·  Posted (edited)

What wrong with my script that the for next loop count a wrong number??

 

When I input 10 times to execute the for next loop, the program execute only 5 times.

 

 

The script list as below. thanks.

 

 

PS: the program execute correct sometimes but not always.

 

ClickTheMouse1()

Func ClickTheMouse1()

    $time2send = InputBox("Set the number of seconds "," Enter the number of seconds, which can be a decimal point?  Mouse over the left-most screen, you can exit the program", "") * 1000
    ; Second input box
    $num2send = InputBox("Set the number of connect the dots "," Input number must be greater than 1?  Mouse over the left-most screen, you can exit the program", "")
    ;mouse click  execute times input box
    If $time2send < 0.4 Then
        $time2send = 1.5 * 1000
    EndIf

    If $num2send < 1 Then
        $num2send = 10
    EndIf

    MsgBox(4096, "Mouse ready press OK "," every " & $time2send / 1000 & " seconds of pressing " & $num2send & " times, move the mouse to the position, ready to press the OK")

    ; Show the message what the data is about user input.
    $pos = MouseGetPos()
    $x = $pos[0]
    $y = $pos[1]
    ; get the mouse position.

    $iCount = 0
    ; @@ for next loop, some problem in there.
    For $i = 1 To $num2send Step 1
        If $pos[0] = 0 Then
            ExitLoop
        EndIf

        $iCount += 1
        ConsoleWrite($iCount & " - ")

        If $time2send = 2500 Then
            ;MouseClick("Left")
            ConsoleWrite("Click left" & @CRLF)
        Else
            ;MouseClick("Left", $x, $y)
            ConsoleWrite("Click left at pos" & @CRLF)
        EndIf
        Sleep($time2send) ;sleep
        $pos = MouseGetPos()
    Next
EndFunc   ;==>ClickTheMouse1
Edited by Melba23
Added code tags and translated

Share this post


Link to post
Share on other sites



stallion,

Welcome to the AutoIt forum. :)

Your loop runs 10 times when I set that value. Why do you think it does not? :huh:

M23

P.S. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I found the reason. I use the  ToolTip("Count down!  " & $i, $x, $y)  to debug the program.

The web site that I want to use Autoit on it dose not reflect the mouse click below 1.5 second.

 

Thanks.

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