Jump to content

Help with condensing code.


 Share

Recommended Posts

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

  • Moderators

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

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

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


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

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

Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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