Jump to content
Sign in to follow this  
DicatoroftheUSA

Pandora.com Keyboard

Recommended Posts

DicatoroftheUSA

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#AutoIt3Wrapper_Outfile=..\..\..\..\Desktop\Pandora.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#region includes
#Include <FF.au3>;http://www.autoitscript.com/forum/topic/95595-ffau3-v0600b/
#include<hotkey.au3>;http://www.autoitscript.com/forum/topic/90492-hotkey-udf/
#include<string.au3>
#endregion includes
#region Options
AutoItSetOption("trayicondebug", True)
#endregion Options
#region Globals
;Below are physical keyboard key values.
Global Const $gc0x_VolumeMute = 0x00AD
Global Const $gc0x_StopMedia = 0x00B2
Global Const $gc0x_PreviousTrack = 0x00B1
Global Const $gc0x_NextTrack = 0x00B0
Global Const $gc0x_Play = 0x00B3
Global Const $gc0x_Media = 0x00B5
#endregion Globals
#region hotkeys
_HotKey_Assign($gc0x_StopMedia, '_StopMedia')
_HotKey_Assign($gc0x_VolumeMute, '_VolumeMute')
_HotKey_Assign($gc0x_PreviousTrack, '_PreviousTrack')
_HotKey_Assign($gc0x_NextTrack, '_NextTrack')
_HotKey_Assign($gc0x_Play, '_Play')
_HotKey_Assign($gc0x_Media, '_Media')
#endregion hotkeys


_pandorasend()
_main()

Func _PandoraStart(ByRef $chFF, $reSend = "")
_FFConnect()
If @error Then _FFStart("http://www.pandora.com/station/play", "default")
;~ Sleep(2000)
$chFF = _FFWindowSelect("station/play", 'href', False)
If $chFF = 0 Then
_FFWindowOpen("http://www.pandora.com/station/play", False, True)
$chFF = _FFWindowSelect("Pandora One")
EndIf
If $reSend <> "" Then _pandorasend($reSend)


EndFunc ;==>_PandoraStart



Func _main()
While 1
Sleep(10)
WEnd
EndFunc ;==>_main

Func _VolumeMute()
ConsoleWrite('stop' & @LF)
_pandorasend("tiredOfSong")
EndFunc

Func _StopMedia()
ConsoleWrite('stop' & @LF)
_pandorasend("thumbDownButton")

EndFunc ;==>_StopMedia


Func _PreviousTrack()
ConsoleWrite('previous' & @LF)
_pandorasend("thumbUpButton")

EndFunc ;==>_PreviousTrack

Func _NextTrack()
ConsoleWrite('next' & @LF)
_pandorasend("skipButton")
EndFunc ;==>_NextTrack

Func _Play()
ConsoleWrite('playButton' & @LF)
_pandorasend('playButton')
EndFunc ;==>_Play

Func _media()
_pandorasend('pauseButton')
EndFunc ;==>_media


Func _pandorasend($sSend = "")
Static Local $chFF = 0
If $chFF = 0 Then _PandoraStart($chFF)
If $sSend = "" Then
_PandoraStart($chFF)
Return
EndIf
$hBackupTab = _FFTabGetSelected()
If Not _FFIsConnected() Then
_PandoraStart($chFF, $sSend)
EndIf
If Not _FFTabExists("Pandora One") Then
_PandoraStart($chFF, $sSend)
EndIf
_FFTabSetSelected(@extended)
$sMode = "Class"
$iIndex = 0
$bLoadWait = True
_FFClick($sSend, $sMode, $iIndex, $bLoadWait)
If @error Then
;~ TrayTip("Error", @error, 1)
_PandoraStart($chFF, $sSend)

Else
;~ $sLabel = _FFGetValue($sSend, $sMode)


$sLabel = $sSend & @CRLF
$sLabel &= _getdetails('songTitle') & @CRLF
$sLabel &= _getdetails('playerBarAlbum') & @CRLF
$sLabel &= _getdetails('playerBarArtist')

TrayTip("", $sLabel, 1)
EndIf

_FFTabSetSelected($hBackupTab)


EndFunc ;==>_pandorasend

Func _getdetails($sClass)
$str_obj_ff = _FFObjGet($sClass, 'class')
$str_obj_ff = _ffobj($str_obj_ff, 'textContent')
Return $str_obj_ff
EndFunc ;==>_getdetails

Assigns pandora to the keyboard's media keys, it requires and I use ff version "0.6.0.1b-8"

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites
Myicq

Interesting read, even if I don't use Pandora.

Btw: you have an error in URL in script to your hotkey UDF.


I am just a hobby programmer, and nothing great to publish right now.

Share this post


Link to post
Share on other sites
Kidney

maybe add and update that with auto click the "I'm still listening" button?? :)

Share this post


Link to post
Share on other sites
Dizzy

Hi,

your code looks very good, but i'll get following error:

"_FF Windows GetHandle General Error"

and i didn't get any information about the actual title, artist ...

Mayby you'll have a look?

Thanks

Dizzy

(And: Is it possible to extend your script to save the album picture?)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×