Jump to content

Control Click Limited Clicks


Recommended Posts

Hi guys,

I'm fairly new to AutoIt. I have taken it on as a final project for my associates degree. My first step is to take the user input from a textbox and divide that input by 4. Once the input is divided, I want to click that many times using control click. 

It appears like this: 

ControlClick($ccd[0], $ccd[1], $ccd[2], $ccd[3], $input, 220, 40)
                    Sleep(200)

The arrays are so I don't have to keep typing in the title, text, control id, and mouse button. $input is the variable amount of clicks based on user input which I'm getting from a variable function that looks like this:

$input = Int(GUICtrlRead($hinputbox)) / 4

My issue is that if I input a number like 100, it only clicks 10 times even though it should click 25 times.

I know my variable is giving me the correct numbers because I can use a message box to show my what the variable is each time. I'm just not sure why that number isn't translating into the control click correctly. Anything under 40 works correctly because it's supposed to be 10. 

 

Any insight would be awesome.

Link to comment
Share on other sites

If you spam clicks as fast as possible, your app probably can not handle or process them quickly enough.

You must add in sleeps, or configure your script to not send the clicks faster than your app can register:

AutoItSetOption...

MouseClickDelay Alters the length of the brief pause in between mouse clicks.
Time in milliseconds to pause (default=10).
MouseClickDownDelay Alters the length a click is held down before release.
Time in milliseconds to pause (default=10).
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Quote
18 hours ago, JohnOne said:

How are you determining that the number of clicks is incorrect?

 

The interface I am using adds items each time it is clicked. I'm only getting 10 items added, thus 10 clicks. 

 

Quote
14 hours ago, jdelaney said:

If you spam clicks as fast as possible, your app probably can not handle or process them quickly enough.

You must add in sleeps, or configure your script to not send the clicks faster than your app can register:

AutoItSetOption...

MouseClickDelay Alters the length of the brief pause in between mouse clicks.
Time in milliseconds to pause (default=10).
MouseClickDownDelay Alters the length a click is held down before release.
Time in milliseconds to pause (default=10).

 

This makes sense. I figured it wasn't having time to register in my app. How would I incorporate MouseCilckDelays within my control click?  

Link to comment
Share on other sites

3 minutes ago, JohnOne said:

Use ControlClick in a loop, rather than all the clicks in the parameter of the function.

I am using a for loop to make this happen 4 different times. The code purposely takes the input and divides by 4 and then puts 1/4 of the input into one control click, loops through 4 times to do all of the input. 

 

ControlClick("Application", "", "", "left", "1", "1", "12")  ;;;not the issue
    Sleep(200)
    ControlClick("Application", "", "", "left", "1", "38", "575") ;;;not the issue
    Sleep(200)
    ControlClick("Application", "", "", "left", "1", "763", "339") ;;;not the issue
    Sleep(200)


    For $x = 1 To 4 Step 1
        ControlClick($ccd[0], $ccd[1], $ccd[2], $ccd[3], $in1, $1Loc[0], $1sLoc[1])
                    Sleep(200)
        ControlClick($ccd[0], $ccd[1], $ccd[2], $ccd[3], $in2, $2Loc[0], $2Loc[1])
                    Sleep(200)
        ControlClick($ccd[0], $ccd[1], $ccd[2], $ccd[3], $in3, $3Loc[0], $3Loc[1])
                    Sleep(200)
     
        ControlClick("Application", "", "", "left", "1", "763", "339")
        Sleep(200)
    Next

 

 

 

 

Link to comment
Share on other sites

Let me better explain what I'm doing. I have a front panel application that has several buttons that I need repeatedly clicked on based on user input. The front panel application adds items to a list when the button is clicked. If the button is clicked 10 times, it gives me 10 items, if the button is clicked less than that, it gives me less than that. My issue is coming from when I get more than 10 clicks needed. The user input is from a textbox. I am taking that input, dividing it by 4 and using the new answer to click for the first loop, the next loop, it moves to a new area and clicks the same amount of times again. It does this 4 times (hence the 4 steps in the for loop). 

Link to comment
Share on other sites

Add other locations.

For $x = 1 To 4 Step 1
    For $i = 1 To $Input
        ControlClick($ccd[0], $ccd[1], $ccd[2], $ccd[3], 1, $1Loc[0], $1sLoc[1])
        Sleep(50)
    Next
Next

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

8 hours ago, JohnOne said:

Add other locations.

For $x = 1 To 4 Step 1
    For $i = 1 To $Input
        ControlClick($ccd[0], $ccd[1], $ccd[2], $ccd[3], 1, $1Loc[0], $1sLoc[1])
        Sleep(50)
    Next
Next

 

Worked beautifully. Thanks :).

Any tips to get the remainders to click? Ie if my input is 50, I divide by 4 and get a remainder of 2. Currently I lose those 2 clicks, where as I want them to start at beginning of loop, do one click, click the next button, do one more click so I get all 50 items and then stop. 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...