jaxclain Posted August 24, 2019 Posted August 24, 2019 Hi There, Im trying to create a function to search for Multiple Images or Pixels, once its found then move mouse and click and if it doesn't finds any of the Pixels or Images, then repeat the search until it finds something but Im new to Autoit.. iv been struggling learning watching youtube videos.. and copying what other people is doing then adjusting it to my needs but as you may guess.. im bad.. lol Here is what I am using so far.. but sometimes it returns this error: "Array variable has incorrect number of subscripts or subscript dimension range exceeded". $left = 703 $top = 264 $right = 1170 $bottom = 709 Local $colors[26] = [ 0x697F13, 0x98A508, 0x282828, 0xFEFEFE, 0x1F1F1F, 0xCDCDCD, 0x442B2C, 0xDD552D, 0xE73C00, 0xDC4E13, 0xCC0909, 0xEFEFEF, 0xF30000, 0x262525,0xF9A4FA, 0xEF94F1, 0x676E17, 0xFBFBFB, 0xAEA118, 0x2F382C, 0x252525, 0x4C3D27, 0x868686, 0x342C25, 0x409BBE, 0x42513E ] Sleep(2000) HotKeySet("{ESC}","qt") While 1 For $i = 0 To 26 $c=PixelSearch($left, $top, $right, $bottom, $colors[$i]) If IsArray($c) Then MouseMove($c[0],$c[1],0) Sleep(1000) MouseClick("left") Sleep (4000) EndIf Next WEnd Func qt() Exit EndFunc I wish I could understand the Imagesearch to do the same function but the Imagesearch didnt work for me... only the Pixelsearch... and still get the Array variable error sometimes lol Anyone can help me figure out what I want to do?
seadoggie01 Posted August 24, 2019 Posted August 24, 2019 You're looping through the colors array which has 26 elements total... (from 0 to 25), but your loop also tries 26, which doesn't exist I find it's much easier to use the size of the array... like this: ;~ "For each array element (UBound returns 26, and you need 0 to 25, so we subtract 1)" For $i=0 to UBound($array) - 1 ;~ "Your array code" Next jaxclain 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
FrancescoDiMuro Posted August 24, 2019 Posted August 24, 2019 @jaxclain There are for sure many other ways to do whatever you're trying to do, instead of using ImageSearch. What kind of application are you trying to automate? jaxclain 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
jaxclain Posted August 25, 2019 Author Posted August 25, 2019 22 hours ago, seadoggie01 said: You're looping through the colors array which has 26 elements total... (from 0 to 25), but your loop also tries 26, which doesn't exist I find it's much easier to use the size of the array... like this: ;~ "For each array element (UBound returns 26, and you need 0 to 25, so we subtract 1)" For $i=0 to UBound($array) - 1 ;~ "Your array code" Next Thanks @seadoggie01 I will try that didnt know it would count 0 lol @FrancescoDiMuro Im doing a macro for a very old game I play on bluestacks, its called Orna RPG, the graphics are very OLD but I love the game and I am not able to play much because I have the carpal tunnel so yea.. im not able to enjoy as much as I would like from any game... Im trying to search in a small area of my screen: $left = 703 $top = 264 $right = 1170 $bottom = 709 for a variety of mobs so once it finds 1.. it will move and click once... also I would love to restrict an area in the middle... its somewhere 938, 507 so it will not search around that area but still im not even able to understand completely the pixelsearch function. I tried using the ImageSearch by taking a screenshot of all the different mobs but yea... i couldnt make it work Thanks in advance!! i love learning autoit... i have a feeling.. in the future I will be using it a lot at work.. doing tasks I do daily Regards
Developers Jos Posted August 25, 2019 Developers Posted August 25, 2019 Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. The Moderation team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts