[SOLVED] Grab pixel color at mouse coordinates

I got this AppleScript and it's working for a fixed coordinate (in this case it's 123,456), which I can, of course, use KM to get the mouse coordinates, but I was wondering if I can do it all with just the AppleScript? So I would like the AS to grab the mouse coordinates automatically, instead of adding more KM actions to grab them?

do shell script "screencapture -R123,456,1,1 -t bmp $TMPDIR/test.bmp && \
                 xxd -p -l 3 -s 54 $TMPDIR/test.bmp | \
                 sed 's/\\(..\\)\\(..\\)\\(..\\)/\\3\\2\\1/'"

Original post:

Have a look at this:

1 Like

Works like a charm. Thanks!
And it's funny to read your comment where you seem to still be at your beginner stage in KM, confused about how to set the clipboard :wink:

1 Like

Ahh... Memories...:joy:

1 Like

I love that feeling of looking at something old and thinking "wow, this is so second nature to me now".

I remember when I moved to New York in 2012, English not being my main language (even though I was already pretty comfortable with it), and I would take daily notes on my phone about certain words, expressions, sayings, etc. And I remember looking at those notes from time to time and having that feeling. Those things just became part of my daily vocabulary without even noticing it and it feels great.

So thanks for improving so much that you can now help others (me included) on their journey as well. I can see my improvement as well when I look at some of my old posts, so I'm getting there :wink:

1 Like

Yeah! I've noticed you're very comfy with KM now. It's a great skill to develop. :+1:t3:

1 Like

Indeed. And along with it, some AS and RegEx as well, which are great (and relatively easy) tools to learn. RegEx more than AS, but I learn as I create new macros.

1 Like

I'm still hopeless at regex so I always make subroutines so I can reuse the logic. :sweat_smile:

1 Like

I know RegEx can become super complex, but since it seemed to be something I would be using quite often, not only with KM, I decided to go to my YouTube source called The Net Ninja. If you don't know him yet, check him out. Super cool guy, great at teaching.

So he has a crash course on RegEx so I took a few hours to watch the whole thing and take notes. Of course he covers the basics, but it's already super helpful, because I was able to understand how it works, even if it was just the basics.

Then using the RegEx101 website whenever I need to test my expressions or just understand expressions shared by other people, has been super useful.

There are super complex expressions that I have no idea what they mean (yet), but at least now I can look at them and see some "logic" in there, which is great and I don't have to always rely on other people for simple expressions

1 Like

Thanks for the links Danny. I think I'll watch the crash course actually. Would be good to up my regex game, as its so useful so often. :+1:t3:

1 Like

You're welcome. I've been getting so much from you and the whole community here, it's always a pleasure to share something as well.
Shawn is a great teacher and I'm sure you will enjoy it.
I've watched some of his other courses related to HTML, CSS, JavaScript, and it's always worth it.

Yes, even for Finder and other apps, I've been using it more often than I expected.

1 Like