• 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: Scriptable multi-clipboard utility?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scriptable multi-clipboard utility?


  • Subject: Re: Scriptable multi-clipboard utility?
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 08 Mar 2014 20:09:33 -0600

Hey Michael,

On Mar 08, 2014, at 13:12, Michael Grant <email@hidden> wrote:
☞ If the user cancels, 'choose from list' returns {«class fals»:false}, not the string "false" — need to coerce to text (I haven't been able to get consistent results working with the chevron class).

Huh?  You mean the boolean?

☞ Running my original version, the choose from list dialog didn't always have focus, so I couldn't use it without mousing. To rectify I put it inside the tell system events block with an activate command.

This is not a bad tactic, BUT if the user clicks outside of the dialog OR switches apps accidentally or otherwise you can lose your dialog and leaving it hanging.

-------------------------------------------------------------------------------------------
set l to {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"}

tell application (get name of application (path to frontmost application as text))

  

  set theCoice to choose from list l ¬
    with title "Your Dialog Title" with prompt "Pick 1 or More:" default items {item 1 of l} ¬
    OK button name "Pick!" cancel button name "Be Gone!" multiple selections allowed true ¬
    with empty selection allowed

  

  if theCoice ≠ false and theCoice ≠ {} then
    beep
    # Do your thing...
  end if

  

end tell
-------------------------------------------------------------------------------------------

I like to use default items in choose from dialogs, so I can immediately type-select.

☞ The try block doesn't seem necessary as far as I can tell.

It's a good practice to always include a try-on-error block.

Basic bare block:

-------------------------------------------------------------------------------------------
try

  

  # Your code here...

  

on error e number n
  set e to e & return & return & "Num: " & n
  tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try
-------------------------------------------------------------------------------------------

Handler for use with a library:

-------------------------------------------------------------------------------------------
try

  

  # Your code here...

  

on error e number n
  stdErr(e, n, true, true) of me
end try
-------------------------------------------------------------------------------------------
--» stdErr()
-------------------------------------------------------------------------------------------
--  Task: General error handler
--  dMod: 2013-05-31 : 04:22
-------------------------------------------------------------------------------------------
on stdErr(e, n, beepFlag, ddFlag)
  set e to e & return & return & "Num: " & n
  if beepFlag = true then
    beep
  end if
  if ddFlag = true then
    tell me
      set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
    end tell
    if button returned of dDlg = "Copy" then set the clipboard to e
  else
    return e
  end if
end stdErr
-------------------------------------------------------------------------------------------

--
Best Regards,
Chris

 _______________________________________________
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: 
 >Scriptable multi-clipboard utility? (From: Michael Grant <email@hidden>)
 >Re: Scriptable multi-clipboard utility? (From: Michael Grant <email@hidden>)
 >Re: Scriptable multi-clipboard utility? (From: Michael Grant <email@hidden>)

  • Prev by Date: Re: Calendar running scripts?
  • Next by Date: Re: build a list of mailboxes
  • Previous by thread: Re: Scriptable multi-clipboard utility?
  • Next by thread: Re: due dates, reminders, & AppleScript
  • Index(es):
    • Date
    • Thread