• 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: Copying text from the AS Editor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copying text from the AS Editor


  • Subject: Re: Copying text from the AS Editor
  • From: "koenig.yvan" <email@hidden>
  • Date: Thu, 01 Aug 2013 16:14:28 +0200


Le 01/08/2013 à 15:38, Jim Brandt <email@hidden> a écrit :

Since this worked for KOENIG, I went back to try to figure this out.

I had saved the original script as a bundle, then turned it into a run-only application (I've been working with scripts that use plists and are stored in the bundle so it's my default save mode right now). It was this version that gives me the contents of the clipboard at the time it is run.

After going back and saving the source as a script (not a bundle), and then making that into a run-only application, it works.

So, my question is, why does it work when saved as a script, but not when it is save as a script bundle?

Jim

On 1-Aug-2013, at 4:56 AM, email@hidden wrote:

I saved the script as an application.
I didn't checked but I guess that if you store it in the System's Scripts menu it would work also stored as Script.

KOENIG Yvan (VALLAURIS, France) jeudi 1 août 2013 11:54:58

As I am running under 10.8.4, when I save as an application it's in fact an application bundle which is created.
I don't remember which OS replaced the pair application and application bundle by the single format application which is in fact an application bundle.

I assume that your problem is linked to the fact that one instruction is missing in your original code.

You posted :

### Use cut & paste to keep color formatting
tell application "AppleScript Editor"
    tell document 1
        set WindowName to name
        tell application "System Events"
            tell process "AppleScript Editor"
                click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
                click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1
            end tell
        end tell
    end tell
end tell

tell application "Tex-Edit Plus"
    make new document with properties {name:WindowName}
    activate
    tell front window
        tell application "System Events" to tell process "Tex-Edit Plus"
            click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
        end tell
        select text of front window
        set size of selection to 8
        select insertion point before character 1
    end tell
end tell


I added an instruction and Nigel choose an other way to get the same behavior.

My version :

tell application "AppleScript Editor"
    activate
    tell document 1
        set WindowName to name
        tell application "System Events"
            tell process "AppleScript Editor"
                click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
                click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1
            end tell
        end tell
    end tell
end tell

Nigel's version :
tell application "AppleScript Editor"
    tell document 1
        set WindowName to name
tell application "System Events"
tell application process "AppleScript Editor"
set frontmost to true
set WindowName to name of window 1
click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1
end tell
end tell

I enlarged in size 24 the instructions making the difference.

Nigel which is more fluent than me with English explained what was wrong.

When you run the script applet, it'll be the frontmost application. You
need _AppleScript Editor_ to be frontmost for the GUI stuff to work:

My choice was to stick to your original structure so I just inserted the activate instruction which brought the AppleScript window at front.
My other changes are related to the fact that triggering the UI elements by their name is boring because these names are localized so your code is unusable as is on my machine.

Nigel which run the system in English kept the instructions which were boring me but coose to drop the instructions speaking to the application AppleScript Editor.

I put a strike upon the three instructions which he dropped and enlarged in size 24 the two ones which he added.
In this case, it's the first enlarged one which bring the script window at front.

KOENIG Yvan (VALLAURIS, France) jeudi 1 août 2013 16:14:24







 _______________________________________________
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

References: 
 >Re: Copying text from the AS Editor (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: Copying text from the AS Editor
  • Next by Date: Re: urlEncode (AppleScript fails in Automator - Permissions error)
  • Previous by thread: Re: Copying text from the AS Editor
  • Next by thread: Re: urlEncode (AppleScript fails in Automator - Permissions error)
  • Index(es):
    • Date
    • Thread