Sign in to follow this  
Followers 0
cbriggs77

Help with condensing code.

11 posts in this topic

#1 ·  Posted (edited)

Ok so i have this code right, and i wrote this code after just learning autoit through like youtube and such. it's for like stuff and definitely not against TOS.  :sweating:

MouseMove(730, 1093)
    MouseClick("left")
    Sleep($interval)
    MouseMove(531, 447)
    MouseClick("left")
    Sleep($interval)
    Send("a")
    MouseMove(845, 514)
    MouseClick("left") ;1
    Sleep($interval2)
    MouseClick("left") ;2
    Sleep($interval2)
    MouseClick("left") ;3
    Sleep($interval2)
    MouseClick("left") ;4
    Sleep($interval2)
    MouseClick("left") ;5
    Sleep($interval2)
    MouseClick("left") ;6
    Sleep($interval2)
    MouseMove(1225, 752)
    MouseClick("left") ;1
    Sleep($interval3)
    MouseMove(1035, 604)
    MouseClick("left") ;2
    Sleep($interval2)
    MouseClick("left") ;3
    Sleep($interval2)
    MouseClick("left") ;4
    Sleep($interval2)
    MouseClick("left") ;5
    Sleep($interval2)
    MouseClick("left") ;6
    Sleep($interval2)
    MouseMove(744, 959) ;1
    MouseClick("left")
    Sleep($interval2)
    MouseMove(922, 596) ;2
    MouseClick("left")
    Sleep($interval2) ;3
    MouseClick("left")
    Sleep($interval2) ;4
    MouseClick("left")
    Sleep($interval2) ;5
    MouseClick("left")
    Sleep($interval2) ;6
    MouseMove(1462, 725)
    MouseClick("left")
    Sleep($interval2) ;1
    MouseMove(1071, 531)
    MouseClick("left")
    Sleep($interval2) ;2
    MouseClick("left")
    Sleep($interval2) ;3
    MouseClick("left")
    Sleep($interval2) ;4
    MouseClick("left")
    Sleep($interval2) ;5
    MouseClick("left")
    Sleep($interval2) ;6
    MouseMove(1681, 427)
    MouseClick("left")
    Sleep($interval5)
    Send("a")
    Sleep($interval5)

Essentially i'm wondering if there is anyway to run a mouseclick at a duplicative of itself. like 20 times without writing it 20 times.

Also as my first coding syntax i've tackled in quite a long time i'd like to say I love autoit's simplicity. :ILA2:

Edited by cbriggs77

Share this post


Link to post
Share on other sites



cbriggs77, can you give us an idea of what you're trying to automate? I guarantee you there is a better way to do it than all those MouseClicks, whatever it is.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

you can always build your own function with the parameters you wish to vary.

_MouseClick("left"  , 531, 447 , 2000 , 5)


    Func _MouseClick($button , $xCoord , $yCoord , $sleep , $repeat)

    For $i = 1 to $repeat
    tooltip ("Clicking the " & $button & " button " & $i & " of " & $repeat & " times at " & $xCoord & "," & $yCoord & " with a sleep of " & $sleep & "ms inbetween each click" , 0 , 0)
    MouseClick($button , $xCoord, $yCoord)
    Sleep($sleep)
    Next


    EndFunc

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

cbriggs77, can you give us an idea of what you're trying to automate? I guarantee you there is a better way to do it than all those MouseClicks, whatever it is.

It is probably to do with the topic that got closed earlier. I can't compare the code as it was removed when the topic was locked.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

 

you can always build your own function with the parameters you wish to vary.

_MouseClick("left"  , 531, 447 , 2000 , 5)


    Func _MouseClick($button , $xCoord , $yCoord , $sleep , $repeat)

    For $i = 1 to $repeat
    tooltip ("Clicking the " & $button & " button " & $i & " of " & $repeat & " times at " & $xCoord & "," & $yCoord & " with a sleep of " & $sleep & "ms inbetween each click" , 0 , 0)
    MouseClick($button , $xCoord, $yCoord)
    Sleep($sleep)
    Next


    EndFunc

I was essentially looking for help on how to repeat certain parameters, like 

boththose

showed. That is tremendously helpful. so if i were to input this into my code file, i'd have to speify what variables 

$repeat are and variable $sleep  earlier in the script ?

Share this post


Link to post
Share on other sites

I think you only need to specify it when you call the function (but not sure, I didn't use my own function for a time now)

Also MouseClick("left") = MouseClick("") Since the default is left click.

Share this post


Link to post
Share on other sites

I think you only need to specify it when you call the function (but not sure, I didn't use my own function for a time now)

Also MouseClick("left") = MouseClick("") Since the default is left click.

OH that is useful as well! cuts down on writing left so many times, xD

You guys are really helpful! thanks so much!

Share this post


Link to post
Share on other sites

Still curious why you are forced to use mouseclicks. The script will never be stable if that is all you're basing it on.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

cbriggs, based on the PM you sent me (below) along with your other posts, you know by now this is against the forum rules.


Hey i was just wondering what you were talking about when you said. " Still curious why you are forced to use mouseclicks. The script will never be stable if that is all you're basing it on."

Essentially I am moving a character around, the game uses the unity engine, and I move my character around from the starting position, and he runs to mineral veins, mines them, runs back and banks the minerals, goes to starting position and returns to minerals, rinse, repeat. i can send you the whole code if you want. it's for a game called, "Albion Online"

I'm still trying to learn how i would do an image search so i can auto attack monsters in the area, but only monsters and than return to mining. : I'm very new at autoit, but I am enjoying the coding portion VERY much. :) If you have anywhere you think I could read u p that would help me, it would be greatly appreciated.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

cbriggs77,

You have >already been pointed to the Forum rules so there is no excuse for starting a second thread. Please do NOT start a third - our patience has limits. :naughty:

M23


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
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0