Retrieve string from Javascript in Visual Basic

201 views Asked by At

Ok so I'm working on a visual basic program that allows me to control pandora through hotkeys instead of having to access the site directly and press the buttons ect.

To my question, Is there a way I can access the javascript variables on the site to get song name and, elapsed time ect? (I'm fairly new to visual basic)

1

There are 1 answers

0
sacredfaith On

Damage,

An angle of attack I would try would be to load Pandora in a WebBrowser control within a winform, and then do something like this:

Private Sub GetFrames()
'Purpose: searches all frames in the document(s) and adds them to colDocuments

Dim i As Integer, j As Integer
j = 1

Set colDocuments = New Collection
colDocuments.Add WebBrowser1.Document

Do While j < colDocuments.Count + 1
    For i = 0 To colDocuments.Item(j).frames.length - 1
        colDocuments.Add colDocuments.Item(j).frames.Item(i).Document
    Next i
    j = j + 1
Loop
End Sub

And then follow it up with:

colDocuments(3).getElementsByName("TD").Item(10).Click

Where '3' in the colDocuments object would be the target 'play', 'pause', etc. that you want to click. You could then tie your desired shortcut keys to whatever buttons you create in your winform. Hope this gets you going in the right direction!! Click SOURCE to see where I got this code: thanks to TheVader at vbforums.com.

SOURCE