xCobra15x Posted March 9, 2016 Posted March 9, 2016 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.
JohnOne Posted March 9, 2016 Posted March 9, 2016 How are you determining that the number of clicks is incorrect? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
jdelaney Posted March 10, 2016 Posted March 10, 2016 (edited) 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 March 10, 2016 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.
xCobra15x Posted March 10, 2016 Author Posted March 10, 2016 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?
JohnOne Posted March 10, 2016 Posted March 10, 2016 Use ControlClick in a loop, rather than all the clicks in the parameter of the function. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
xCobra15x Posted March 10, 2016 Author Posted March 10, 2016 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
xCobra15x Posted March 10, 2016 Author Posted March 10, 2016 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).
JohnOne Posted March 10, 2016 Posted March 10, 2016 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.
xCobra15x Posted March 10, 2016 Author Posted March 10, 2016 8 minutes 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 I will try this when I have access to my application again. And report back. Thanks
xCobra15x Posted March 11, 2016 Author Posted March 11, 2016 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now