【发布时间】:2018-10-03 16:02:15
【问题描述】:
我需要改进这个 Apple 脚本:https://gist.github.com/mariocesar/b15cddd184481f25390e0a6e5cff2d40
# Open the color picker
on convertRGBColorToHexValue(theRGBValues)
set theHexList to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
set theHexValue to ""
repeat with a from 1 to count of theRGBValues
set theCurrentRGBValue to (item a of theRGBValues) div 256
if theCurrentRGBValue is 256 then set theCurrentRGBValue to 255
set theFirstItem to item ((theCurrentRGBValue div 16) + 1) of theHexList
set theSecondItem to item (((theCurrentRGBValue / 16 mod 1) * 16) + 1) of theHexList
set theHexValue to (theHexValue & theFirstItem & theSecondItem) as string
end repeat
return ("#" & theHexValue) as string
end convertRGBColorToHexValue
set theRGBValues to (choose color default color {255, 255, 255})
set hexValue to (convertRGBColorToHexValue(theRGBValues))
set the clipboard to hexValue as text
目前,此脚本在手动单击“拾色器”窗口的“确定”按钮后,将颜色十六进制值复制到剪贴板中。
我想一点击就复制剪贴板中的颜色,以避免点击“确定”按钮。
我尝试使用click button "OK",但没有成功。
【问题讨论】:
标签: applescript action color-picker applescript-objc