Skip navigation

AppleScript

358 Views 9 Replies Latest reply: Feb 8, 2013 7:42 AM by leroydouglas RSS
Karl Thomas Hove Calculating status...
Currently Being Moderated
Feb 7, 2013 7:36 AM

I am looking for an easy solution to copy text from a web page (always in the same location) into to Word and print.

 

A repetative task that I'd like to run by single keystroke.

 

Go to a field on a webpage, select the text, copy, change application to Word, select text in a specific location, paste and print.

 

This all works fine - I need elp with setting mouseLocation and double clicking to copy

 

 

tell application "Google Chrome"

  activate 

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

end tell

tell application "Microsoft Word"

  activate

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

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

end tell

iMac, OS X Mountain Lion (10.8.2), Office (home)
  • davidsignal Level 3 Level 3 (525 points)
    Currently Being Moderated
    Feb 8, 2013 6:07 AM (in response to Karl Thomas Hove)

    It would work far better to grab the text based on its elementID rather than your mouse location.

  • davidsignal Level 3 Level 3 (525 points)
    Currently Being Moderated
    Feb 8, 2013 6:24 AM (in response to Karl Thomas Hove)

    get UI Browser.

    Use that to get the HTML element IDs for the text areas you want.

    Then do something like:

    tell application "System Events" to tell process "Google Chrome"

         set customerName to the value of text field 4 of group 1 of window 1 

    end tell

    tell application "System Events" to tell "Microsoft Word"

         activate

         keystroke customerName

    end tell

     

     

    you could also do it without using keystrokes by getting the elementID of the document text area in Word and then setting the value of that element to customerName.

  • davidsignal Level 3 Level 3 (525 points)
    Currently Being Moderated
    Feb 8, 2013 7:40 AM (in response to Karl Thomas Hove)

    I am at work, so I can't really test anything out at the moment....  maybe someone else on the forums will have better input.

     

    Microsoft Word (which I don't use) incorporates its own Applescript dictionary with relevant commands.  You could read the dictionary in your applescript editor.  There are also various examples of applescripts to replace text that you could search on google.

  • leroydouglas Level 6 Level 6 (13,375 points)
    Currently Being Moderated
    Feb 8, 2013 7:42 AM (in response to Karl Thomas Hove)

    Karl Thomas Hove wrote:

     

    I thought you gurus would be all over this, do anyone know applescript?

    There is a AppleScript specific discussion forum:

     

    https://discussions.apple.com/community/mac_os/mac_os_x_technologies#/?tagSet=10 44

    MacBook Pro (15-inch Mid 2010), OS X Mountain Lion (10.8.2), 2.4GHz IntelCorei5 320GB HD 8GB RAM

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.