Jump to content

Press a key to start the script?


 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

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