Pyrex Posted April 29, 2008 Share Posted April 29, 2008 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 More sharing options...
Pain Posted April 29, 2008 Share Posted April 29, 2008 look for HotKeySet in the helpfile Link to comment Share on other sites More sharing options...
monoceres Posted April 29, 2008 Share Posted April 29, 2008 (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 April 29, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Pyrex Posted April 29, 2008 Author Share Posted April 29, 2008 (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 April 29, 2008 by Pyrex Link to comment Share on other sites More sharing options...
Pain Posted April 29, 2008 Share Posted April 29, 2008 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 Link to comment Share on other sites More sharing options...
Pyrex Posted April 29, 2008 Author Share Posted April 29, 2008 yes you need a function that should start when you press on the key.to stop your script make HotKeySet("{ESC}", "Terminate")with this functionFunc Terminate() Exit 0EndFuncWhich function do I choose because it's got PixelSearch and MouseClick Link to comment Share on other sites More sharing options...
weaponx Posted April 29, 2008 Share Posted April 29, 2008 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. Link to comment Share on other sites More sharing options...
Pyrex Posted April 29, 2008 Author Share Posted April 29, 2008 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 More sharing options...
weaponx Posted April 29, 2008 Share Posted April 29, 2008 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! Link to comment Share on other sites More sharing options...
Pyrex Posted April 29, 2008 Author Share Posted April 29, 2008 i went into the game but nothing happens when i press spacebar Link to comment Share on other sites More sharing options...
newbiescripter Posted April 29, 2008 Share Posted April 29, 2008 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now