Help: Scribble- change colors - set a specific one & text

heya!
Got this awesome macro modified, many thanks to Nige_S ^^/

Now, I would want to tweak it again to selecting a color I would want.

scribble modified.kmmacros (8.8 KB)

Like, I understand it is within the applescript - screencapturei -> button 1 "markup" -> button 2 "draw",

how to add also the "Border Color" ~ #33 (if im sure, the color green).

Saw another similar to selecting color from this forum (credits to author) but it is used for preview.


select color other.kmmacros (3.4 KB)

There, they added a variable "zzzColorButtonNumber" -> tell application "System Events", tell application process "Preview"...tell (first color well whose description is "border color").

hmm...how shall it be added to my scribble macro -> apple script (?)

Additional note: I believe that just modifying the "Draw" to "Text" would be clicking the text option in screencapturei mini window, right? I'm pretty new to apple script. so :sweat_smile:

edit note: just tried to change the "Draw" to "Text" within the macro-apple script, but not responding, hmmm, wonder why
attempt text .kmmacros (8.8 KB)

Easiest way is to target color well 1 of the window. The colour swatches are then in groups within the color well's pop over, numbered left-tonight and top-to-bottom starting with "No border" at 1 -- so you want button 67 (I think, I'm a bit too colour blind to be sure!).

So, if we aren't in the window's tell block:

tell window 1
	click color well 1
	tell UI element 2 of pop over 1 of color well 1 to click button 67
end tell

Here's the full script, with the extra bit inserted just before the "move the window" block:

Script
set inst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
	set mainLeft to getvariable "Local_mainScreenLeft" instance inst
	set mainWidth to getvariable "Local_mainScreenWidth" instance inst
	set mainTop to getvariable "Local_mainScreenTop" instance inst
	set mainHeight to getvariable "Local_mainScreenHeight" instance inst
	set secondLeft to getvariable "Local_secondScreenLeft" instance inst
	set secondWidth to getvariable "Local_secondScreenWidth" instance inst
	set secondTop to getvariable "Local_secondScreenTop" instance inst
	set secondHeight to getvariable "Local_secondScreenHeight" instance inst
end tell

tell application "System Events"
	tell process "screencaptureui"
		repeat until exists window 1
			delay 0.2
		end repeat
		delay 0.2
		tell window 1
			click button 1
			delay 0.2
			repeat with eachButton in (every button)
				try
					if value of attribute "AXDescription" of eachButton is "markup" then
						click eachButton
						exit repeat
					end if
				on error
					-- do nothing
				end try
			end repeat
			delay 0.2
			repeat with eachCheckbox in (every checkbox)
				try
					if value of attribute "AXDescription" of eachCheckbox is "Draw" then
						click eachCheckbox
						exit repeat
					end if
				on error
					-- do nothing
				end try
			end repeat
		
		-- select the colour
			click color well 1
			tell UI element 2 of pop over 1 of color well 1 to click button 67

		end tell
		
		-- move the window
		set currentPos to position of window 1
		set percentLeft to ((item 1 of currentPos) - mainLeft) / mainWidth
		set percentTop to ((item 2 of currentPos) - mainTop) / mainHeight
		set newPos to {secondLeft + (percentLeft * secondWidth), secondTop + (percentTop * secondHeight)}
		set position of window 1 to newPos
		
	end tell
end tell

Because, annoyingly, "Draw" is a checkbox but "Text" is a button. So replace the repeat with each checkbox block with:

repeat with eachButton in (every button)
	try
		if value of attribute "AXDescription" of eachButton is "Text" then
			click eachButton
			exit repeat
		end if
	on error
		-- do nothing
	end try
end repeat

ty for the response!

finally got time to try it, the text one is awesome, it worked.

I'm having issues with the color well.

Tried replacing it on my KM -> apple script, it wasnt picking up.

Used the apple script editor and when running it, it shows this (?), im wondering what invalid index within screencaptureui might be.

coding attempt 1
delay 4 -- me delaying it and trying it on separately from KM moving the window

tell application "System Events"
	tell process "screencaptureui"
		repeat until exists window 1
			delay 0.2
		end repeat
		delay 0.2
		tell window 1
			click button 1
			delay 0.2
			repeat with eachButton in (every button)
				try
					if value of attribute "AXDescription" of eachButton is "markup" then
						click eachButton
						exit repeat
					end if
				on error
					-- do nothing
				end try
			end repeat
			delay 0.2
			repeat with eachCheckbox in (every checkbox)
				try
					if value of attribute "AXDescription" of eachCheckbox is "Draw" then
						click eachCheckbox
						exit repeat
					end if
				on error
					-- do nothing
				end try
			end repeat
		end tell
		
		-- select the colour
		click color well 1
		
		
		
		
	end tell
end tell
coding 2 attempt
delay 4

tell application "System Events"
	tell process "screencaptureui"
		repeat until exists window 1
			delay 0.2
		end repeat
		delay 0.2
		tell window 1
			click button 1
			delay 0.2
			repeat with eachButton in (every button)
				try
					if value of attribute "AXDescription" of eachButton is "markup" then
						click eachButton
						exit repeat
					end if
				on error
					-- do nothing
				end try
			end repeat
			delay 0.2
			repeat with eachButton in (every button)
				try
					if value of attribute "AXDescription" of eachButton is "Text" then
						click eachButton
						exit repeat
					end if
				on error
					-- do nothing
				end try
			end repeat
		end tell
		
		-- select the colour
		click color well 1
		tell UI element 2 of pop over 1 of color well 1 to click button 67
		
		
	end tell
end tell

both still show

I tried this method with editing the "Text" applescript that I wanted, and it worked, wondering about this one with the error :melting_face:.

Because you have it outside of a tell window 1 block.

UI elements are nested, so you have to nest the references to them in your script:

tell application "System Events"
   tell application process "screencaptureui"
      tell window 1
         -- other stuff here
         click color well 1
	     tell UI element 2 of pop over 1 of color well 1 to click button 67
      end tell
   end tell
end tell

You can see that from your error message, where it's failing to get color well 1 of the screencaptureui process -- color well isn't a child of the process, it's a child of window 1.

Yes, I stupidly put it in the wrong place in the script above. Fixed now, and hopefully the explanation will help you when you do similar in the future -- and you will, I guarantee it :wink:

ty for the script on the color wheel. I got an issue after running the script, looks like it only opens the color window wheel rather than already selecting a preferred color.

wheel.kmmacros (7.5 KB)

maybe it is within the -- select the colour like giving it a delay of 1 sec btw

click color well 1
tell ui element of pop over 1 of color well 1 to click button 37