Scinner Posted January 14, 2008 Share Posted January 14, 2008 Hi all, Now I've been at the computer for 2 hole days and I still cant get the hang of all thoose IF staments. As you will see Im at the beginners level of AutoIt scripting. Had a go at it a couple of months ago and liked it very much. But then my job started and I just had no time over. Now Im unemployed for 2 months until my season based job starts again and what better way to spend it than with AutoIt Could someone please help me with this script, preferably before I throw AutoIt and my computer out the window $Coord = PixelSearch(582, 582, 299, 299, 0x9CDFFF) ; If @error Then ; correct/incorrect? I want it to search for that pixel color until it apears. And then move on to the next PixelSearch ; PixelSearch( 596, 596, 299, 299, 0x9CDFFF ) ; And then the same here, search until it apears and then next. If @error Then ; ; PixelSearch( 604, 604, 299, 299, 0x9CDFFF ) ; And finally the last one. When it finds the last one it will do a series of mousemoves. If Not @error Then ; As you can see Im a no good at this, especially If statements. Dont know if it need loops? MouseClick( "left", 12, 12, 1) ; Would very much appreciate filling in the blanks! EndIf Link to comment Share on other sites More sharing options...
SpookMeister Posted January 14, 2008 Share Posted January 14, 2008 Think more linearly about what you are trying to do. When the script runs what do you want to happen? Are you trying to trigger off of a situation whenever three different pixels are certain colors? - If that is the case then yes, you will want a loop. PixelSearch returns co-ordinates of the first pixel to match your search request within the grid that you specify, perhaps PixelGetColor is more along the lines of what you want to use. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Scinner Posted January 14, 2008 Author Share Posted January 14, 2008 (edited) Could it be as simple as this? $t1 = PixelGetColor(582, 299) $t2 = PixelGetColor(596, 299) $t3 = PixelGetColor(604, 299) If Hex($t1, $t2, $t3, 6) = "0x9CDFFF" Then MouseClick("Left", 790, 710, 2) EndIfoÝ÷ Øêéz¸Z¦Ç¯z{aÆ®¶sbb33c·CÒVÄvWD6öÆ÷"S"Â#¢b33c·CÒVÄvWD6öÆ÷"SbÂ#¢b33c·CÒVÄvWD6öÆ÷"cBÂ#¢bWb33c·CÂbÒgV÷C³4DddbgV÷C²FVà¤Ö÷W6T6Æ6²gV÷C´ÆVgBgV÷C²ÂsÂsÂ"¤VæD` Edited January 14, 2008 by Scinner Link to comment Share on other sites More sharing options...
SpookMeister Posted January 14, 2008 Share Posted January 14, 2008 (edited) In your first example I don't think you are using Hex correctly, and I still don't know what you are really trying to do, so I can't help you yet. In your second example you are effectively overwriting $t1 each time you use the PixelGetColor() function. This is probably not desired. Explain the conditions that you are looking for to perform the mouseclick and we can help you out. Edited January 14, 2008 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Scinner Posted January 14, 2008 Author Share Posted January 14, 2008 (edited) This is what I want to get out of it. When a countdown clock have reached a specific time (0:00:59) I want AI to click a specific button. EDIT: Got it to work correctly with this code: While 1 $t1 = PixelGetColor(582, 299) $t1 = PixelGetColor(596, 299) $t1 = PixelGetColor(604, 299) If Hex($t1, 6) = "9CDFFF" Then MouseClick("left", 790, 710, 1) EndIf WEnd Thank you for getting me of that dumb code I was on! Edited January 14, 2008 by Scinner Link to comment Share on other sites More sharing options...
SpookMeister Posted January 14, 2008 Share Posted January 14, 2008 Something like this then: While 1 $t1 = PixelGetColor(582, 299) $t2 = PixelGetColor(596, 299) $t3 = PixelGetColor(604, 299) If $t1 = "0x9CDFFF" And $t2 = "0x9CDFFF" And $t3 = "0x9CDFFF" Then MouseClick("Left", 790, 710, 2) ExitLoop EndIf WEnd [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Scinner Posted January 14, 2008 Author Share Posted January 14, 2008 Something like this then: While 1 $t1 = PixelGetColor(582, 299) $t2 = PixelGetColor(596, 299) $t3 = PixelGetColor(604, 299) If $t1 = "0x9CDFFF" And $t2 = "0x9CDFFF" And $t3 = "0x9CDFFF" Then MouseClick("Left", 790, 710, 2) ExitLoop EndIf WEnd No EXACTLY like that. (Missed the ExitLoop. But works fine without the "AND"s, should I put them in annyways? Link to comment Share on other sites More sharing options...
SpookMeister Posted January 14, 2008 Share Posted January 14, 2008 Without the ands you are only checking 1 pixel... if that is a good enough condition for your needs than no you don't need them. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Scinner Posted January 14, 2008 Author Share Posted January 14, 2008 Ok. Thank you for all your help! 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