Problem Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Sky1337
Posts: 11
Joined: 24 Nov 2022, 12:44

Problem

Post by Sky1337 » 25 Nov 2022, 15:39

I made a script so that when a given color appears in the given coordinates, then 1 is pressed, but nothing works and I can’t understand what the problem is

Code: Select all

Pixelgetcolor, Color, 580, 471
        if (Color==0x784498)
		{
			Send, {1}
		}

User avatar
boiler
Posts: 16915
Joined: 21 Dec 2014, 02:44

Re: Problem

Post by boiler » 25 Nov 2022, 16:01

Could be one of several things. Your script as shown only checks once and that’s it. It doesn’t repeatedly check. It is getting the color in BGR format, not RGB. It is checking coordinates relative to whatever window is active at the time.

Sky1337
Posts: 11
Joined: 24 Nov 2022, 12:44

Re: Problem

Post by Sky1337 » 25 Nov 2022, 16:20

Could you help me make a script?

Sky1337
Posts: 11
Joined: 24 Nov 2022, 12:44

Help

Post by Sky1337 » 25 Nov 2022, 16:23

hello, could you help me make a script so that when the specified color is in the specified coordinates, the button 1 is pressed
Last edited by gregster on 25 Nov 2022, 16:30, edited 1 time in total.
Reason: Topics merged.

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Problem  Topic is solved

Post by mikeyww » 25 Nov 2022, 17:57

Debugging strategies per boiler's note:

1. MouseMove to the coordinates.
2. Display the color value that is found there.

Code: Select all

x = 580
y = 471
WinGetActiveTitle, title
MouseMove, x, y
PixelGetColor, bgr, x, y ; Blue-Green-Red
MsgBox, 64, Color, Title: %title%`n`nBGR color (0xbbggrr): %bgr%
bgr.png
0x784498
bgr.png (320 Bytes) Viewed 441 times

Sky1337
Posts: 11
Joined: 24 Nov 2022, 12:44

Re: Problem

Post by Sky1337 » 26 Nov 2022, 02:04

Can you send me the full script? I'm just new and don't know much about scripting.

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Problem

Post by mikeyww » 26 Nov 2022, 05:19

That is a test script that enables you to determine whether you are seeing the color value that you expected to see (in the message box). You can run it and then report whether the script worked.

Sky1337
Posts: 11
Joined: 24 Nov 2022, 12:44

Re: Problem

Post by Sky1337 » 26 Nov 2022, 05:42

everything is working

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Problem

Post by mikeyww » 26 Nov 2022, 06:28

If the original problem remains, you can examine the :arrow: KeyHistory as a next step.

Code: Select all

#InstallKeybdHook
#Persistent
x       = 580
y       = 471
target := 0x784498
WinGetActiveTitle, title
MouseMove, x, y
PixelGetColor, bgr, x, y ; Blue-Green-Red
MsgBox, 64, Color, Title: %title%`n`nBGR color (0xbbggrr): %bgr%
If (bgr = target) {
 Send 1
 MsgBox, 64, Success, Worked!
} Else MsgBox, 48, Failure, Not!
KeyHistory
image221126-0628-001_cr.png
Key history
image221126-0628-001_cr.png (5.07 KiB) Viewed 353 times

Post Reply

Return to “Ask for Help (v1)”