Color detect in every corner Topic is solved
-
- Posts: 18
- Joined: 28 Oct 2021, 03:50
Color detect in every corner
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
Re: Color detect in every corner
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.
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.
-
- Posts: 18
- Joined: 28 Oct 2021, 03:50
Re: Color detect in every corner
@Rohwedder can you make an example can't understand the pixel Parameters
Re: Color detect in every corner Topic is solved
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
-
- Posts: 18
- Joined: 28 Oct 2021, 03:50
Re: Color detect in every corner
@Rohwedder I tried to search this color in my screen 0xF5D222 and the result is nothing it only goes under my mouse
Re: Color detect in every corner
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:
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
-
- Posts: 18
- Joined: 28 Oct 2021, 03:50
Re: Color detect in every corner
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 differentRohwedder wrote: ↑03 Dec 2021, 12:37The 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