• 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: Get characters# ids
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get characters# ids


  • Subject: Re: Get characters# ids
  • From: Christopher Nebel <email@hidden>
  • Date: Wed, 24 Feb 2010 21:46:00 -0800

On Feb 24, 2010, at 3:51 AM, Shane Stanley wrote:

> On Feb 24, 2010, at 2:36 AM, Thomas Fischer wrote:
>
>> I'd like to have a general small AppleScript script(?) to give me the Unicode points for the selected text in the frontmost window (say for the first five characters).
>>
>> My first problem is that there seems to be no general method to get the selected text of window 1 of application 1.
>> So I might try to distinguish between different applications that I want to use.
>> But then I run into the second problem that I can't use something like
>>
>> copy the id of application 1 to myApp
>>
>> because AppleScript-Editor will not compile this (as long as it is application 1 I suppose).
>>
>> Has anybody an idea?
>

> The only reliable way will be to copy the selection, and get the id of the text on the clipboard.

Actually, this is a perfect application for the Automator-based Services in Snow Leopard.  Your real issue here is getting the selected text, and that's what services can do by definition.  Fire up Automator, make a new Service, set it to "Service receives selected <text> in <any application>", and then use a Run AppleScript action that does what you need.  My quick and dirty version:

	on run {input, parameters}
		set p to ""
		repeat with s in input
			set p to p & s
		end
		set AppleScript's text item delimiters to ", "
		display dialog ((id of p) as text)
	end run

Different presentation forms are left as an exercise for the reader.  Alternatively, find an application such as UnicodeChecker that does this sort of thing as a service already.


--Chris Nebel
AppleScript Engineering

 _______________________________________________
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: Get characters# ids
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: Get characters# ids (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: [ANN]AppleScript Pro Sessions Florida
  • Next by Date: Scripts Folder
  • Previous by thread: Re: Get characters# ids
  • Next by thread: Re: Get characters# ids
  • Index(es):
    • Date
    • Thread