Jump to content

Total noob, super easy script


 Share

Recommended Posts

Hi, if i want to create a script that clicks twice with a short time between them (for a doubleclick), wait like two seconds and then click once, wait like half a second and then press alt+f4, wait 2 seconds and then start from the top. What would that script look like? I'm a total noob and not at all familiar with this programing language.

Thx for helping out

Link to comment
Share on other sites

Start by using the help file. Look up MouseClick() and Send().

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Start by using the help file. Look up MouseClick() and Send().

Yeah but the help file doesn't say how you send several buttons at once, like when i want to send alt+f4, it just shows how to send a series of buttons.

The other thing it doesn't show is how to make the script wait for a few seconds (or just count to whatever or something), how do i do these things?

Link to comment
Share on other sites

If you actually read the help file, you would see that the entry on the Send function has a link to the Send Key List entry, where it's shown how to use Send for key combinations.

You can use Sleep for pausing script execution for a period of time. You could have found it by looking at the help file index under: Function Reference->Timer and Delay Management.

Really now... It's obvious you're not even trying. The help file is laid out in an organized manner. It's not like you're digging for treasure.

You can be pardoned for being a noob at coding. You can't claim being a noob at reading though, not unless you are, in which case I'd suggest working on that first before you attempt tackling coding.

Edited by omikron48
Link to comment
Share on other sites

If you actually read the help file, you would see that the entry on the Send function has a link to the Send Key List entry, where it's shown how to use Send for key combinations.

You can use Sleep for pausing script execution for a period of time. You could have found it by looking at the help file index under: Function Reference->Timer and Delay Management.

Really now... It's obvious you're not even trying. The help file is laid out in an organized manner. It's not like you're digging for treasure.

You can be pardoned for being a noob at coding. You can't claim being a noob at reading though, not unless you are, in which case I'd suggest working on that first before you attempt tackling coding.

I haven't found this help file, all i found were some readme's and loads of examples. The examples were helpful, once i knew what to look for (you told me about the sleep function, i was looking for a "wait" or "hold"-command). So thanks for that, my script is working as intended now. But now i've got some new issues, if i start the script to do a loop of say 100 actions, and in the middle i notice shit's going bad, so i need to abort the script. How do i do that?

I found the help file now, i was searching for a file named "help" or w/e, but it was just named autoit. Searched it for stop/pause-functions or buttons and didn't find anything.

Link to comment
Share on other sites

Sleep is the pause/wait command

The script will execute the Sleep until the timer reaches the specified number (in miliseconds)

Sleep(1000)

will make the script do nothing for 1000 ms (1 second)

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Because you are new I made the script with a description on every line.

While 1 ; A loop (repeats what's inside)
    _ClickCurPos(2) ; The double click
    Sleep(2000) ; Wait 2 seconds (it's in milli seconds)
    _ClickCurPos(1) ; 1 click
    Sleep(500) ; Wait half a second
    ;Send('{ALT}{F4}') ; This will send the ALT-F4 keystroke. You might as well use: 
    WinClose('') ; This closes the current window
    Sleep(2000) ; Wait 2 seconds and repeat the whole thing
WEnd

Func _ClickCurPos($clicks=1) ; Func for clicking on the current mouse position
    $_Pos = MouseGetPos() ; Current mouse position
    MouseClick('Left', $_Pos[0], $_Pos[1], $clicks) ; Left mouse button, x-coord mouse, y-coord mouse, amount of clicks
EndFunc

Ludocus

Edited by ludocus
Link to comment
Share on other sites

Because you are new I made the script with a description on every line.

While 1 ; A loop (repeats what's inside)
    _ClickCurPos(2) ; The double click
    Sleep(2000) ; Wait 2 seconds (it's in milli seconds)
    _ClickCurPos(1) ; 1 click
    Sleep(500) ; Wait half a second
    ;Send('{ALT}{F4}') ; This will send the ALT-F4 keystroke. You might as well use: 
    WinClose('') ; This closes the current window
    Sleep(2000) ; Wait 2 seconds and repeat the whole thing
WEnd

Func _ClickCurPos($clicks=1) ; Func for clicking on the current mouse position
    $_Pos = MouseGetPos() ; Current mouse position
    MouseClick('Left', $_Pos[0], $_Pos[1], $clicks) ; Left mouse button, x-coord mouse, y-coord mouse, amount of clicks
EndFunc

Ludocus

Oh, really nice of you. What if i repeat this action like say 1000 times in a script, is there a easy way for me to abort the script while it's doing these clicks and stuff? It's for a voting-thing, i've found a website with where you vote for some stuff and it just disables you from voting again with a cookie. So i set my web browser to clear cookies everytime it get's shut down, and then i make it so that the button to start the web browser and the vote button coincides, and set my browser start page to the specific thing i want to vote for. So then it's useful to just make a script that automaticly spam-votes for me but i haven't found any decent ways to stop the script while running yet. Except for making the sleep-time so long that i can rightclick the icon and choose "exit" on autoit.
Link to comment
Share on other sites

Oh, really nice of you. What if i repeat this action like say 1000 times in a script, is there a easy way for me to abort the script while it's doing these clicks and stuff? It's for a voting-thing, i've found a website with where you vote for some stuff and it just disables you from voting again with a cookie. So i set my web browser to clear cookies everytime it get's shut down, and then i make it so that the button to start the web browser and the vote button coincides, and set my browser start page to the specific thing i want to vote for. So then it's useful to just make a script that automaticly spam-votes for me but i haven't found any decent ways to stop the script while running yet. Except for making the sleep-time so long that i can rightclick the icon and choose "exit" on autoit.

HotKeySet()

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Ok i've worked it out now, and it's going great.

I just wanted to check about the "While 1"-command. Does the number after While matter? Does it just loop what's inside the while-thing until i stop the script, or how long?

As long as the statement after the while evaluates to true it is ok. Once it stops being True then the loop exits.

On a computer: 0 = False, any other number = True. 1 just happens to be the easiest and the one everyone learns. Many languages that have data types use True instead, to avoid the unneccessary conversion from an int to a bool.

Mat

Edit: This is the same as a while loop:

If STATEMENT Then ; Do inner code

If STATEMENT Then ; Do inner code

If STATEMENT Then ; Do inner code

If STATEMENT Then ; Do inner code

If STATEMENT Then ; Do inner code

If STATEMENT Then ; Do inner code

If STATEMENT Then ; Do inner code

If STATEMENT Then ; Do inner code

...

Edited by Mat
Link to comment
Share on other sites

Hmmm you guys seem very smart in the forum...But i've posted a message and provided my code i need help with one forum below this..with a real question that ive tried for weeks to figure out and i only got four views this guy gets 450 in less time then me

Link to comment
Share on other sites

Hmmm you guys seem very smart in the forum...But i've posted a message and provided my code i need help with one forum below this..with a real question that ive tried for weeks to figure out and i only got four views this guy gets 450 in less time then me

Some people only look at certain forums. For example I hardly ever look at 'ActiveX/COM Help and Support (AutoItX)', simply because A) I never use AutoItX and ;) I have no expertise in that area. GUI's are funny because everyone uses them, but few people go into real detail such as using the UDF controls to do more advanced stuff.

Your problem is that you don't have an endif before the until:

Do
        $coord = PixelSearch( 166, 337, 271, 438, 50, 2)
        if Not @error Then
            MouseMove(842, 535) ; Moves to the axe input box
            MouseClick("") ; Clicks Axe input Box
            Send($AxeNumber) ; Types how many axes to train
            MouseMove(941, 563) ; Moves to recruit Button
            MouseClick("") ; Clicks Recruit Button
            MouseMove(310, 305) ; Moves mouse to Next villa Button
            MouseClick("") ; Clicks next villa button
            $OFFvSWITCHED = $OFFvSWITCHED + 1 ; Adds one to howmany times it has switched villas
        Else
            MouseMove(842, 513) ; Moves to Axe inputBox
            MouseClick("") ; Clicks Axe InputBox
            Send($AxeNumber) ; Types Number of how many axes to train
            MouseMove(931, 540) ; Moves to recruit Button
            MouseClick("") ; Clicks recruit Button
            MouseMove(310, 305) ; Moves to next villa button
            MouseClick("") ; Clicks next villa Button
            $OFFvSWITCHED = $OFFvSWITCHED + 1
        EndIF
    until $OFFvSWITCHED = $OFFvNumber

Also, I see some members suspected that your code was against a ToS somewhere... That's a sure way not to get help. The general rule on this forum is that we don't want bots, so we won't help. If you must ask then post code that shows the problem, without the crap.

Link to comment
Share on other sites

Ok, thanks for clearing out the while-command. What if i want to make the script loop this loop for X amount of times or for a specific period of time, is there an easy way for me to do that?

Can i do something with the while-thing then or do i have to rewrite it in a different way?

I could just spam thesame script like 100 times in one script-file to make sure it does that loop 100 times when using that file, but it feels like the wrong way to script it, with like shitloads of extra rows in the script. Intuitively it feels like telling the script to loop something for a specific amount of times should be really easy.

Thanks again for all the help.

Edited by onaqui
Link to comment
Share on other sites

Oh, really nice of you. What if i repeat this action like say 1000 times in a script,... It's for a voting-thing, ... So then it's useful to just make a script that automaticly spam-votes for me ...

Um,... when do we get to discuss the ethics of your actions?

Link to comment
Share on other sites

Um,... when do we get to discuss the ethics of your actions?

Right now, it's a thing where you vote for pieces of art that will eventually be displayed in Stockholm. A friend of mine has a piece of art in the contest and the top 30 will be displayed. Atop of that one of the contributions will be selected and given a scolarship of 25.000 swedish kronor, about 2500 euros.

Anyways, we've written some emails to the holders of the contest and told them about the ability to vote several times and asked them about how they were going to deal with that and some obvious plagiarism going on in the contest. They haven't answered the email in over a week now and several people are obviously abusing this ability to vote several times, so i went ahead and took it to the next level with a script.

Link to comment
Share on other sites

hi i have a question that aproaches to wath is being discused here. i want to do something similar but wath i want is to click once in 1 coord then a second click in a diferent coord with and interval o a second and repeat the process, then stop the script or rather start and end with keys all i did so far was click in just one place i want the cursor to move betwen 2 specific coordenades how can i do that? sorry for my bad english.

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...