Sign in to follow this  
Followers 0
Redundant

Using an array with PixelSearch

3 posts in this topic

#1 ·  Posted (edited)

I'm using a multi-dimensional array to hold the coordinates of the area I want to PixelSearch to use. However, PixelSearch is finding the pixel even when it isn't there. I've either handled the array wrong, or I'm using PixelSearch wrong.

Global $slots[9][4] = [[464, 690, 494, 720], [506, 690, 535, 720], [544, 690, 575, 720], [584, 690, 615, 720], [624, 690, 655, 720], [664, 690, 695, 720], [704, 690, 735, 720], [744,690,775,720],[784,690,815,720]]
HotKeySet("{m}","findcoord")
HotKeySet("{ESC}", "On_Exit")

; Now keep the script active
;MC HWhd = 0x000602F0
While 1
Sleep(10)
WEnd

Func findcoord()
Local $i
For $i = 0 To UBound($slots, 1) - 1
$coord = PixelSearch($slots[$i][0], $slots[$i][1], $slots[$i][2], $slots[$i][3], 0x173933, 0, 2, 0x000602F0)
If @error Then
MsgBox(0,"Error","Missing Pixel")
Else
MouseWheel("down")
MsgBox(0,"Good","Pixel Found")
EndIf
Next
EndFunc

Func On_Exit()
Exit
EndFunc
Edited by Redundant

Share this post


Link to post
Share on other sites



A window's handle will change every time a program is run, you should be trying to get the window's handle before you run the pixelsearch instead of hardcoding the incorrect number in your script.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Okay, that helped a lot. I have it working now, it was acting very weird.

Share this post


Link to post
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
Sign in to follow this  
Followers 0