Color detect in every corner Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
99leeroi99
Posts: 18
Joined: 28 Oct 2021, 03:50

Color detect in every corner

02 Dec 2021, 01:51

Hello I made a script and now I need to upgrade it to find a grey color in my screen and find the 4 corners of it and then calculate to find the center of it if it is possible I've already run test but can't get the corners it only look for grey area then receiving the location of the located grey area
Rohwedder
Posts: 7643
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Color detect in every corner

02 Dec 2021, 02:38

Hallo,
https://www.autohotkey.com/docs/commands/PixelSearch.htm#Remarks
The search order depends on the order of the parameters. In other words, if X1 is greater than X2, the search will be conducted from right to left, starting at column X1. Similarly, if Y1 is greater than Y2, the search will be conducted from bottom to top. However, prior to [v1.1.32], the fast mode required X1 and Y1 to be the top-left corner.

This allows you to find the upper left corner first and then the lower right corner. The other two result from this.
99leeroi99
Posts: 18
Joined: 28 Oct 2021, 03:50

Re: Color detect in every corner

02 Dec 2021, 09:54

@Rohwedder can you make an example can't understand the pixel Parameters
Rohwedder
Posts: 7643
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Color detect in every corner  Topic is solved

02 Dec 2021, 12:07

Then try:

Code: Select all

F3::
Gui, Destroy
Gui, +AlwaysOnTop -DPIScale +LastFound
Gui, Color, FFFFFF
Random, s, 50, 150
Gui, Font, s%s%
Random, x, 100, 500
Random, y, 100, 500
Random, w, 100, 500
Gui, Add, Text, cBlack x%x% y%y%,% chr(0x2588) ;black space
Gui, Show, w800 h800
Sleep, 1000
WinActivate, ahk_class AutoHotkeyGUI
WinWaitActive, ahk_class AutoHotkeyGUI
PixelSearch, x1, y1, 10, 50, 790, 790, 0x000000, 10, Fast
PixelSearch, x3, y3, 790, 790, 10, 50, 0x000000, 10, Fast
ToolTip, 1, x1, y1, 1 ;upper left
ToolTip, 2, x3, y1, 2 ;upper right
ToolTip, 3, x3, y3, 3 ;lower right
ToolTip, 4, x1, y3, 4 ;lower left
Return
99leeroi99
Posts: 18
Joined: 28 Oct 2021, 03:50

Re: Color detect in every corner

03 Dec 2021, 11:22

@Rohwedder I tried to search this color in my screen 0xF5D222 and the result is nothing it only goes under my mouse
Rohwedder
Posts: 7643
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Color detect in every corner

03 Dec 2021, 12:37

The color displayed by Window Spy is in RGB mode.
PixelGetColor normally works in BGR mode, but can be switched to RGB mode.
My script with RGB 0xF5D222:

Code: Select all

F3::
Gui, Destroy
Gui, +AlwaysOnTop -DPIScale +LastFound
Gui, Color, FFFFFF
Random, s, 50, 150
Gui, Font, s%s%
Random, x, 100, 500
Random, y, 100, 500
Random, w, 100, 500
Gui, Add, Text, cF5D222 x%x% y%y%,% chr(0x2588) ;black space
Gui, Show, w800 h800
Sleep, 1000
WinActivate, ahk_class AutoHotkeyGUI
WinWaitActive, ahk_class AutoHotkeyGUI
PixelSearch, x1, y1, 10, 50, 790, 790, 0xF5D222, 10, Fast RGB
PixelSearch, x3, y3, 790, 790, 10, 50, 0xF5D222, 10, Fast RGB
ToolTip, 1, x1, y1, 1 ;upper left
ToolTip, 2, x3, y1, 2 ;upper right
ToolTip, 3, x3, y3, 3 ;lower right
ToolTip, 4, x1, y3, 4 ;lower left
Return
99leeroi99
Posts: 18
Joined: 28 Oct 2021, 03:50

Re: Color detect in every corner

04 Dec 2021, 13:27

Rohwedder wrote:
03 Dec 2021, 12:37
The color displayed by Window Spy is in RGB mode.
PixelGetColor normally works in BGR mode, but can be switched to RGB mode.
My script with RGB 0xF5D222:

Code: Select all

F3::
Gui, Destroy
Gui, +AlwaysOnTop -DPIScale +LastFound
Gui, Color, FFFFFF
Random, s, 50, 150
Gui, Font, s%s%
Random, x, 100, 500
Random, y, 100, 500
Random, w, 100, 500
Gui, Add, Text, cF5D222 x%x% y%y%,% chr(0x2588) ;black space
Gui, Show, w800 h800
Sleep, 1000
WinActivate, ahk_class AutoHotkeyGUI
WinWaitActive, ahk_class AutoHotkeyGUI
PixelSearch, x1, y1, 10, 50, 790, 790, 0xF5D222, 10, Fast RGB
PixelSearch, x3, y3, 790, 790, 10, 50, 0xF5D222, 10, Fast RGB
ToolTip, 1, x1, y1, 1 ;upper left
ToolTip, 2, x3, y1, 2 ;upper right
ToolTip, 3, x3, y3, 3 ;lower right
ToolTip, 4, x1, y3, 4 ;lower left
Return
problem solve I was grabbing the wrong Hex color in win.spy the result was f5d222 but when I screenshot it and placed in photoshop the hex is different

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, slowwd and 205 guests