Jump to content

robots-dreams

Member
  • Posts

    4
  • Joined

  • Last visited

Posts posted by robots-dreams

  1. If you need anything else, let me know, I'd be glad to help

    Thanks.

    I was able to get it working, thanks to your help and advice.

    Hotkey

    Run NSAppleScript

    on alfred_script(q)

    -- Google Translate Applescript

    -- L. Fugitt

    -- 4/6/2013

    --

    -- Copies selected text into the translation text box on Google Translate

    --

    tell application "Google Chrome"

    activate

    tell application "System Events" to keystroke "c" using command down

    --

    -- Open the Google Translate webpage

    --

    set myTab to make new tab at end of tabs of window 1

    set URL of myTab to "http://translate.google.com"

    --

    -- Wait for the webpage to finish loading

    --

    view source of active tab of window 1

    delay 3

    repeat while loading of active tab of window 1

    delay 1

    end repeat

    --

    -- Paste the clipboard into Google Translate

    --

    tell application "System Events" to keystroke "v" using command down

    end tell

    end alfred_script

    Post Notification

  2. Apologies, I misunderstood your request. This could be accomplished. The quirky thing about this though is that, the paste command is going to fire pretty quickly. It more than like is going to fire before the Google Translate page has loaded. That being said, it still CAN be done but instead of using the Copy to Clipboard and auto pasting, you may would have to just copy to the clipboard and use an applescript to wait a few seconds then paste (also using applescript).

     

    No problem. I should have been clearer in my description.

     

    The problem I've been seeing is probably the paste firing too quickly. I created another Workflow just to paste the clipboard contents, and it works fine.

     

    The reason I want to use the Google Translate page rather than just returning the translated contents is to take avantage of the other features on the Google Translate page. For example, you can have the text pronounced, do editing and see the translated changes immediately, see examples of the translated words in use, and save the results to a phrasebook.

     

    Thanks for the help. I really appreciate it.

  3. The Open URL module does only that. Opens the page. From my understanding, what you are looking for would require more coding so that you could use a Google API to send that text to Google Translate and get a response. I haven't looked at it but you may be better served to check out one of the Google Translate Workflows that have already been created. I know I've seen at least one in the Share Your Workflows forum.

     

    Thanks. That's helpful.

     

    There is only one Google Translate workflow that I can find, and it's fairly complex.

     

    Basically what I need to do is simple and would apply to any website - not just Google Translate.

     

    I just want to open the website URL, and paste the contents of the clipboard. Does that require using additional coding?

  4. I do a lot of research on foreign language websites, usually in Japanese. It isn't always possible to use the Chrome translate plug-in, so I tried creating an Alfred Workflow that would:

     

    1- Trigger on a Hotkey with the Argument "Selection in OS X" and Action "Pass through to workflow"

     

    2- Open URL with http://translate.google.com

     

    3- Copy to Clipboard with "Automatically past to front most app" checked.

     

    The workflow opens the Google Translate page, but doesn't paste the clipboard contents.

     

    I've also tried it with the Argument "OS X Clipboard contents", making sure that I copied the Japanese text to the clipboard first, but unfortunately that doesn't work either.

     

    What am I missing? I know the answer must be so simple I'm totally overlooking it.

×
×
  • Create New...