Chromascope Macro (v11.1.1), a screen colour monitoring tool

I just couldn't wait 24 hours to post another Swift-based utility. This utility displays a window on the screen showing you the current distribution of Red, Green and Blue Pixels on the screen. This is a dynamic window that updates itself several times per second (although that depends on how large your screen is, or the size of the screen's rectangle that you tell this macro to search inside.)

You can close it by double clicking on it, (I am fond of that method) or using your own hotkey to terminate all macros.

This window floats above the screen and its own pixels are not included in the screen sampling algorithm. The window is also completely resizable. At the top of the window is the screen rectangle that the macro is examining. The line below it is the frames per second (FPS) that the macro is currently running. Your FPS will depend upon the size of the region being measured and your CPU speed.

You may get a pop-up like this:

I was able to avoid seeing that popup by adding the following program to System Settings / Privacy and Security / Accessibility.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend

Some of you may have never installed Xcode so the program you have to add may be the following instead: (I didn't test this)

/usr/bin/swift-frontend

If you try to trigger this macro directly rather than running it as a subroutine then the search area defaults to the centre "ninth" of your screen (if you don't like that default you can change it, but it's reasonable for my needs) This macro is meant to be run as a subroutine, so you should pass it the screen rectangle that you want this macro to examine. If you pass it the empty string it will examine the entire screen.

This is a very nice macro that proves how powerful Swift can be. You can't write this macro with KM actions, and you can't even write it with AppleScript actions (which doesn't have access to the APIs that Swift does.)

I gave it a cute sounding name, "Chromascope."

Yes, I did use Gemini AI to write most of the code, but it really required a lot of guidance on my part. It took about 100 attempts to get this to work, because Gemini is not usually correct in its guidance. But I still love it.

I'm not entirely sure what problem this macro solves. But it reminds me of the builtin macOS utility called Digital Color Meter, which I use a lot. At least Chromascope is "potentially useful."

Chromascope Macro (v11.1.1)

Chromascope.kmmacros (17 KB)