Re: Get characters# ids
Re: Get characters# ids
- Subject: Re: Get characters# ids
- From: Thomas Fischer <email@hidden>
- Date: Thu, 25 Feb 2010 19:12:21 +0100
Hello,
thanks for all the clever hints!
It seems that
on run {input}
set myList to input as text
set text item delimiters to ", "
display dialog (id of myList as text)
end run
will present the list of Unicode numbers in a dialog, as Mark suggested.
Since I want to add some additional information (e.g. the respective hexadecimal numbers) I want those numbers on separate lines, and that doesn't work, unless there is a way to enlarge to dialog window. As it is, it cuts off the bottom of the forth line and everything beyond. The button "Copy to Clipboard" is shortened to something that looks like "Copy to Clipl". And the action is very slow...
I have a version of this for TextWrangler (basically the same script) which acts snappy and without restriction of the size of the dialog.
And by the way, my second question comes back to me in other contexts:
Is there a way to get the name or id of of the front application?
Cheers
Thomas
Am 25.02.2010 um 14:41 schrieb Mark J. Reed:
> If input is a list and the loop is to turn it into one big string,
> wouldn't it be more efficient to set TIDs to "" and use "input as
> text" instead?
>
> On Thursday, February 25, 2010, Christopher Nebel <email@hidden> wrote:
>> 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
>>
>
> --
> Mark J. Reed <email@hidden>
> _______________________________________________
> 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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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