Jump to content

Best method to test area for color


Go to solution Solved by junkew,

Recommended Posts

What exactly are you looking for it to do, that way we can figure out what it is you need to use to get there.

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

Link to comment
Share on other sites

For any window that resizes internal content I could only figure out a way to test with getpixelcolor() that was unreliable. I am sure this is a common problem.

Have you thought oif hooking directly into the control? That way it makes no difference what size the window is.

Link to comment
Share on other sites

#include <Debug.au3>
_DebugSetup()
call(testpixelsearch())
Func testpixelsearch()
    local $aarray= MouseGetPos()
    local $color= hex(PixelGetColor($aarray[0] , $aarray[1]))
    local $shadecycle=1
    while (0=PixelSearch($aarray[0]-5,$aarray[1]-5,$aarray[0]+5,$aarray[1]+5,$color,$shadecycle))
        $shadecycle=$shadecycle+1
        _DebugOut($shadecycle & ", " & $color & ", " & $aarray[0] & ", " & $aarray[1])
    WEnd
Endfunc

Sometimes finds in one iteration sometimes in 40 sometimes in 249. Anything wrong with my code? How does pixelsearch work exactly? Same color gets same results.

Edited by undefinedspace
Link to comment
Share on other sites

PixelSearch is using an DEC value as color afaik. But yours is HEX.

#include <Debug.au3>
_DebugSetup()
call(testpixelsearch())

Func testpixelsearch()
    Local $aarray = MouseGetPos()
    Local $color = PixelGetColor($aarray[0], $aarray[1])
    Local $shadecycle = 1
    Do
        PixelSearch($aarray[0] - 5, $aarray[1] - 5, $aarray[0] + 5, $aarray[1] + 5, $color, $shadecycle)
        If @error = 0 Then ExitLoop
        $shadecycle += 1
    Until 1
    _DebugOut($shadecycle & ", " & $color & ", " & $aarray[0] & ", " & $aarray[1])
EndFunc   ;==>testpixelsearch

This works like a charm for me. Always on the first shadecycle whereever my mouse hovering over.

Edited by bootybay
Link to comment
Share on other sites

I feel like I repeat this about twice a month lately.

Hex numbers and Decimal numbers are identical, they're just different ways to present the exact same information. If you search for the value 0x0000FF or the value 255, as long as you treat them both as numbers, you'll find your match.

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

Link to comment
Share on other sites

Thanks BB. Two programing tips AND your code works perfect! Why? Its not the hex. While we wait for me to come up with new and exciting bizarre behavior, is there any way to get '?do=embed' frameborder='0' data-embedContent>> FastFind installed in Autoit properly or should i just keep a copy of everything in a folder with each new script?

'?do=embed' frameborder='0' data-embedContent>> worked too.

Edit: BB is wrong. im stupid for not checking right away

Edited by undefinedspace
Link to comment
Share on other sites

is there any way to get '?do=embed' frameborder='0' data-embedContent>> FastFind installed in Autoit properly or should i just keep a copy of everything in a folder with each new script?

You can create a custom Include directory for the include.au3

http://www.autoitscript.com/wiki/Adding_UDFs_to_AutoIt_and_SciTE

You'll still need to copy the dll to each of your scripts, there's no (good) way around that.

Link to comment
Share on other sites

You are trying to search for a color under the mouse for a match within an area 10x10 centered under the mouse

shouldnt that always be TRUE?

but bootybay wrote it much cleaner. check how he did the error checking vs how ou did it.

Link to comment
Share on other sites

#include <Debug.au3>
_DebugSetup()
call(testpixelsearch())
Func testpixelsearch()
    Local $aarray = MouseGetPos()
    Local $color = hex( PixelGetColor($aarray[0], $aarray[1]))
    Local $shadecycle = 1

    Do
        _DebugOut($shadecycle & ", " & $color & ", " & $aarray[0] & ", " & $aarray[1])
        PixelSearch($aarray[0] - 50, $aarray[1] - 50, $aarray[0] + 50, $aarray[1] + 50, $color, $shadecycle)
        ;If @error = 0 Then ExitLoop
        $shadecycle += 1
    Until 1
    _DebugOut($shadecycle & ", " & $color & ", " & $aarray[0] & ", " & $aarray[1])
EndFunc   ;==>testpixelsearch

when exitloop line is commented until still runs only once. need something like until (false)

then everything except pixelsearch works like planned.

junkew helped but in the end all was solved by googlefu.

Edited by undefinedspace
Link to comment
Share on other sites

Do loops will run at least once until the Until statement equals True, in your case it runs once because you placed a true statement as the Until condition. This is exactly opposite of the While statement, which will run until the condition is False. If the condition being checked starts as false, the While loop will not run at all

The help file clearly explains this as it states:

 

The statements in between Do...Until are executed until the expression is true.

There's no need for further explanation.

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

Link to comment
Share on other sites

You're not making sense, you just agreed with me?

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

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...