Floating.Point Posted August 5 Share Posted August 5 (edited) I think it might be nice to include a system colour picker as part of the Automation Tasks. At the moment I am using the following osascript (JavaScript) function run(argv) { function chooseColor() { try { let app = Application.currentApplication(); app.includeStandardAdditions = true; // Open the color picker with a default color of red let color = app.chooseColor({defaultColor: [1, 0, 0]}); // Convert the normalized color values (0-1) to 8-bit RGB values (0-255) let r = Math.round(color[0] * 255); let g = Math.round(color[1] * 255); let b = Math.round(color[2] * 255); // Convert RGB values to HEX return rgbToHex(r, g, b); } catch (error) { return "no_swatch"; } } function rgbToHex(r, g, b) { return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1).toUpperCase(); } // Output return JSON.stringify({alfredworkflow: {arg: chooseColor()}}); } But this method comes with a warning osascript[41187:4957949] It's not legal to call -layoutSubtreeIfNeeded on a view which is already being laid out. If you are implementing the view's -layout method, you can call -[super layout] instead. Break on void _NSDetectedLayoutRecursion(void) to debug. This will be logged only once. This may break in the future. … which worries me a bit Edited August 5 by Floating.Point Link to comment Share on other sites More sharing options...
vitor Posted August 5 Share Posted August 5 13 hours ago, Floating.Point said: which worries me a bit But it’s not you causing the error, it’s whatever AppleScript is doing. It looks to be accessing old APIs which are themselves throwing that error. I recommend opening a bug report with Apple for that. I will do so as well, but ostensibly the more there are, the more likely issues are to be addressed. Floating.Point 1 Link to comment Share on other sites More sharing options...
Floating.Point Posted August 6 Author Share Posted August 6 Okay will do, cheers Vitor ☺️ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now