• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Show Emoji & Symbols GUI access
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Show Emoji & Symbols GUI access


  • Subject: Re: Show Emoji & Symbols GUI access
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 7 Nov 2017 10:41:12 +1100

So here's a left-field alternative for those who (a) mostly use the same
characters or those in Favorites, and (b) are running Sierra:

use AppleScript version "2.5" -- probably Sierra only
use framework "Foundation"
use framework "AppKit"
use scripting additions

-- get app ID
tell application id "com.apple.systemevents" to set appID to (bundle identifier
of application process 1 whose frontmost is true)
-- build list of favorites and recents
set defaults to current application's NSUserDefaults's alloc()'s
initWithSuiteName:"com.apple.CharacterPicker"
set theFaves to defaults's
objectForKey:"Favorites:com.apple.CharacterPicker.DefaultDataStorage"
set theRecents to defaults's
objectForKey:"Recents:com.apple.CharacterPicker.DefaultDataStorage"
set listOfChars to {"Favorites"}
repeat with aFave in theFaves
        set end of listOfChars to character -3 of (aFave as text)
end repeat
set end of listOfChars to "Recents"
repeat with aRecent in theRecents
        set end of listOfChars to character -3 of (aRecent as text)
end repeat
set oldClip to fetchStorableClipboard() -- store existing clipboard contents to
restore later
repeat
        tell application id appID
                activate
                set theResult to choose from list listOfChars
                if theResult is not false then
                        set the clipboard to (item 1 of theResult)
                        delay 0.1
                        tell application id "com.apple.systemevents" to
keystroke "v" using command down
                else
                        -- restore original clipboard contents
                        my putOnClipboard:oldClip
                        exit repeat
                end if
        end tell
end repeat

on fetchStorableClipboard()
        set aMutableArray to current application's NSMutableArray's array() --
used to store contents
        -- get the pasteboard and then its pasteboard items
        set thePasteboard to current application's NSPasteboard's
generalPasteboard()
        set theItems to thePasteboard's pasteboardItems()
        -- loop through pasteboard items
        repeat with i from 1 to count of theItems
                -- make a new pasteboard item to store existing item's stuff
                set newPBItem to current application's NSPasteboardItem's
alloc()'s init()
                -- get the types of data stored on the pasteboard item
                set theTypes to (item i of theItems)'s |types|()
                -- for each type, get the corresponding data and store it all
in the new pasteboard item
                repeat with j from 1 to count of theTypes
                        set theData to ((item i of theItems)'s
dataForType:(item j of theTypes))'s mutableCopy()
                        if theData is not missing value then
                                (newPBItem's setData:theData forType:(item j of
theTypes))
                        end if
                end repeat
                -- add new pasteboard item to array
                (aMutableArray's addObject:newPBItem)
        end repeat
        return aMutableArray
end fetchStorableClipboard

on putOnClipboard:theArray
        -- get pasteboard
        set thePasteboard to current application's NSPasteboard's
generalPasteboard()
        -- clear it, then write new contents
        thePasteboard's clearContents()
        thePasteboard's writeObjects:theArray
end putOnClipboard:

Put it in your FastScripts menu and assign a suitable shortcut.

--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Show Emoji & Symbols GUI access
      • From: Jim Underwood <email@hidden>
References: 
 >Show Emoji & Symbols GUI access (From: Jean-Christophe Helary <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: 2551phil <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Jean-Christophe Helary <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Jean-Christophe Helary <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: 2551phil <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Yvan KOENIG <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Jean-Christophe Helary <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Yvan KOENIG <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: David Gregg <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Yvan KOENIG <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Jim Underwood <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Yvan KOENIG <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: David Gregg <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Jean-Christophe Helary <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: David Gregg <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Jean-Christophe Helary <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Yvan KOENIG <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Jean-Christophe Helary <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Yvan KOENIG <email@hidden>)
 >Re: Show Emoji & Symbols GUI access (From: Jim Underwood <email@hidden>)

  • Prev by Date: Re: Show Emoji & Symbols GUI access
  • Next by Date: Re: Show Emoji & Symbols GUI access
  • Previous by thread: Re: Show Emoji & Symbols GUI access
  • Next by thread: Re: Show Emoji & Symbols GUI access
  • Index(es):
    • Date
    • Thread