Re: How to pre-fill a dialog input box from clipboard?
Re: How to pre-fill a dialog input box from clipboard?
- Subject: Re: How to pre-fill a dialog input box from clipboard?
- From: Takaaki Naganoya via AppleScript-Users <email@hidden>
- Date: Fri, 27 May 2022 16:20:04 +0900
Hi Jenni,
I wrote a simple AppleScript Library "display text fields" to display or
confirm data with dialog.
http://piyocast.com/as/asinyaye/display-text-fields_v13
<AppleScript>
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use dspLib : script "display text fields"
set vRes1 to (confirm text fields main message "Zip archive Result" sub message
"Edit this data to proc." key list {"scpt", "scptd", "applescript"} value list
{98, 16, "You used some value which can not stringfy by AppleScript functions
(ex: application objects or Cocoa objects)"})
--> {"98", "16", "You used some value which can not stringfy by AppleScript
functions (ex: application objects or Cocoa objects)"}
</AppleScript>
Takaaki Naganoya
--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/
> 2022/05/27 13:48、Jenni via AppleScript-Users
> <email@hidden>のメール:
>
> I've written a little script that creates a dialog box to enter text to
> be translated into another language using the Argos Translator script on
> GitHub. It works well. But then I thought it would be nice to have the
> dialog box input field be automatically populated with any text already on
> the clipboard, but I can't get it to work.
>
> Here's what I have:
>
> use AppleScript version "2.4"
> use scripting additions
> use script "Dialog Toolkit Plus" version "1.1.0"
>
> tell application "Terminal"
> activate
> set accViewWidth to 650
> set {theButtons, minWidth} to create buttons {"Cancel", "to English
> [⌘E]", "to French [⌘F]"} button keys {"", "e", "f"} cancel button 1
>
> if minWidth > accViewWidth then set accViewWidth to minWidth
>
> set {the_phrase, theTop} to create field "" placeholder text "Enter
> your text here" bottom 0 field width accViewWidth extra height 60 with
> accepts linebreak and tab
>
> set {boldLabel, theTop} to create label "Enter the phrase you want to
> translate, then click the destination language:" & return & return & "(Or,
> use the command key shortcuts.)" bottom theTop + 20 max width accViewWidth
> control size regular size
>
> set {buttonName, controlsResults} to display enhanced window "Argos
> Translate" acc view width accViewWidth acc view height theTop acc view
> controls {the_phrase, boldLabel} buttons theButtons active field the_phrase
> initial position {660, 330} with align cancel button
>
> --tell application "System Events" to keystroke "v" using command down
> --set {the_phrase} to the clipboard
>
> set {the_phrase} to controlsResults
> delay 0.5 -- This is needed for the command keys above to work.
>
> do script "" -- Open a new Terminal window.
> activate
>
> tell application "System Events"
> if buttonName contains "English" then
> keystroke "argos-translate --from-lang fr --to-lang en
> \"" & the_phrase & "\""
> else
> keystroke "argos-translate --from-lang en --to-lang fr
> \"" & the_phrase & "\""
> end if
> delay 0.1
> keystroke return
> end tell
> end tell
>
>
> Neither pasting into, nor setting the field, work (see the commented
> out lines). Is this possible to do?
>
> Thanks,
> Marc
> _______________________________________________
> 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
_______________________________________________
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