Thursday, October 6, 2022

#1 2022-05-27 06:17:10 pm

daBee
Member
From:: Toronto
Registered: 2010-02-09
Posts: 199

AS to copy current text selection

Hi folks.  I'm looking for a way to copy the current text selection into the Clipboard.  It's initiated through a third party software item, so I can't use the normal procedures.  This is what I'm thinking it should look like:

Applescript:

tell application "BBedit" to set the clipboard with current selection

But it's not working.  I can't recognize the highlighted focus. 

Any ideas?

Cheers


Filed under: Copy Focus

Offline

 

#2 2022-05-28 01:45:17 am

Fredrik71
Member
Registered: 2019-10-23
Posts: 976

Re: AS to copy current text selection

When you hit a error in AppleScript you need to do the basics

Start with:

Applescript:

tell application "BBEdit"
its properties
end tell[/AppleScript]

We need to set the right type
tell application "BBEdit"
-- first we need to set a variable to return the right class
set theSelection to selection as text
set the clipboard to theSelection
log theSelection
end tell

Lastly we take the code you post and change it to

Applescript:

tell application "BBEdit" to set the clipboard to (selection as text)

Last edited by Fredrik71 (2022-05-28 01:47:23 am)


Node-RED makes it easy to automate IoT

Offline

 

#3 2022-05-29 09:58:37 am

daBee
Member
From:: Toronto
Registered: 2010-02-09
Posts: 199

Re: AS to copy current text selection

First block didn't copy the selection, but the second one worked.  I wasn't far off.  Thank you.

Cheers

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)