Orcc Posted April 1, 2009 Share Posted April 1, 2009 I'm kinda new to auto it but, it seems this is something I am willing to learn I wrote a simple script to do the following things move the mouse to a certain color,then left click, send key f1. Then send key E. But I been testing it over and over and modifying it but it doesn't seem to workCan someone hep review it and tell me what I'm doing wrong?Below is the script. Also how do I set pause to be infinite?Global $PausedHotKeySet("{End}", "ExitProg") ;;To exit the progamHotKeySet("{Home}", "StartProg") ;;To start the programHotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpauseWhile 1 Sleep(100) ;;;Waits for function call WendFunc StartProg() $coord = PixelSearch( 0, 0, 1024, 768, 0x0c0d0d )If Not @error ThenMouseClick ( "Left")send("{F1}")send("{e}")EndIfEndFuncFunc TogglePause() $Paused = NOT $Paused While $Paused sleep(1000000) WEndEndFuncFunc ExitProg() Exit 0 ;;;Exits the programEndFunc Link to comment Share on other sites More sharing options...
maqleod Posted April 1, 2009 Share Posted April 1, 2009 I don't see where you are actually moving the mouse to the coordinates that you find with pixelsearch() your click should reference those coordinates, like so: MouseClick("Left",$coord[0],$coord[1]) [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
Orcc Posted April 2, 2009 Author Share Posted April 2, 2009 I was under the impression it would move the mouse to find that color? If that is false, can you steer me to the right path? where should i go to read up on it?Knowledge is life. Link to comment Share on other sites More sharing options...
maqleod Posted April 2, 2009 Share Posted April 2, 2009 I was under the impression it would move the mouse to find that color? If that is false, can you steer me to the right path? where should i go to read up on it?Knowledge is life.pixelsearch() just scans an area of the screen for the pixel information provided and returns coordinates of the given pixel if it finds it.the code I provided above using mouseclick() will move the mouse to the coordinates returned by your pixelsearch before it clicks. [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
Orcc Posted April 2, 2009 Author Share Posted April 2, 2009 So i redid the code and it wasn't that much different tell me if it's wrong still. now for what i intend for it to perform.Also is there a way to put the program to find more then one color? of so is it just putting more pixel search in?BTW, Thank's for the fast reply's.Global $PausedHotKeySet("{End}", "ExitProg") ;;To exit the progamHotKeySet("{Home}", "StartProg") ;;To start the programHotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpauseWhile 1 Sleep(100) ;;;Waits for function call WendFunc StartProg() $coord = PixelSearch( 0, 0, 1024, 768, 0x0c0d0d )If Not @error ThenMouseClick("Left",$coord[0],$coord[1]) send("{F1}")send("{e}")EndIfEndFuncFunc TogglePause() $Paused = NOT $Paused While $Paused sleep(1000000) WEndEndFuncFunc ExitProg() Exit 0 ;;;Exits the programEndFunc Link to comment Share on other sites More sharing options...
Authenticity Posted April 2, 2009 Share Posted April 2, 2009 sleep(1000000) Use @DesktopWidth and @DesktopHeight instead of fixed values. You can make array of colors and pass each in a loop to the PixelSearch() function. Link to comment Share on other sites More sharing options...
Orcc Posted April 2, 2009 Author Share Posted April 2, 2009 Yeah I wondering how to set the sleep, to infinite till I unpause. So I set it to 1000000. still looking that info up. Quote Authenticity "You can make array of colors and pass each in a loop to the PixelSearch() function" Can you show me where to look, on how to loop it. The array of colors doe's it range from" A to Z" or it's pre-set like 0x1ag6agd oxa4dfad ox156446 preset it that way? let me put a sample of what your saying? See if it's correct? Global $Paused HotKeySet("{End}", "ExitProg") ;;To exit the progam HotKeySet("{Home}", "StartProg") ;;To start the program HotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpause While 1 Sleep(100) ;;;Waits for function call Wend Func StartProg() $coord = PixelSearch( 0, 0, 1024, 768, 0x0cafd0 ) $coord = PixelSearch( 0, 0, 1024, 768, 0x0c0d0d ) $coord = PixelSearch( 0, 0, 1024, 768, 0x0fofof ) $coord = PixelSearch( 0, 0, 1024, 768, 0xagager) $coord = PixelSearch( 0, 0, 1024, 768, 0x0fykfsr ) <---Like that? $coord = PixelSearch( 0, 0, 1024, 768, 0x0agrah ) $coord = PixelSearch( 0, 0, 1024, 768, 0x0c0d0d ) $coord = PixelSearch( 0, 0, 1024, 768, 0x0cagah ) $coord = PixelSearch( 0, 0, 1024, 768, 0x0clolia ) If Not @error Then MouseClick("Left",$coord[0],$coord[1]) send("{F1}") send("{e}") EndIf EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(1000000) WEnd EndFunc Func ExitProg() Exit 0 ;;;Exits the program EndFunc Link to comment Share on other sites More sharing options...
Chapi Posted April 3, 2009 Share Posted April 3, 2009 Yeah I wondering how to set the sleep, to infinite till I unpause. So I set it to 1000000. still looking that info up. Global $Paused HotKeySet("{Insert}", "TogglePause");; Key to pause and unpause $Paused = False Func TogglePause() $Paused = Not $Paused while $paused sleep(100) wend EndFunc Link to comment Share on other sites More sharing options...
Orcc Posted April 3, 2009 Author Share Posted April 3, 2009 So making sleep timer to (100) would make it infinite not 100 milliseconds? Well I am going to test it. Thank you. Link to comment Share on other sites More sharing options...
BlackDragonBE Posted April 3, 2009 Share Posted April 3, 2009 No... Making a hotkey that pauses or unpauses your script by checking a variable will do that, and not "infinite", the Sleep(100) sleeps 100ms to have mercy on the CPU. Link to comment Share on other sites More sharing options...
Orcc Posted April 3, 2009 Author Share Posted April 3, 2009 Thanks for clearing that up about the pause issue. Still wondering about the color pixel issue. Should i set a thousand colors to search for or is there and array "range" of Pre-set colors I can set the program to find? Link to comment Share on other sites More sharing options...
Authenticity Posted April 3, 2009 Share Posted April 3, 2009 What are the colors you're looking for? There might be logic behind it so there is no need for thousands array elements. If you want to find 256 variations of green you can query for PixelSearch with shade-variation of 256, for example. Link to comment Share on other sites More sharing options...
Orcc Posted April 4, 2009 Author Share Posted April 4, 2009 What are the colors you're looking for? There might be logic behind it so there is no need for thousands array elements. If you want to find 256 variations of green you can query for PixelSearch with shade-variation of 256, for example.This program is to get a color off a character then I want it to perform a action on that character. So the charater has 20 colors black blue light blue red etc. But i want to be able to get that character info and perform a action on that character. Link to comment Share on other sites More sharing options...
Authenticity Posted April 4, 2009 Share Posted April 4, 2009 Dim $sColors = '0x00FF00FF|0x00CC50D1|0x000000FF|0x0000FF00|0xDEADBEEF|0x78563412|0x00FFFFFF' Dim $aColors = StringSplit($sColors, '|') For $i = 1 To $aColors[0] Local $aPos = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $aColors[$i]) If Not @error Then ; Do something with the coordinate and exit the loop. ExitLoop EndIf Next Link to comment Share on other sites More sharing options...
Orcc Posted April 4, 2009 Author Share Posted April 4, 2009 Dim $sColors = '0x00FF00FF|0x00CC50D1|0x000000FF|0x0000FF00|0xDEADBEEF|0x78563412|0x00FFFFFF' Dim $aColors = StringSplit($sColors, '|') For $i = 1 To $aColors[0] Local $aPos = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $aColors[$i]) If Not @error Then ; Do something with the coordinate and exit the loop. ExitLoop EndIf Next I don't get this? so the loop is wrong? I need the script to run over and over. so it wont exit until. I give the command. So with autoit dim colors what does that do? Link to comment Share on other sites More sharing options...
Authenticity Posted April 4, 2009 Share Posted April 4, 2009 If you want it to run until you'll stop it just wrap it in an outer loop and set a hot-key to stop it. HotKeySet('{ESC}', '_EXIT') . . . While 1 ; Inner while loop. Sleep(50) WEnd Func _EXIT() Exit EndFunc The string with the pipes - '|' is for clarity and simplicity so you don't have to declare an array variable and assign each color like: $aColors[0] = 0x0000FF00 ; Green $aColors[1] = 0x00FF0000 ; Red ... etc. Link to comment Share on other sites More sharing options...
Orcc Posted April 4, 2009 Author Share Posted April 4, 2009 If you want it to run until you'll stop it just wrap it in an outer loop and set a hot-key to stop it. HotKeySet('{ESC}', '_EXIT') . . . While 1 ; Inner while loop. Sleep(50) WEnd Func _EXIT() Exit EndFunc The string with the pipes - '|' is for clarity and simplicity so you don't have to declare an array variable and assign each color like: $aColors[0] = 0x0000FF00 ; Green $aColors[1] = 0x00FF0000 ; Red ... etc. The loop process is correct hot key While funcend exit I have those in my script. So the "|" Key will simplify the code so i don't have to type out $coord=0xofofof Over and over. Gotcha. Thanks all the help has been .. well Helpful. Thanks all. 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