Jump to content

Recommended Posts

Posted

With

While 1
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
If IsArray($Coord) Then
MouseClick("left", $coord[0], $coord[1],2)
Else
MouseClick("left",,,2)
EndIf
WEnd

How can I get it to start if I press the 'spacebar'? Cause when I run it, it runs straight away and I don't want it to.

Posted (edited)

I actually think _IsPressed() is better in this situation, it doesn't make the code "better" but a lot more readable:

#include <misc.au3>
Do
    Sleep(50)
Until _IsPressed("20")

; Script continues here:
Edited by monoceres

Broken link? PM me and I'll send you the file!

Posted (edited)

look for HotKeySet in the helpfile

Do I have a function in my code or do I need to set one?

That is what it says I need to put:

HotKeySet("{PAUSE}", "TogglePause")

And how do I stop my script when I want it to stop?

#include <misc.au3>
Do
    Sleep(50)
Until _IsPressed("20")

; Script continues here:

What will ^^^ do?

Edited by Pyrex
Posted

yes you need a function that should start when you press on the key.

to stop your script make HotKeySet("{ESC}", "Terminate")

with this function

Func Terminate()

Exit 0

EndFunc

Posted

yes you need a function that should start when you press on the key.

to stop your script make HotKeySet("{ESC}", "Terminate")

with this function

Func Terminate()

Exit 0

EndFunc

Which function do I choose because it's got PixelSearch and MouseClick

Posted

Monoceres already posted the solution...it will get caught in a loop until the spacebar is hit, then the rest of the script will run. Come on people this is not rocket science.

Posted

Monoceres already posted the solution...it will get caught in a loop until the spacebar is hit, then the rest of the script will run. Come on people this is not rocket science.

ok but where do i put it and what does it do?

Posted

ok but where do i put it and what does it do?

At the top! You said you didn't want anything to happen until after the keypress!

Posted

This what was monoceres said and it should work. I've put it in the loop for you and make continue until you press the spacebar again.. if you want it to be deactivated by another key, then look in the misc.au3 to see which ID the key has..

#include <misc.au3>
While 1
    Do
        Sleep(50)
    Until _IsPressed("20")
    
    Do  
        $coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
        If IsArray($Coord) Then
            MouseClick("left", $coord[0], $coord[1],2)
        Else
            MouseClick("left","","",2)
        EndIf  
    Until _IsPressed("20")
WEnd

Regards

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
×
×
  • Create New...