Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following script uses <a href="http://www.getautoma.com" rel="nofollow noreferrer" title="Automa">Automa</a> to do exactly what you want (tested on Word 2010):</p> <pre><code>def find_lyrics(): print 'Please minimize all other open windows, then enter the song:' song = raw_input() start("Google Chrome") # Disable Google's autocompletion and set the language to English: google_address = 'google.com/webhp?complete=0&amp;hl=en' write(google_address, into="Address") press(ENTER) write(song + ' lyrics filetype:txt') click("I'm Feeling Lucky") press(CTRL + 'a', CTRL + 'c') press(ALT + F4) start("Microsoft Word") press(CTRL + 'v') press(CTRL + 's') click("Desktop") write(song + ' lyrics', into="File name") click("Save") press(ALT + F4) print("\nThe lyrics have been saved in file '%s lyrics' " "on your desktop." % song) </code></pre> <p>To try it out for yourself, download Automa.zip from its <a href="http://www.getautoma.com/download" rel="nofollow noreferrer" title="Automa Download Page">Download page</a> and unzip into, say, <code>c:\Program Files</code>. You'll get a folder called <code>Automa 1.1.2</code>. Run <code>Automa.exe</code> in that folder. Copy the code above and paste it into Automa by right-clicking into the console window. Press Enter twice to get rid of the last <code>...</code> in the window and arrive back at the prompt <code>&gt;&gt;&gt;</code>. Close all other open windows and type</p> <pre><code>&gt;&gt;&gt; find_lyrics() </code></pre> <p>This performs the required steps. </p> <p>Automa <a href="http://www.getautoma.com/features/python_integration" rel="nofollow noreferrer" title="Automa&#39;s Python integration">is a Python library</a>: To use it as such, you have to add the line</p> <pre><code>from automa.api import * </code></pre> <p>to the top of your scripts and the file <code>library.zip</code> from Automa's installation directory to your environment variable <code>PYTHONPATH</code>. </p> <p>If you have any other questions, just let me know :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COHi Michael Herrmann. Thanks alot. I had never thought that anyone would spend time writing the whole code for me (I'll ues your code to study as a refference since I really really want to put what I've learnt to some practical use :D) I'm sure your code shall make excellent example for me as well as a guild. I'm now downloading automa and I just can't wait to try out your work! Thank you so much. I'm sure I'll have more questions to ask later.
      singulars
    2. COFirst, this is going to copy and paste all of the text of the lyrics results into a Word file, not just the lyrics. Which is almost certainly not what you want. Many lyrics sites are designed to not let you copy-paste the lyrics; even if you're lucky, you'll get a whole mess of navigation, links, etc. surrounding the lyrics. (Also, this will quit both apps when it's done, which is probably not what you want either, but that's easier to fix.)
      singulars
    3. COSecond, the blog post `http://www.getautoma.com/blog/find-song-lyrics-with-automa` about this SO question is highly misleading. "… the other answers consist of… the general tone 'it's too difficult'"? Really, showing the 5 lines of `win32com` code to create a new file in Word is too difficult, but showing the 7 lines of Automa code to do the same thing is not? The hard part is extracting the lyrics text—which this answer just punts on by not actually solving it.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload