Jump to content

i have a question


Recommended Posts

ok i was wandering if auto it could like scan for the green and if found scan for the red and if found pinpoint the center of red

Yes it can scan for colors, but I'm not sure about the pinpointing center. Search for PixelSearch in the help file and/or this forum. PixelSearch searches a rectangle of pixels for the pixel color provided. The syntax is PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] ).

Sorry I don't have any of those topics bookmarked otherwise I'd give you the links.

Link to comment
Share on other sites

ok i was wandering if auto it could like scan for the green and if found scan for the red and if found pinpoint the center of red

Posted Image

If it's simply a rectangular area then the center is just $X = $X + ($Width / 2), and $Y = $Y + ($Height /2). With PixelSearch() and PixelGetColor() the areas are not hard to locate. This doesn't sound hard... what have got so far? Post some code if you're stuck and you'll get plenty of help.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

ok i have tryed to make a script to actavate the window that i have the red

and green pic in. then it scans the cords for PixelSearch and then if it finds red

it gives me a msgbox with title of test and text of yes.

i cant get it give me a msgbox it pops up the window i the pic in but thats it

here is wat i got so far

WinActivate("help - Windows Picture and Fax Viewer", "")

$coord = PixelSearch( 489, 366, 487, 614, 0xFF0000 )

If $coord = 0 Then

MsgBox(0, "test", "yes")

EndIf

Link to comment
Share on other sites

well, I'm pretty tired right now but pixelsearch returns an array so (I'm not sure what coord you want) [0]=X-Pos [1]=Y-Pos

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
Share on other sites

ok i have tryed to make a script to actavate the window that i have the red

and green pic in. then it scans the cords for PixelSearch and then if it finds red

it gives me a msgbox with title of test and text of yes.

i cant get it give me a msgbox it pops up the window i the pic in but thats it

here is wat i got so far

WinActivate("help - Windows Picture and Fax Viewer", "")

$coord = PixelSearch( 489, 366, 487, 614, 0xFF0000 )

If $coord = 0 Then

MsgBox(0, "test", "yes")

EndIf

First, your PixelSearch() coordinates are not formatted correctly. It always searches left-to-right, then top-to-bottom in a rectangular area. To define the search area, you give it left/top corner and right/bottom corners. In your code above, left (489) > right (487).

Second, PixelSearch() returns an array with the coordinates. If you try to treat an array as an integer, you get 0, even if there are other things in the array. So "If $coord = 0" is not a valid test for detection. Read the help file entry on PixelSearch(). The help file and the demo example given will show you how to use it.

Third, how robust does the logic need to be? You might need some more rules to test for. For example:

1. Your code only searches for a red pixel, are you not going to search for the green box first?

2. Will the green rectangle be the only green in the window?

3. Is there a minimum/maximum/changing/fixed size to the rectangles?

Here's a tweak to the code you showed:

WinActivate("help - Windows Picture and Fax Viewer", "")

; Searches a box 3 pixels wide and 249 pixel high:
$coord = PixelSearch( 487, 366, 489, 614, 0xFF0000 )

; Tests if @error was set to see if color was found:
If @error = 0 Then
    MsgBox(0, "test", "Found at: " & $coord[0] & "," & $coord[1])
Else
    MsgBox(16, "test", "Not found.")
EndIf

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

First, your PixelSearch() coordinates are not formatted correctly. It always searches left-to-right, then top-to-bottom in a rectangular area. To define the search area, you give it left/top corner and right/bottom corners. In your code above, left (489) > right (487).

Second, PixelSearch() returns an array with the coordinates. If you try to treat an array as an integer, you get 0, even if there are other things in the array. So "If $coord = 0" is not a valid test for detection. Read the help file entry on PixelSearch(). The help file and the demo example given will show you how to use it.

YaY I beat someone to an answer for once in my life :)...........all the other stuff I didn't really pay attention to >.> Edited by Infinitex0

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...