Hey!
Is is possible to use color code in applescript, like in linkinus on spotify output?
and how is it done?
Hey!
Is is possible to use color code in applescript, like in linkinus on spotify output?
and how is it done?
Not clear to me what you want to do, but I use this script (and the magnifying glass icon on the color picker window) to match colors:
-- I find this script endlessly useful in preparing both the MacScripter.net articles (HTML), and forum entries (BBCode).
-- set the initial shade in the palette to light grey
set C10 to choose color default color {50000, 50000, 50000}
set Val16 to ""
repeat with C in C10
if contents of C = 0 then
set Val16 to Val16 & "00"
else
set Val16 to Val16 & |10->16|(C) -- as 8-bit colors
end if
end repeat
set B to button returned of (display dialog "The color values for the color chosen:" & return & return & Val16 default button 1 buttons {"BB to Clip", "Num to Clip", "HTML to Clip"})
if B = "BB to Clip" then
set the clipboard to "[color=#" & Val16 & "]"
else if B = "Num to Clip" then
set the clipboard to Val16
else
set the clipboard to "<font color=\"#" & Val16 & "\">"
end if
on |10->16|(n10)
set n10 to n10 div 256 -- to get 8-bit
if n10 is less than 0 then set n10 to -n10
set Ch16 to "0123456789ABCDEF"
set Txt16 to ""
set N to n10
set Dgt16 to 1
repeat
if N is 0 then exit repeat
set nx to N div Dgt16
set mx to nx mod 16
set Txt16 to (character (mx + 1) of Ch16) & Txt16
set N to N - (mx * Dgt16)
set Dgt16 to (Dgt16 * 16)
end repeat
if length of Txt16 = 1 then set Txt16 to "0" & Txt16
return Txt16
end |10->16|
Try looking at the Formatting panel of the Preferences of Script Editor. If that’s not what you want but like wrting a color code in the script so taht the text becomes violet from then on, forget it.
Otherwise there are few fans of linkinus. Although the speakers in my kitchen color the spotify output somehow.
Please do elaborate a little bit on what you mean by use color code.
Applescript can be copied into a text edit document and exported as html.
You can use color codes like in html, by specifying color tags in your text, if you want to output something with colors in it for pasting into something different.
Here is the code
The thing i what is to color “nP” like this : nP
EDIT:
Found out how it works:
set theString to "/colorme n#redP #white" & theArtist & " - [ Track: " & theTrack & "] - [Album: " & theAlbum & "] Spotify URL: [url=http://open.spotify.com/track/]http://open.spotify.com/track/"[/url] & spotify_id
-- (C) 2011 agreeabledragon <recognize@me.com>
on linkinuscmd(cmd)
set AppleScript's text item delimiters to ""
set spotify_active to false
set theString to "Spotify is not running right now!"
tell application "Finder"
if (get name of every process) contains "Spotify" then set spotify_active to true
end tell
if spotify_active then
set got_track to false
tell application "Spotify"
if player state is playing then
set theTrack to name of the current track
set theArtist to artist of the current track
set theAlbum to album of the current track
set isStarred to starred of the current track
set spotify_id to id of the current track
set got_track to true
end if
end tell
set spotify_id to replace_text(spotify_id, "spotify:track:", "")
set theString to "Spotify is not running right now!"
if got_track then
set fav to ""
if isStarred then
set fav to "one of my favorite tracks, "
end if
set theString to "nP: " & fav & "\"" & theArtist & "\"" & " " & theTrack & " [Album: " & theAlbum & "] Spotify URL: [url=http://open.spotify.com/track/]http://open.spotify.com/track/"[/url] & spotify_id
end if
end if
return theString
end linkinuscmd
on replace_text(io, search, replace)
set AppleScript's text item delimiters to the search
set the item_list to every text item of io
set AppleScript's text item delimiters to the replace
set io to the item_list as string
set AppleScript's text item delimiters to ""
return io
end replace_text
linkinuscmd("")
Using Adam’s script is great for setting the background color and such on html documents that are just too big to be converted by the readability bookmarklet.
I use this, when I feel my eyes have been strained enough by the white:
tell application "Safari"
# http://stackoverflow.com/questions/197748/how-do-i-change-the-background-color-with-javascript
tell its document 1
do JavaScript "document.body.style.background = \"#FFCC66\";"
end tell
end tell
This one changes the font type and size to something more pleasant.
tell application "Safari"
tell its document 1
do JavaScript "var i = \"\";
var paragraphs = \"\";
paragraphs = document.getElementsByTagName(\"p\");
for(i=0; i<paragraphs.length; i++)
{
paragraphs[i].style.fontFamily = \"Baskerville\";
paragraphs[i].style.fontSize = '1.2em';
}"
end tell
end tell