I find it very weird:
if I run like this:
Local $aCoord = PixelSearch($posX, $posY, $sizeX, $sizeY, '0xFF455E')
works fine!
If I run like this:
Local $metaColor1 = '0xFF455E' or like this Local $metaColor1 = "0xFF455E" or Local $metaColor1 = "'0xFF455E'"
Local $aCoord = PixelSearch($posX, $posY, $sizeX, $sizeY, $color)
it doesn't want to work! So something with variable is not working and yes if I print it out like this:
ConsoleWrite(@LF & $posX & ":"& $posY & ":"& $sizeX & ":" & $sizeY & ":" & $color&@LF)
771:80:833:151:0xFF455E
So I dont see the problem, maybe some of you people?

I need help about pixel search. The problem with the script below is that PixelSearch does not continue on the coordinates where it has stopped.
When the first pixelsearch finds the 1st pixel, it should move the mouse over it and new pixels would appear just like hovering over menus. Then upon hover, there would be another PixelSearch to see if the second red pixel is found. If not found, then it should resume the first PixelSearch instead of starting from left to right again.
For example we are doing a pixelsearch on two straight lines with coordinates [x,y] :
[0,0] [1,0] [2,0]
[1,0] [1,1] [1,2]
Pixelsearch finds the coordinate [1,0] matching our color. So it checks the pixel just below it which is [1,1] to see if it is color red. If not red then it should continue searching starting on coordinates [2,0] instead of going back to [0,0]
Local $bflag = False
Do
ToolTip("finding..",0,0,"")
Sleep(500)
$var = PixelSearch(591, 169, 1365, 740, 0x464950,50) ; look for initial pixel
If Not @error Then ;
MouseMove($var[0],$var[1],0) ;move on the button to show new selections, new pixels
sleep(1000)
;search for the red pixel on an area above the first pixel coords which was
;generated when mouse cursor was hovered on the first pixel found.
$redpixel = PixelSearch($var[0]-50,$var[1]-50,$var[0]+50,$var[1]+50,0xFF0048)
If Not @error Then ; Found the 2nd pixel
ToolTip("found...",0,0,"")
$bflag = True
EndIf
EndIf
Until $bflag
I can pay 50USD through Paypal for a working solution. thanks

Hello, I am new to both Programming and this forum. I have done a few tiny projects that were successful and fell in love with Autoit. So now I am trying to learn new things as I go. I have read the Help docs on my following question, I have gone thru all of that. and I am sure as soon as you see my code you will be saying OMG why did he do that, or OMG how can you forget to add this.. But when your new you take the path of least resistance to get the outcome you want.
SETUP:
I am trying to make a code that will open a piece of software, then open a browser (which has a handful of tabs already open) go to a web page (one of the tabs) and search an area of the web page for a specific color, if that color is found I want it to close the browser and go back and start again. If that color is not found on that page I want it to switch tabs and search that page for the color. If the color is found on that page I want it to close the browser and start again. If the color is not found on either page, I want it to open another browser and go to website and do some things I will add once i get past this obstacle.
I already have it almost there my code will open my software, open the browser, do the searches, find or not find the color, the part I am having trouble with is the if and else and what happens if and what it does if it does not. So the first code I have does everything I want except if it finds the color on the first run it closes the browser, but then when it starts the process again it doesnt check for the color. its like it skips the scanning part and goes straight to the opening of the second browser and finishes the code.
Run( "C:\Programs\myprogram.exe", "", @SW_SHOWDEFAULT )
Sleep(4000)
MouseClick("left", 613,272) ;click in program
Sleep(500)
Example()
Func Example()
MouseClick("left", 632,456) ;click in program
Sleep(500)
MouseClick("left", 527,456) ;click in program
Sleep(15000)
Run( "C:\Programs\browser1.exe", "", @SW_SHOWMAXIMIZED )
Sleep(Random(4000,6000))
EndFunc ;==>Example
MouseClick("left", 162,14) ;switch tab
Sleep(Random(5000,8000))
MouseClick("left", 354,14) ;switch tab
Sleep(Random(5000,8000))
$aCoord = PixelSearch(873, 485, 900, 600, 0xDD0000, 10) ;search for color
If Not @error Then
MouseClick("left", 1338,6) ;close browser1
Sleep(1000)
Call("Example")
Else
MouseClick("left", 162,14) ;switch tab
Sleep(1000)
EndIf
MouseClick("left", 162,14) ;click tab again just to be sure its loaded
Sleep(4000)
$aCoord = PixelSearch(1052, 308, 1120, 431, 0xFF0000, 10) ;search for this color
If Not @error Then
MouseClick("left", 1338,6) ;close browser1
Sleep(1000)
Call("Example")
Else
Run( "C:\Programs\browser2.exe", "", @SW_SHOWMAXIMIZED )
Sleep(2000)
EndIf
MouseClick("left", 134,45) ;click on address bar
Sleep(1000)
Send("aspecificwebpage.com") ;input website
Send("{enter}") ;hit enter
Sleep(15000)
MouseClick("left", 1338,6) ;close browser2
Sleep(500)
MouseClick("left", 1338,6) ;close browser1
Sleep(500)
MouseClick("left", 625,454) ;click in program
Sleep(500)
MouseClick("left", 634,271) ;click in program
Sleep(500)
MouseClick("left", 917,245) ;close program
Sleep(500)
SO it makes the first scan and is successful, if the color is found it closes as I want, but then when nit starts the code again it does not scan anything the second time.
and on the other side, if the color is not found naturally everything works as it is written.
I want to guess by all the weird colors in the code sniplet I have a massive amount of errors. It is like a rainbow of text up there. different from what i see in AutoIT
Any help would be appreciated.

I had this problem with PixelGetColor not giving me the same HEX Color as the AU3Info Tool and searched every were with no luck then had a OH DA moment LoL.
The problem is that the
"PixelGetColor ($mouseX[0], $mouseY[1])"
is looking rite at the very tip of the mouse pointer not under it. So you have to set a -3 after the [0] and [1].
"PixelGetColor ($mouseX[0] -3, $mouseY[1] -3)"
to make it search next to the pointer not on the pointer. You may have to adjust this a bit for your display but you should not have to go more then -5. -3 seems to work best for me.
Example.au3
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 141, 127, 276, 231)
$Input1 = GUICtrlCreateInput("", 8, 8, 121, 21)
$Label1 = GUICtrlCreateLabel("Press or Hold F1 to get Hex color at Mouse X -3, Y-3 Pos,", 8, 40, 124, 73)
GUISetState(@SW_SHOW)
HotKeySet("{f1}","MousePos")
Func MousePos()
$aPos = MouseGetPos()
$PGC = PixelGetColor($aPos[0] -3, $aPos[1] -3)
GUICtrlSetData($Input1, "0x" & Hex($PGC, 6))
EndFunc
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Hello,
I've wrote a fairly straight forward script that will search an area of the screen and then left click on apart of that area should it find a certain color/pixel.
I have a small issue where by within the area, multiple pixels of the same color will appear, the script will continue to click on the same pixel over and over again. Is there a way so that it will cycle through all the results and click on each one for a given time period then move onto the next, as apose to clicking on the same spot forever. I have used timers before and that shouldn't be an issue, its more the having it stop clicking, or ignoring the current pixel its clicking and then moving onto the next one (same pixel color within same area).
Hopefully this makes sense.
[autoit]
HotKeySet("{ESC}", "END_EXIT")
HotKeySet("+1", "start")
While 1
Sleep(100)
WEnd
func start()
while 1
$location = PixelSearch( 631, 175, 1181, 597, 0xFF0000)
If IsArray ($location) = 1 Then
MouseClick ('left', $location[0], $location[1], 1, 0)
EndIf
WEnd
EndFunc
func END_EXIT()
Exit
EndFunc
[/autoit]

Greetings,
Func pixelHunter ()
Local $PixelHunt[2]
Do
$PixelHunt = PixelSearch (1, 1, 1016, 874, "0xCCE4CC", 0, 1, $sWorkOrderWin)
Until $PixelHunt[0] > 0
EndFunc
So when I call up this function in my app it fires back "Subscript used on non-accessible variable"
Now, if I am understanding this message properly it is trying to tell me that the variable can't be seen by the function asking for it.
I replaced "Do...Until" with simply a "ConsoleWrite" the $PixelHunt value and it doesn't throw that error.
Any advice would be appreciated!
-Reiz

I have a need to make the mouse push down the the left button and trace a shape that goes in all directions . If it can follow the line in a full circle I'd be set. I'm not concerned with the left mouse down, I have that figured out for later. My problem is having the cursor follow a circle in paint. It'll follow some but I think it's going toward 0,0 I'm guessing but falls off once it gets to a certain point.
I've searched, I've tried several methods. This code below has been the simplest that works close but won't follow a full, or half circle. It just falls off.
More detail that you need but if you've ever seen contour lines on a map, that's what I'm ultimately wanting to follow. I'll be doing it on my own images that I create by scanning the water with sonar and making lake maps. I want to put my image on google earth and turn the contour lines into paths so they have latitude longitude data. Tracing them manually is very time consuming and accuracy suffers.
Thank you for any time you spend on this. It would be very helpful.
HotKeySet("{ESC}", "Terminate")
Const $color = 0x000000
Local $start = MouseGetPos()
While 1
$pos = MouseGetPos()
If $pos = $start Then ContinueLoop
$pix = PixelSearch($pos[0] - 5, $pos[1] - 5, $pos[0] + 5, $pos[1] + 5, $color, 5)
If @error = 1 Then ContinueLoop
$start = $pos
MouseMove($pix[0], $pix[1])
Wend
Func Terminate()
Exit
EndFunc

my script is working fine but it mostly clicks only in the sides and corner of green square (which is the first pixels it detects i guess) any idea how can I click the middle area inside of pixelsearch? heres what i done but it wont work $greenbox = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x00FF00)
If isArray($greenbox) then
newX := greenbox[0] + 25
newY := greenbox[1] + 25
MouseMove($newX[0],$newY[1], 0)
MouseClick("Left")

I want to do several Pixelsearches on my Screen to find out if i can find the Chrome Browser ^^
Instead of one big search on the screen i run $pixesearch1,$pixesearch2,$pixesearch3 etc. on a sliced up Screen.
I have done something similar before.. But i wanted to ask if i should use Switch or Select?
Do they only run ONE of their cases? or run as many cases that are True?

While i am waiting for Better Solutions for Finding Multiple @error Cases and React according to them, i am hoping that some1 could explain me what my problem in this (time consuming) function is.. The Idea is that i check for @Errors from the 3 PixelSearch i am doing, and give Message according to it. I am changing Colors In Paint for Every Loop To Test If the Color Searches Are Correct. All Cases are Working Fine, and the Right MsgBoxes are Triggered, Except the Case where all 3 Colors are Missing: HotKeySet("{ESC}", "End")
Global $pixelSearchError1 = @error
Global $pixelSearchError2 = @error
Global $pixelSearchError3 = @error
While 1
Sleep(10)
$pixelsearch1 = PixelSearch(100,300,200,512,0x0000ff,10) ;Blue
$pixelSearchError1 = @error
$pixelsearch2 = PixelSearch(250,310,400,512,0xfa0000,10) ;Red
$pixelSearchError2 = @error
$pixelsearch3 = PixelSearch(500,300,600,512,0x00ff00,10) ;Green
$pixelSearchError3 = @error
Call("_errorcheck")
WEnd
Func _errorcheck()
Sleep(100)
Select ;Check for Blue Color, Then Proceed.
Case Not $pixelSearchError1 ;Found Blue
MsgBox(0,"Message","Blue Pixel Found!")
Select ;Blue Found. Now check for Red
Case Not $pixelSearchError2 ;Found Blue and Red
MsgBox(0,"Message","Blue and Red Pixel Found!")
Select ;Blue and Red found. Now check for Green
Case Not $pixelSearchError3 ;Found Blue, Red and Green
MsgBox(0,"Message","Blue,Red and Green Pixel Found!")
Case $pixelSearchError3 ;Blue, Red But not Green
MsgBox(0,"Message","Found Blue, Red But Not Green")
EndSelect
Case $pixelSearchError2 ;Blue Found, But Not Red
MsgBox(0,"Message","Blue Found, But Not Red")
Select ;Blue and Red found. Now check for Green
Case Not $pixelSearchError3 ;Found Blue, Green But not Red
MsgBox(0,"Message","Found Blue, Green But Not Red")
Case $pixelSearchError3 ;Blue, But not Red or Green
MsgBox(0,"Message","Could only Find Blue")
EndSelect
EndSelect
Case $pixelSearchError1 ;Blue Not Found
MsgBox(0,"Message","Blue Pixel Not Found")
Select ;Blue Not Found. Now check for Red
Case Not $pixelSearchError2 ;Found Red, But not Blue
MsgBox(0,"Message","Found Red, But not Blue")
Select ;Found Red, But not Blue Now check for Green
Case Not $pixelSearchError3 ;Red and Green, but not Blue
MsgBox(0,"Message","Red,Green But not Blue")
Case $pixelSearchError3 ;Red, But not Blue or Green
MsgBox(0,"Message","Could only Find Red")
EndSelect
Case $pixelSearchError2 ;Could not find Blue or Red
MsgBox(0,"Message","Could not Find Blue and Red")
Select ;Blue and Red Not found. Now check for Green
Case Not $pixelsearch3 ;Only found Green
MsgBox(0,"Message","Only found Green")
Case $pixelSearchError3 ;Did not Find Blue,Red or Green
MsgBox(0,"Message","No Color was found")
EndSelect
EndSelect
EndSelect
Sleep(10)
EndFunc I Made a Picture that should make it far easier to see where one Select Case Starts and Ends Check the Link Below. http://imageshack.us/f/9/selectcasegreenerror.gif/ I can't see why the Last Case is not working.. When Blue,Red AND Green are Missing i still get the "Only found Green" Please Help Also, Building the Cases Like this takes up allot of Time and Space, so if you have a Easier way please Tell Like: If Not @error 1 And @error 2 And @error 3 Then But i don't think that Works. I probably want to run 5 PixelSearches and that would mean 5 Select an 32 Cases !!!1!!11 So it would be Great if there was another way of doing this If not, Please do still tell what the problem of my Function is

So i was in need of this custom udf Fastfind Melba23 showed me this great article on AutoIt wiki..http://www.autoitscript.com/wiki/Adding_UDFs_to_AutoIt_and_SciTE and i think i did like it said.. mostly anyway.. I downloaded and unzipped FastFind and placed all files in a new Folder i created in the AutoIt3 Folder The files i placed in the new Folder: <-- Named it FastFind Benchmark.au3 FastFind.au3 FastFind.dll FastFind_Demo.au3 FastFind.dll I think the Benchmark and FastFind_Demo are just examples.. But i don't think they will Hurt by being in there ? They don't have any Dll to them.. and Even though i am not shure about it.. i think you need the dll to include and call the Custom Files from that folder. Correct me if i am wrong So after placing the files in the new Folder, i started SciTE --> SciTE Config --> User Include Dir: C:Program Files (x86)AutoIt3FastFind Save+Apply So can i now #include <fastfind.au3> ? and you the build in functions? I have not tried this yet because i dont know how to use the custom UDF "syntax?"

Hey i am trying to do a PixelSearch on the Screen, in a 3D environment. The Idea is that the PixelSearch "Rotates Arround " In the 3D evironment, until it finds the Color. Then Moves Toward The Color. To accomplish this, i made the PixelSearch Thin, But Tall: PixelSearch(620,0,660,512, 0xFE4335,10) (My resolution is 1280x1024 so the Center of X is 640) Here is My Script: WinActivate("3D Application")
Sleep(5000)
$KeyToPress = "w"
$D_Down = "d"
Global $color = PixelSearch(540,0,740,512, 0xFE4335,50)
Func Spin()
Send ("{"&$D_Down&" DOWN}")
Sleep (200)
Send ("{"&$D_Down&" UP}")
EndFunc
Func WalkDistance()
Send ("{"&$KeyToPress&" DOWN}")
Sleep ($color[1]*2000)
Send ("{"&$KeyToPress&" UP}")
EndFunc
Select
Case Not @error
Sleep(10)
MouseMove ($color[0],$color[1],10)
Call("WalkDistance")
Case @error
Sleep(10)
Call("Spin")
Case Else
MsgBox(0,"Error","Error")
EndSelect
MsgBox(0,"Message","Done") The First Case Works, But is not Shutting Down. The Second Case Steps in when there are no Pixels of that Color, and Rotates I want to Repeat the Select until the Application Window is No Longer The Active window. How can i Repeat The Select Case? Can i Run a Select Case inside a Select Case by using If ... Then ? Is Select Case a Good Way to Make a Programm work with Diffrent Scenarios (Cases) or is there a better way? This Language is Fast and fun to Learn !

Hey guys (and girls if any ^^) I've started Playing around with PixelSearch, and after being shocked that it is not using X,Y i found it far smarter^^ For the Simple Version: I need to PixelSearch the Screen for a Color. And Then Move the Mouse to that place. Sleep(3000)
$Color = PixelSearch(0, 0, 1000, 1000, 0xE94434, 10)
If Not @error Then
MouseClick("left", $Color,$Color)
Else <- The Variable For the Mouse is also Not Working How can i move the Mouse to a Variable instead of Set Cordinates? Advanced: There is more than one Pixel of The Color. And There will Most Likely Be More Than One Area With Them on the Screen, but the Mouse is only Supposed To Move to One Area with the Pixels. So i think i will split the The Screen Into a Grid and Run the PixelSearch Function Until i Find One Window with The Color. $Color = PixelSearch(0, 0, 100, 100, 0xE94434, 10)
If Not @error Then
Else MORE ADVANCED ! I need the Script to "Understand 3d" So i need to Calculate the Range between The Pixelsearch Window and the Center of The Screen. Got any Help for me:) ? Pieces of Script, Tutorials, articles ? Thx for the Help !