Re: With Yosemite, can no longer get selected text of Google Chrome page
Re: With Yosemite, can no longer get selected text of Google Chrome page
- Subject: Re: With Yosemite, can no longer get selected text of Google Chrome page
- From: G Wood <email@hidden>
- Date: Sun, 26 Oct 2014 20:59:04 -0400
> The script goes, in part
> ++
> tell application "Google Chrome"
> set theselect to (selectedText of me from "Google Chrome")
> log "theselect: " & theselect
> end tell
> ++
>
> In Mavericks (and almost all earlier versions), this gives the selected text of the active tab.
> In Yosemite, this gives “missing value”.
>
> Chrome’s library says it has a “copy selection” command -
> ++
> copy selection v : Copy text.
> copy selection specifier : The tab to execute the command in.
> ++
>
> Tried it. Doesn’t work. Neither “copy selection of active tab” nor “copy selection of active tab of front window” yields anything. (One errors, one returns no result.)
>
> In my desperation, I’ve even tried Javascript. Also doesn’t work. (Prefer not to use Javascript tbh.)
>
> So - how can I copy and paste selection in a Google Chrome window?
I don't see a "selectedText" command but I do see the Chrome dictionary entry you cite. You appear to be using it incorrectly. It's not "copy selection of..." It's a verb/command directed at a tab.
I also don't see any such entry as "active tab". Tabs belong to windows so you must speak to them via their window path (a tab id alone won't do).
This works for me (you can condense this of course, I'm just being "tell" explicit here)...
set cs to ""
tell application "Google Chrome"
tell window 1 -- or by it's id
tell tab 2 -- or by it's id
copy selection -- it's now in the clipboard
end tell
end tell
end tell
set cs to the clipboard -- copy clipboard to local var
Manual (cmd-v) pasting now produces what I had selected, as does the use of the variable 'cs'.
HTH
-- Gary
_______________________________________________
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