#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include ;#include #include #include #include Opt("GUIOnEventMode", 1) Global $String = "this is a string" Global $playpause, $Picture, $MeasureLabel, $TitleBarHeight, $StatusBox, $StatusLabel, $Play, $Rewind, $Skip, $Artist, $Album,$Title,$ID, $OTitle, $TitleLabel, $AALabel, $Outgoing, $incoming, $OSCTitle, $OSCAlbum, $OSCArtist, $sReceived Global $Shuffle = False,$Rewind10 = False,$Forward30 = False,$repeat = False Setup() Load() Idle() Func Setup() UDPStartup () DirCreate(@TempDir & "\GoogleOSC") $Outgoing = UDPOpen("127.0.0.1",8006) $incoming = UDPBind("127.0.0.1",8001) _Toast_Set(0, 0xFF3D02, 0xD6D6D6, 0xD6D6D6, 0xFF3D02, 15, "Courier New",500,250) TraySetToolTip("Connecting to Google Play Music") $ID = _IEAttach( "https://play.google.com/music", "url") if @error = 7 then _Toast_Show("C:\Users\zglam\Desktop\Google Play.jpg", "Google Play Music OSC", " Opening Google Play Music",-500, False) $ID = _IECreate ("https://play.google.com/music/listen#/home", 0.5, 1, 0 ,0) _IELoadWait ($ID) EndIf _Toast_Hide() Do sleep(50) $Play = _IEGetObjById($ID, 'player-bar-play-pause') Until @error = 0 $Title = _IEGetObjById($ID,"currently-playing-title") if @error <> 0 then TraySetToolTip("Waiting for Music to start playing") _Toast_Show("C:\Users\zglam\Desktop\Google Play.jpg", "Google Play Music OSC", " Waiting for Music to start playing",-500,False) Do Sleep(50) $Title = _IEGetObjById($ID,"currently-playing-title") Until @error = 0 _Toast_hide() EndIf $Skip = _IEGetObjById($ID, 'player-bar-forward') $Rewind = _IEGetObjById($ID, 'player-bar-rewind') $oElems = _IETagNameGetCollection($ID,"paper-icon-button") For $oElem In $oElems ; loop over td tag collection Switch $oElem.icon Case "av:shuffle" $Shuffle = $oElem Case "av:replay-10" $Rewind10 = $oElem Case "av:forward-30" $Forward30 = $oElem Case "av:repeat" $repeat = $oElem EndSwitch Next EndFunc Func Load() $OSCTitle = "2F6D757369632F747261636B000000002C730000"& _StringtoHex($Title) $OSCTitle = StringFormat("%-" &(Floor(Stringlen($OSCTitle)/8) + 8) & "s",$OSCTitle) Toast_Update() $Artist = _IEGetObjById($ID,"player-artist") $Artist = _IEPropertyGet($Artist,'innerhtml') $Album = _IEGetObjById($ID,"player-album") $Album = _IEPropertyGet($Album,'innerhtml') msgbox(0,@error,$Album) UDPSend($Outgoing, "0x" & $OSCTitle) $Picture = (_IEGetObjById($ID,"playerBarArt")).src $OSCPicture ="2F6D757369632F7069637475726500002C730000"& _StringtoHex($Picture) $OSCPicture = StringFormat("%-" &(Floor(Stringlen($OSCPicture)/8) + 8) & "s",$OSCPicture) UDPSend($Outgoing, "0x" & $OSCPicture) $String = _IEBodyReadHTML($ID) $Start = StringInStr ($String, 'data-type="album" data-navigate=') $Album = StringTrimLeft($String, $Start) $Start = StringInStr ($Album, ">") $Album = StringTrimLeft($Album, $Start) $Start = StringInStr ($Album, "<") $Album = StringLeft ($Album, $Start-1) $OTitle = $Title TraySetToolTip($Title & @CRLF & " by: " & $Artist & @CRLF & " From: " & $Album) $OSCArtist = "2F6D757369632F6172746973740000002C730000"& _StringtoHex($Artist) & "0A0A" & _StringtoHex($Album) $OSCArtist = StringFormat("%-" &(Floor(Stringlen($OSCArtist)/8) + 8) & "s",$OSCArtist) UDPSend($Outgoing, "0x" & $OSCArtist) EndFunc Func Idle() while 1 sleep(500) Local $sReceived = "" $sReceived = UDPRecv($incoming, 100) if $sReceived <> "" then OSCRecieved($sReceived) $Title = (_IEGetObjById($ID,"currently-playing-title")).title if $Title <> $OTitle then Load() if $Play.title <> $PlayPause then $PlayPause = $Play.title if $PlayPause = "Play" then UDPSend($Outgoing, "0x2F6D757369632F706C617969636F6E002C730000706C617900000000") if $PlayPause = "Pause" then UDPSend($Outgoing, "0x2F6D757369632F706C617969636F6E002C7300007061757365000000") EndIf WEnd EndFunc Func OSCRecieved($sReceived) Switch $sReceived Case "0x2F6D757369632F706C6179002C6600003F800000" _IEAction($Play, "click") Case "0x2F6D757369632F736B6970002C6600003F800000" _IEAction($Skip, "click") Case "0x2F6D757369632F726577696E640000002C6600003F800000" _IEAction($Rewind, "click") Case "0x2F6D757369632F7265667265736800002C6600003F800000" Load() Case Else clipput($sReceived) ;msgbox(0,"error",$sReceived) udpsend($Outgoing, "0x2F6D757369632F6572726F72000000002C730000" & "6D65737361676520696E20636C6970626F61726400000000") EndSwitch EndFunc Func ThumbUp() $oElems = _IETagNameGetCollection($ID,"Paper-icon-button") ; get object of all td tags For $oElem In $oElems ; loop over td tag collection if $oElem.title = "Thumb-up" or $oElem.title = "Undo thumb-up" then return $oElem ExitLoop EndIf Next EndFunc Func ThumbDown() $oElems = _IETagNameGetCollection($ID,"Paper-icon-button") ; get object of all td tags For $oElem In $oElems ; loop over td tag collection if $oElem.title = "Thumb-down" or $oElem.title = "Undo thumb-down" then return $oElem ExitLoop EndIf Next EndFunc Func Toast_Update() InetGet ($Picture, @TempDir & "\GoogleOSC\Thumbnail.jpg") _Toast_Show(@TempDir & "\GoogleOSC\Thumbnail.jpg", "Google Play Music OSC", " " & $Title & @CRLF & " " & $Artist & " - " & $Album,-5,False) EndFunc