Author Topic: Trick: Pasting MB’s NowPlaying as YouTube Query into Word  (Read 2685 times)

joShu

  • Newbie
  • *
  • Posts: 15
Hi,

Here is a trick I use for MB. It’s pretty specific to my world but maybe it will give you an idea how you can hack it for yours.

I am a writer and I use Word a lot for journaling, notes, etc., and I wanted to quickly paste a link of what is currently playing right in line with the text I am typing in Word. So, while I am typing in Word, and while the song is playing in the background in MB, I press a couple hotkeys and the resulting paste into Word looks like this:

Eivor - Salt - Juke Train
S:\Audio\Eivør\Eivor - Salt - Juke Train.mp3
http://www.bing.com/search?q=lyrics_Eivor_Juke_Train
https://www.youtube.com/results?search_query=Eivor_Juke_Train
7/8/2017 11:46:25 AM

Clicking the first link will play the song in MB (for you only, it's a local link, and assuming MB is the working default for that format).
The second link will use your browser to look up the song’s lyrics (if they exist).
The third does a basic browser-query to youtube.

The result is basically a linked log of what you were listening to at the time you were writing. Or, sometimes I copy the youtube query link into a sms message using Cortana and she will send it via my Android.

Anyways, what I did:


Musicbee Send To Word Current Song

Overview
In Word, pressing this:
CTRL ALT SHIFT P
CTRL ALT SHIFT B

Inserts this into Word:

Anilah - Warrior - Medicine Chant
S:\Audio\Anilah - Warrior\Anilah - Warrior - 04 Medicine Chant.flac
http://www.bing.com/search?q=lyrics_Anilah_Medicine_Chant
https://www.youtube.com/results?search_query=Anilah_Medicine_Chant
7/8/2017 11:34:49 AM

Setup

1. MusicBee
  a. Options, Tags(2)
  b. ‘send to clipboard’ tags, copy and paste this:
<Artist> - <Album> - <Title>+++<Path><Filename>+++http://www.bing.com/search?q=lyrics <Artist> <Title>+++https://www.youtube.com/results?search_query=<Artist> <Title>
  c. Options, Hotkeys
  d. Send To: Clipboard (now playing)
  e. CTRL+ALT+SHIFT+P, Global: Yes
2. Word
  a. Create below macro and assign it to CTRL ALT SHIFT B

Sub MusicBeeCleanup()
'
' MusicBeeCleanup Macro
' Uses Send To Tag:
' <Artist> - <Album> - <Title>+++<Path><Filename>+++http://www.bing.com/search?q=<Artist> <Title>+++https://www.youtube.com/results?search_query=<Artist> <Title>
'
' Use the MusicBee global hotkey for Send to Clipboard CTRL SHIFT ALT P
' Then use the Word hokey for this macro CTRL SHIFT ALT B
'
    
    Dim oRng As Word.Range
    
    'I should be able to run the MusicBee global hotkey to load and paste the clipboard, but
    'it is not working.
    'Specifically, selection.paste does not recognize the clipboard contents after using sendkeys
      
    'SendKeys "(^+%P)", True
    'SendKeys "(%H)VT", True
    
        
    'first paste the clipboard from musicbee then replace the +++ delimiters with CRs
    Selection.Paste
    Selection.MoveUp Unit:=wdParagraph, count:=1, Extend:=wdExtend
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "+++"
        .Replacement.Text = "^p"
        .Wrap = wdFindContinue
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.EndKey Unit:=wdLine
    
    'insert a timestamp
    Selection.TypeParagraph
    Selection.InsertDateTime DateTimeFormat:="M/d/yyyy h:mm:ss am/pm", _
        InsertAsField:=False, DateLanguage:=wdEnglishUS, CalendarType:= _
        wdCalendarWestern, InsertAsFullWidth:=False
    Selection.TypeParagraph
    
    'there are now 4 paragraphs of raw text
        
    'select the text with the local url and turn it into a hyperlink
    Selection.MoveUp Unit:=wdParagraph, count:=4
    Selection.MoveDown Unit:=wdParagraph, count:=1, Extend:=wdExtend
    Selection.MoveLeft Unit:=wdCharacter, count:=1, Extend:=wdExtend 'don't include the CR so move left 1 char
    Set oRng = Selection.Range
    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=oRng
        
    'select the text with internet url 1
    'Replace spaces with underscores.
    'Why? Because if you paste the link into a text message, the link is not auto formed properly. Underscores solve that.
    Selection.MoveDown Unit:=wdParagraph, count:=1
    Selection.MoveDown Unit:=wdParagraph, count:=1, Extend:=wdExtend 'select the paragraph
    Set oRng = Selection.Range
    oRng = Replace(oRng, " ", "_")
    Selection.MoveDown Unit:=wdParagraph, count:=1, Extend:=wdExtend
    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=oRng
    
    'select the text with internet url 2
    Selection.HomeKey Unit:=wdLine
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Set oRng = Selection.Range
    oRng = Replace(oRng, " ", "_")
    Selection.MoveDown Unit:=wdParagraph, count:=1, Extend:=wdExtend
    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=oRng
    

    'go the end of the block
    Selection.MoveDown Unit:=wdLine, count:=2
    
End Sub

Use

1. Open MB and start playing some music.
2. Open Word
3. While in Word, press the two hotkeys in sequence
  a. CTRL ALT SHIFT P
  b. CTRL ALT SHIFT B