Here is a script that does a *fair* job of grabbing text from "any" application(cocoa or non-cocoa), not just firefox. However, if you are planning to use it with Firefox, remember to set a proper hotkey (e.g. avoid the option key which makes firefox launch in safe mode)

(This is what I have gathered from one of the posts in   Macscripter:
QS accept characters whose ASCII codes are 01 through 127.
A string which contains a accented character doesn't work)

The script below replaces problematic characters with "?".


tell application "System Events"
set {name:theApp, bundle identifier:theIdentifier} to (get 1st application process whose frontmost is true)
end tell

tell application theApp
        tell application "System Events"
                tell process theApp
                        delay 0.2
click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1
--alternatively, you can use:
--keystroke "c" using command down
                end tell
        end tell
end tell
delay 0.2
set cb to quoted form of (the clipboard as string)
do shell script "/bin/echo " & cb & " | /usr/bin/tr -c '[:print:] [:cntrl:]' '?' | qs "


Attachment: anytext.scpt
Description: Binary data






Reply via email to