Jump to content

TinyChartsJukebox 1.0.6.2 Update of 28 June 2014 (no more Ads)


wakillon
 Share

Recommended Posts

Would you Listen Last 100 Uk Top Charts singles like a JukeBox or Radio in random order and without advertising ? :blink:

It's possible by getting charts List on charts website http://creativedisc.com/category/top-charts/uk-top-100-singles/ updated weekly
and searching songs list on youtube.


20140323152611.jpg

Changelog 1.0.6.1

Script completly rewrited.

All externals fils are includes.

New youtube search engine improved for listen the good song !

Blacklist Management improved.

Video can be visible.

Now flashplayer sound is muted while Ads. -_-

User clicks on flashplayer progress bar are now detected for the detection of the end of the song.

New Buttons.

Changelog 1.0.6.2

Adapted to new AutoIt Version and Youtube changes.

Hope you like it !  :guitar:

Previous downloads : 500

sourceTinyChartsJukebox v1.0.6.2.au3.html

executable :  TinyChartsJukebox.exe.html

(Once the html file is downloaded, double click on it for start the download)

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Very nice and useful

Might be nice if it had a tooltip saying "please wait, just retrieving song....." as I thought it wasn't working on my slow connection.

Thanks happy2help Posted Image

There is already "Waiting for Next Song..." in the Tooltip,

and

you're right, streaming depends of connection quality !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Very nice and useful

Might be nice if it had a tooltip saying "please wait, just retrieving song....." as I thought it wasn't working on my slow connection.

Strange - What OS have you tested this on? My Win7 didn't display the upper tooltip - hence my suggestion - but when I tried it on my XP machine it works fine? :blink:

Link to comment
Share on other sites

Strange - What OS have you tested this on? My Win7 didn't display the upper tooltip - hence my suggestion - but when I tried it on my XP machine it works fine? :blink:

Sorry I did not say which os I have run it ! Posted Image

and not tested on win7... ( I prefer xp for his simplicity ) Posted Image

Perhaps Tooltips doesn't works well on Win7 ? i can't try it, i have suppress my win 7 partition.

I'll try to add a little gui... ok ? Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Just a little cosmetic thing - it would be nice to have the tooltip display the song title and artist separately, even just with a " - " between would make it easier to read.

ok i'm working on Posted Image

Very cool job.

Thanks for this share !

Thank's pierrotm777 ! Posted Image

I want specify that the waiting time is more due to the IE opening than the search ! Posted Image

Soon a gui interface with manual selection...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I have added a sort by order !

Add to the beginning of the script:

If Not FileExists("Settings.ini") Then

IniWrite("Settings.ini", "WebRadio", "WindowsName", "WebRadio")

IniWrite("Settings.ini", "WebRadio", "SortBy", "order")

EndIf

$SortBy = IniRead("Settings.ini", "WebRadio", "SortBy", "")

replace the line 53 by:

If $SortBy = "randomize" Then $_R = _Randomize ( $_LastUkTopChartsListArray[0] );choix au hazard

If $SortBy = "order" Then $_R = _ByOrder ( $_LastUkTopChartsListArray[0] );choix par ordre de 1 à 100

Func _ByOrder ( $_Max=100 );choice by order

Do

If $_Order < 100 Then

$_Order = $_Order+1

EndIf

If $_Order =100 Then

$_Order = 0

$_Order = $_Order+1

EndIf

Until Not _AlreadyInArray ( $_OrderArray, $_Order )

_ArrayAdd ( $_OrderArray, $_Order )

Return $_Order

EndFunc ;==> _ByOrder ( )

If some one has an idea for to add a choice by number

Link to comment
Share on other sites

So, with a Tiny graphical interface this JukeBox is nicer... Posted Image

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Radio.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs -----------------------------------------------------------------------------------------------------------

 AutoIt Version  : 3.3.6.1
 Author          : Wakillon
 Title          : TinyUKChartsStreamPlayer
 Script Fonction : Listen Last 100 Uk Top Charts singles like a radio in random order and without advertising
                by getting charts List on charts website and search song's list on youtube.
                _ Right Arrow for Next random song
                _ ESC for Quit
                _ WebSite http://www.theofficialcharts.com/singles-chart/ is updated weekly

#ce -----------------------------------------------------------------------------------------------------------
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIStatusBar.au3>
#Include <GuiListView.au3>
#include <String.au3>
#include <File.au3>
#include <Misc.au3>
#include <Date.au3>
#include <IE.au3>

HotKeySet ( "{ESC}", "_Terminate" )
If Not _Singleton ( @ScriptName, 1 ) Then Exit 

Dim $_RandomArray[1], $_TimerInit = TimerInit ( ), $Sec, $Min, $Hour, $Time, $_Spaces='        '
Dim $_Text=$_Spaces & '_ Right Arrow for Next random song' & @Crlf & $_Spaces & '_ ESC for Quit'
Dim $_DurationDiff, $_DurationMs, $_GetItem, $_Auto=1, $oIE, $_SelectOld, $_PicShow=0
Global $_Duration, $_UpDateDate, $_ImagesUrlArray[1]
Global $_Invert=True
Global $_InvertTimerInit=TimerInit ( )
Global $_StatusParts[1] = [500]
Global $_TempStatus[1] = [""]
Global $__SLIDE_aGUI[1][5] = [["Winhandle", "sSide", "sState", "locked", "OnHover"]]
Global $__SLIDE_hDLL = DllOpen ( "user32.dll" ) 

AdlibRegister ( "__Slide_CheckHover", 100 )
OnAutoItExitRegister ( "__Slide_UnloadDLL" )
Opt ( "TrayMenuMode", 1 )
TraySetIcon ( "Shell32.dll", -129 ) 
TraySetToolTip ( "   TinyUKChartsStreamPlayer" & @Crlf & StringStripWS ( $_Text, 7 ) ) 
TraySetState ( 4 ) 

_ProcessClose ( 'iexplore.exe' )
OnAutoItExitRegister ( "_OnAutoItExit" )    
If Not FileExists ( @TempDir & '\Pics' ) Then DirCreate ( @TempDir & '\Pics' )

Do    
    Sleep ( 1000 )
    ToolTip ( $_Spaces & 'Waiting for Internet connection', @DesktopWidth/2-100, 0, 'Tiny UK Charts Stream Player', 1, 4 )
Until _IsConnected ( )

ToolTip ( $_Spaces & 'Searching Last 100 Uk Top Charts List...' & @Crlf & @Crlf & $_Text, @DesktopWidth/2-100, 0, 'Tiny UK Charts Stream Player', 1, 4 )
$_LastUkTopChartsListArray = _GetLastUkTopChartsListArray2 ( 'http://www.theofficialcharts.com/singles-chart/' )
If _IsArrayEmpty ( $_LastUkTopChartsListArray ) Then Exit MsgBox ( 0, 'Error', 'Sorry Uk Top Charts List Not Found !', 5 )
Dim $ListViewItem[UBound ( $_LastUkTopChartsListArray )]
Dim $_SelectButtonWidth = 120, $_X=368

$_Gui                      = GUICreate ( 'Tiny UK Charts Stream Player ' & $_UpDateDate, 500, 330, @DesktopWidth-507, @DesktopHeight - 360, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
                        GUISetBkColor ( 0xFFD900 ) 
                            GUISetIcon ( "Shell32.dll", -129 )
$_ListView  = GUICtrlCreateListView ( "Top Nb|Title - Artist", 15, 20, 340, 260 )
    _GUICtrlListView_SetColumnWidth ( $_ListView, 1, $LVSCW_AUTOSIZE_USEHEADER )
For $_G = 1 To UBound ( $_LastUkTopChartsListArray ) - 1
    $ListViewItem[$_G] = GUICtrlCreateListViewItem ( StringFormat ( "%02i", $_G ) & "|" & $_LastUkTopChartsListArray[$_G], $_ListView )
Next
$_SelectButton   = GUICtrlCreateButton ( "Listen Selected Song", $_X, 221, $_SelectButtonWidth, 24 ) 
                       GUICtrlSetState ( $_SelectButton, $GUI_DISABLE ) 
$_ExitButton    = GUICtrlCreateButton ( "Exit", $_X, 257, $_SelectButtonWidth, 24 ) 
$_RandomButton   = GUICtrlCreateButton ( "Disable Random Mode", $_X, 149, $_SelectButtonWidth, 24 )                 
                    GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 )  
                    GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) 
$_NextButton    = GUICtrlCreateButton ( "Next Random Song", $_X, 185, $_SelectButtonWidth, 24 )                 
            $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X, 20, 118, 118, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) 
$_StatusBar = _GUICtrlStatusBar_Create ( $_Gui, $_StatusParts, $_TempStatus, $SBARS_SIZEGRIP )
        _GUICtrlStatusBar_SetMinHeight ( $_StatusBar, 40 )
    $_Icons = _WinAPI_LoadShell32Icon ( 128 )
            _GUICtrlStatusBar_SetIcon ( $_StatusBar, 0, $_Icons )
                    _Slide_WinSetSlide ( $_Gui, "top" ) 
                _Slide_SlideSetOnHover ( $_Gui ) 
                        GUISetState ( @SW_SHOW )
                               ToolTip ( '' )


While 1
    If $_Auto Then
        $_R = _Randomize ( $_LastUkTopChartsListArray[0] ) 
        _GUICtrlStatusBar_SetText ( $_StatusBar, ' Waiting for Next Song...', 0 )   
        $_YoutubeSearch = _YoutubeSearch ( $_LastUkTopChartsListArray[$_R]& ' official' )
        If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/watch?v' ) <> 0 Then 
            $oIE = _IECreate ( $_YoutubeSearch, 0, 0, 1 )
            $_DurationInit = TimerInit ( )
            $_DurationDiff=0
            For $_P = 1 To $_ImagesUrlArray[0]
                $_PicPath = @TempDir & '\Pics\' & $_LastUkTopChartsListArray[$_P] & '.jpg'
                If Not FileExists ( $_PicPath ) Then InetGet ( $_ImagesUrlArray[$_P], $_PicPath, 0, 1 )
            Next
            $_PicPath = @TempDir & '\Pics\' & $_LastUkTopChartsListArray[$_R] & '.jpg'
            If FileExists ( $_PicPath ) Then
                GUICtrlSetState ( $_Pic, $GUI_HIDE )
                $_Pic = GUICtrlCreatePic ( $_PicPath, $_X, 20, 118, 118, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) )    
            EndIf   
        Else    
            _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_LastUkTopChartsListArray[$_R] & @Crlf & 'Music Not Found !', 0 )    
            Sleep ( 2000 )
        EndIf
    EndIf   
    While 1
        If $_DurationDiff > $_DurationMs Or ( $_Auto And _IsPressed ( "27" ) ) Then
            _IEQuit ( $oIE ) 
            $_GetItem=''
            $_Duration=0
            $_DurationInit=0
            $_DurationDiff=0
            $_PicShow=0
            ExitLoop 
        EndIf       
        Sleep ( 20 )
        $_Msg = GUIGetMsg ( )
        Switch $_Msg
            Case $_SelectButton 
                _IEQuit ( $oIE ) 
                $_PicShow=0
                $_GetItem = _GetItem ( )
                If $_GetItem Then
                    _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Waiting for Next Song...', 0 )
                    $_YoutubeSearch = _YoutubeSearch ( $_GetItem & ' official' )
                    $oIE = _IECreate ( $_YoutubeSearch, 0, 0, 1 )
                    $_DurationInit = TimerInit ( )
                    $_DurationDiff=0
                    $_PicPath = @TempDir & '\Pics\' & $_GetItem & '.jpg'
                    If FileExists ( $_PicPath ) Then
                        GUICtrlSetState ( $_Pic, $GUI_HIDE )
                        $_Pic = GUICtrlCreatePic ( $_PicPath, $_X, 20, 118, 118, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) )    
                    EndIf
                EndIf
            Case $_NextButton
                _IEQuit ( $oIE ) 
                $_GetItem=''
                $_Duration=0
                $_DurationInit=0
                $_DurationDiff=0
                $_PicShow=0
                ExitLoop                    
            Case $_RandomButton 
                _IEQuit ( $oIE ) 
                $_PicShow=0
                If $_Auto = 1 Then 
                    $_Auto=0
                    GUICtrlSetState ( $_SelectButton, $GUI_ENABLE ) 
                    GUICtrlSetState ( $_NextButton, $GUI_DISABLE )
                    GUICtrlSetState ( $_RandomButton, $GUI_HIDE )
                    $_RandomButton = GUICtrlCreateButton ( "Enable Random Mode", $_X, 146, $_SelectButtonWidth, 24 ) 
                    GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 )  
                    GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) 
                Else    
                    $_Auto = 1
                    GUICtrlSetState ( $_SelectButton, $GUI_DISABLE )
                    GUICtrlSetState ( $_RandomButton, $GUI_HIDE )
                    GUICtrlSetState ( $_NextButton, $GUI_ENABLE )
                    $_RandomButton = GUICtrlCreateButton ( "Disable Random Mode", $_X, 146, $_SelectButtonWidth, 24 ) 
                    GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 )  
                    GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) 
                    ExitLoop 
                EndIf   
            Case $GUI_EVENT_CLOSE
                GUIDelete ( )   
                _Terminate ( )
            Case $_ExitButton
                GUIDelete ( )    
                _Terminate ( )              
            Case $_Msg <> 0
                $_Select = _GetItem ( )
                If $_Select <> $_SelectOld Then
                    $_PicPath = @TempDir & '\Pics\' & $_Select & '.jpg'
                    If FileExists ( $_PicPath ) Then
                        GUICtrlSetState ( $_Pic, $GUI_HIDE )
                        $_Pic = GUICtrlCreatePic ( $_PicPath, $_X, 20, 118, 118, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) )    
                    EndIf
                    $_SelectOld = $_Select
                    $_Select=''
                EndIf               
        EndSwitch
        If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) 
        $_DurationMs = $_Duration * 1000    
        If $_Duration Then $_DurationDiff = Round ( TimerDiff ( $_DurationInit ) )
        _TicksToTime ( $_DurationMs - $_DurationDiff, $Hour, $Min, $Sec )
        If $_Auto Then  
            $_Text2 = $_LastUkTopChartsListArray[$_R]
        Else
            $_Text2 = $_GetItem
        EndIf
        If $_Text2 Then 
            _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_Text2 & ' - ' & StringFormat ( "%02i:%02i", $Min, $Sec ), 0 )
            If Not $_PicShow Then
                $_PicPath = @TempDir & '\Pics\' & $_Text2 & '.jpg'
                If FileExists ( $_PicPath ) Then
                    GUICtrlSetState ( $_Pic, $GUI_HIDE )
                    $_Pic = GUICtrlCreatePic ( $_PicPath, $_X, 20, 118, 118, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) 
                    $_PicShow = 1               
                EndIf
            EndIf   
        EndIf
    WEnd
WEnd

Func _InvertColorButton ( $_GuiCtrl )
    If $_Invert Then
        GUICtrlSetBkColor ( $_GuiCtrl, 0xFF0000 )  
        GUICtrlSetColor ( $_GuiCtrl, 0xFFFF00 ) 
        $_Invert=False
    Else
        GUICtrlSetBkColor ( $_GuiCtrl, 0xFFFF00 )  
        GUICtrlSetColor ( $_GuiCtrl, 0xFF0000 )     
        $_Invert=True
    EndIf
EndFunc ;==> _InvertColorButton ( )

Func _EachXseconds ( $_Interval )
    $_TimerDiff = Round ( TimerDiff ( $_InvertTimerInit )/ 1000 )
    If $_TimerDiff >= $_Interval Then
        $_InvertTimerInit = TimerInit ( )
        Return 1
    Else
        Return 0
    EndIf
EndFunc ;==> _EachXseconds ( )

Func _GetItem ( )
    $_Select = GUICtrlRead ( GUICtrlRead ( $_ListView ) ) 
    $_Stringlen = Stringlen ( $_Select )
    $_Select = StringReplace ( StringRight ( $_Select, $_Stringlen - 3 ), '|', '' )
    If $_Select Then Return $_Select 
EndFunc ;==> _GetItem ( )

Func _GetLastUkTopChartsListArray2 ( $_LastChartsUrl )
    Local $_NamesArray[1], $_Add
    $_LastChartPageSourceCode = _GetSourceCode ( $_LastChartsUrl )  
    $_UpDateDate = _StringBetween ( $_LastChartPageSourceCode, '"date"> -', "<" )               
    If Not @error Then $_UpDateDate = '( Week of ' & StringStripWS ( $_UpDateDate[0], 7 ) & ' )'
    $_LastChartsArray = StringSplit ( $_LastChartPageSourceCode, @CRLF ) 
    Local $_ChartsArray[1] 
    For $_I = 1 To UBound ( $_LastChartsArray ) -1
        If StringInStr ( $_LastChartsArray[$_I], '</h4>' ) <> 0 Then
            $_Title = _StringBetween ( $_LastChartsArray[$_I], '<h4>', '</h4>' )
            If Not @error Then
                $_Artist = StringReplace ( $_LastChartsArray[$_I+2], '<br />', '' )
                $_Name = _CleanVideoName ( $_Title[0] & ' - ' & $_Artist )
                If Not _AlreadyInArray ( $_NamesArray, $_Name ) Then 
                    _ArrayAdd ( $_NamesArray, $_Name )
                    $_Add = $_Add + 1
                    If $_I+43 < UBound ( $_LastChartsArray ) -1 Then
                        For $_J = $_I-3 To $_I+3
                            $_ImagesUrl = _StringBetween ( $_LastChartsArray[$_J], 'coverimage" src="', '"' )               
                            If Not @error Then 
                                $_ImagesUrl = $_ImagesUrl[0]
                                If StringLeft ( $_ImagesUrl, 4 ) <> 'http' Then $_ImagesUrl = 'http://www.theofficialcharts.com' & $_ImagesUrl
                                If Not _IsValidUrl ( $_ImagesUrl ) Then $_ImagesUrl=''
                            _ArrayAdd ( $_ImagesUrlArray, $_ImagesUrl )
                            EndIf 
                        Next
                    EndIf 
                EndIf 
            EndIf 
        EndIf 
    Next 
    $_ImagesUrlArray[0] = UBound ( $_ImagesUrlArray ) -1
    $_NamesArray[0] = UBound ( $_NamesArray ) -1
    Return $_NamesArray
EndFunc ;==> _GetLastUkTopChartsListArray2 ( )

Func _YoutubeSearch ( $_Query )
    Dim $_WordOfQuery[1]
    $_QuerySplit = StringSplit ( StringStripWS ( StringRegExpReplace ( StringReplace ( StringReplace ( $_Query, 'è', 'e' ), 'é', 'e' ), "\W", " " ) , 7 ), ' ' )
    For $_I = 1 To UBound ( $_QuerySplit ) - 1
    If StringLen ( $_QuerySplit[$_I] ) > 1 Then _ArrayAdd ( $_WordOfQuery, StringReplace ( $_QuerySplit[$_I], ',', ' ' ) )
    Next
    $_WordOfQuery[0] = UBound ( $_WordOfQuery ) - 1 
    $_Query = StringReplace ( $_Query, " ", "+" )
    $_Query = StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace _
    ( StringReplace ( StringStripWS ( $_Query, 7 ), ',', '%2C' ), '&', '%26' ), '(', '%28' ), ')', '%29' ), "'", '%27' ), 'è', 'e' ), 'é', 'e' ), '«', ' ' ), '»', ' ' )
    $_SourceCode = _GetSourceCode ( "http://www.youtube.com/results?search_query=" & $_Query ) 
    $_SourceCodeSplit = StringSplit ( $_SourceCode, @CRLF )     
    Dim $_Watch[1] 
    For $_I = 1 To UBound ( $_SourceCodeSplit )-1
        If StringInStr ( $_SourceCodeSplit[$_I], '/watch?v=' ) <> 0 And StringInStr ( $_SourceCodeSplit[$_I], 'video-long-title' ) <> 0 Then
            _ArrayAdd ( $_Watch, $_SourceCodeSplit[$_I] )
        EndIf 
    Next    
    For $_I = 1 To UBound ( $_Watch )-1
        $Titles = _StringBetween ( $_Watch[$_I], 'title="', '" rel=' )
        If Not @error Then 
            If Not _OneOfThisStringInStr ( $Titles[0], 'Karaok|lyrics|Singing|parod' ) Then
                $_Duration = _StringBetween ( $_SourceCode, 'time">', '<' ) 
                If Not @error Then 
                    $_Duration = StringSplit ( $_Duration[0], ':' )
                    $_Duration = $_Duration[1]*60 + $_Duration[2]
                    $Link = _StringBetween ( $_Watch[$_I], 'href="', '"' )  
                    If Not @error Then 
                        If StringInStr ( $Link[0], 'http://www.youtube.com' ) = 0 Then 
                            $_UrlToExtract = "http://www.youtube.com" & $Link[0]
                        Else
                            $_UrlToExtract = $Link[0]
                        EndIf
                        Return $_UrlToExtract
                    EndIf
                EndIf
            EndIf   
        EndIf
    Next 
Endfunc ;==> _YoutubeSearch ( )

Func _OneOfThisStringInStr ( $_InStr, $_String )
    $_StringArray = StringSplit ( $_String, '|' ) 
    If @error Then Return 0
    For $_I = 1 To UBound ( $_StringArray ) -1
        $_StringInStr = StringInStr ( $_InStr, $_StringArray[$_I] ) 
        If $_StringInStr <> 0 Then Return 1 
    Next
    Return 0
EndFunc ;==> _OneOfThisStringInStr ( )

Func _CleanVideoName ( $_Name )
    $_Name2 = StringRegExpReplace ( $_Name, '(&quot;)|(&quot;)|(quot;)|(&amp;)|(amp;)|(&lt;)|(lt;)|(&gt;)|(gt;)|(#39;)', '' )   
    $_Name2 = StringReplace ( $_Name2, 'ç', 'c' )    
    $_Name2 = StringReplace ( $_Name2, 'ß', 'ss' )       
    $_Name2 = StringReplace ( $_Name2, '€', '€' )   
    $_Name2 = StringRegExpReplace ( $_Name2, '(à )|(â)|(ä)|(À)|(ã)|(á)|(Ã¥)', 'a' )
    $_Name2 = StringRegExpReplace ( $_Name2, '(Ú)|(ê)|(é)|(è)|(ë)', 'e' )
    $_Name2 = StringRegExpReplace ( $_Name2, '(ï)|(î)|(Ã)', 'i' )
    $_Name2 = StringRegExpReplace ( $_Name2, '(ÃŽ)|(ö)|(ó)|(ô)', 'o' )
    $_Name2 = StringRegExpReplace ( $_Name2, '(û)|(ü)|(ù)|(ÃŒ)|(ú)', 'u' )
    $_Name2 = StringReplace ( $_Name2, 'Ã', 'a' )      
    $_Name2 = StringReplace ( $_Name2, '\', '' )    
    $_Name2 = StringRegExpReplace ( $_Name2, "[|!?_*~´’'`³¹¼¯,]", ' ' )  
    $_Name2 = StringRegExpReplace ( $_Name2, '[âªâ™«»¥¶£¢€¡†Ø§³ÙŠšØ¹±ª#®¤©‰¨¹¬·/;:"]', '' )  
    Return _StringProper ( StringStripWS ( _CleanHtmlName ( $_Name2 ), 7 ) )
EndFunc ;==> _CleanVideoName ( )

Func _CleanHtmlName ( $_Name )
    $_Name2 = StringReplace ( $_Name, '%2C', ',' )
    $_Name2 = StringReplace ( $_Name2, '%82', ',' )
    $_Name2 = StringReplace ( $_Name2, '%27', "'" )
    $_Name2 = StringReplace ( $_Name2, '&039', "'" )    
    Return $_Name2
EndFunc ;==> _CleanHtmlName ( )

Func _Randomize ( $_Max=100 )   
    Do 
        $_Random = Random ( 1, $_Max, 1 )
    Until Not _AlreadyInArray ( $_RandomArray, $_Random )
    _ArrayAdd ( $_RandomArray, $_Random ) 
    If UBound ( $_RandomArray ) -1 >= $_Max Then ReDim $_RandomArray[1]
    Return $_Random
EndFunc ;==> _Randomize ( ) 

Func _AlreadyInArray ( $_SearchArray, $_Item )
    $_Index = _ArraySearch ( $_SearchArray, $_Item ) 
    If @error Then      
        Return False
    Else  
        If  $_Index <> 0 Then
            Return True
        Else 
            Return False
        EndIf   
    EndIf
EndFunc ;==> _AlreadyInArray ( )
 
Func _GetSourceCode ( $_Url )
    $_InetRead = InetRead ( $_Url )
    If Not @Error Then
        $_BinaryToString = BinaryToString ( $_InetRead )
        If Not @Error Then Return $_BinaryToString
    EndIf   
EndFunc ;==> _GetSourceCode ( )

Func _IsArrayEmpty ( $_EmptyArray )
    Local $_V = UBound ( $_EmptyArray ) -1, $_P 
    If $_V = 0 Then Return True
    For $_F = 1 To $_V      
        If $_EmptyArray[$_F] = '' Then $_P = $_P + 1
    Next
    If $_P = $_V Then 
        Return True
    Else
        Return False
    EndIf
EndFunc ;==> _IsArrayEmpty ( )

Func _IsConnected ( )
    $_SrcFilePath = _TempFile ( @TempDir & "\", '~google_', ".src", 7 ) 
    Local $IsConnected = InetGet ( "http://www.google.com", $_SrcFilePath, 1, 1 )
    Local $_Info 
    Do
        $_Info = InetGetInfo ( $IsConnected )
        Sleep ( 50 )
    Until $_Info[2] = True 
    InetClose ( $IsConnected )
    _Delete ( $_SrcFilePath )   
    If $_Info[3] <> True Then   
        Return 0
    Else
        Return 1
    EndIf   
EndFunc ;==> _IsConnected ( )

Func _IsValidUrl ( $_IsValidUrl )
    $_Size = InetGetSize ( $_IsValidUrl ) 
    If $_Size <> 0 Then Return 1    
Endfunc ;==> _IsValidUrl ( )

Func _Delete ( $_FullPath )
    $_DeleteInit = TimerInit ( )
    While FileExists ( $_FullPath ) 
        If StringInStr ( FileGetAttrib ( $_FullPath ), "D" ) Then 
            DirRemove ( $_FullPath, 1 )
        Else
            FileDelete ( $_FullPath )
        EndIf
        If TimerDiff ( $_DeleteInit ) > 5000 Then Return 0
    WEnd
    Return 1    
EndFunc ;==> _Delete ( ) 

Func _ProcessClose ( $_ProcessName )
    While ProcessExists ( $_ProcessName )
        ProcessClose ( $_ProcessName )  
    WEnd
EndFunc ;==> _ProcessClose ( )

Func _Terminate ( )
    _IEQuit ( $oIE ) 
    _ProcessClose ( 'iexplore.exe' )
    Exit 
EndFunc ;==> _Terminate ( )

Func _OnAutoItExit ( )
    Opt ( "TrayIconHide", 0 ) 
    TrayTip ( "TinyUKChartsStreamPlayer", "        by wakillon...", 1, 1 )
    Sleep ( 2000 )
    TrayTip ( '', '', 1, 1 )
EndFunc ;==> _OnAutoItExit ( ) 

Func _Slide_WinSetSlide ( $hWnd, $sSide, $iMode = 1 )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    If @error Then Return SetError ( 1, 0, 0 )
    If $iMode > 1 Or $iMode < 0 Then Return SetError ( 1, 0, 0 )
    If Not StringRegExp ( $sSide, "(?i)(left|right|top|bottom)" ) Then Return SetError ( 1, 0, 0 )
    $iUbound = UBound ( $__SLIDE_aGUI )
    Switch $iMode
        Case 1
            ReDim $__SLIDE_aGUI[$iUbound + 1][5]
            $__SLIDE_aGUI[$iUbound][0] = $hWnd
            $__SLIDE_aGUI[$iUbound][1] = $sSide
            $__SLIDE_aGUI[$iUbound][2] = True
            $__SLIDE_aGUI[$iUbound][3] = False
            $__SLIDE_aGUI[$iUbound][4] = False
            _Slide_SlideOut ( $hWnd )
            GUISetState ( @SW_SHOWNOACTIVATE, $hWnd )
        Case 0
            For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
                If $__SLIDE_aGUI[$i][0] = $hWnd Then
                    For $j = $i To UBound($__SLIDE_aGUI) - 2
                        $__SLIDE_aGUI[$j][0] = $__SLIDE_aGUI[$j + 1][0]
                        $__SLIDE_aGUI[$j][1] = $__SLIDE_aGUI[$j + 1][1]
                        $__SLIDE_aGUI[$j][2] = $__SLIDE_aGUI[$j + 1][2]
                        $__SLIDE_aGUI[$j][3] = $__SLIDE_aGUI[$j + 1][3]
                        $__SLIDE_aGUI[$j][4] = $__SLIDE_aGUI[$j + 1][4]
                        ReDim $__SLIDE_aGUI[UBound ( $__SLIDE_aGUI ) - 1][5]
                        _Slide_SlideIn ( $hWnd )
                        GUISetState ( @SW_HIDE, $hWnd )
                    Next
                EndIf
            Next
    EndSwitch
EndFunc ;==> _Slide_WinSetSlide ( )

Func _Slide_SlideSetOnHover ( $hWnd, $sMode = True )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    If @error Then Return SetError ( 1, 0, 0 )
    $iUbound = UBound ( $__SLIDE_aGUI )
    Switch $sMode
        Case True
            For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
                If $__SLIDE_aGUI[$i][0] = $hWnd Then
                    $__SLIDE_aGUI[$i][4] = True
                EndIf
            Next
        Case False
            For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
                If $__SLIDE_aGUI[$i][0] = $hWnd Then
                    $__SLIDE_aGUI[$i][4] = False
                EndIf
            Next
    EndSwitch
EndFunc ;==> _Slide_SlideSetOnHover ( )

Func _Slide_SlideOut ( $hWnd )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    If @error Then Return SetError ( 1, 0, 0 )
    For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
        If $__SLIDE_aGUI[$i][0] = $hWnd Then
            If $__SLIDE_aGUI[$i][2] Then
                __Slide_WinSlide ( $hWnd, "out", $__SLIDE_aGUI[$i][1] )
                $__SLIDE_aGUI[$i][2] = False
                Return SetError ( 0, 0, 1 )
            Else
                Return SetError ( 3, 0, 0 )
            EndIf
        EndIf
    Next
    Return SetError ( 2, 0, 0 )
EndFunc ;==> _Slide_SlideOut ( )

Func _Slide_SlideIn ( $hWnd )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    If @error Then Return SetError ( 1, 0, 0 )
    For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
        If $__SLIDE_aGUI[$i][0] = $hWnd Then
            If Not $__SLIDE_aGUI[$i][2] Then
                __Slide_WinSlide ( $hWnd, "in", $__SLIDE_aGUI[$i][1] )
                $__SLIDE_aGUI[$i][2] = True
            Else
                Return SetError ( 3, 0, 0 )
            EndIf
        EndIf
    Next
    Return SetError ( 2, 0, 0 )
EndFunc ;==> _Slide_SlideIn ( )

Func __Slide_WinSlide ( $hWnd, $sMode, $sSide )
    Local $aScreen_Res = WinGetPos ( WinGetHandle ( "Program Manager" ) )
    Local $aWPos = WinGetPos ( $hWnd ), $m = 0 - ( $sMode = "in" ) + ( $sMode = "out" )
    Local $h = 0 - ( $sSide = "left" ) + ( $sSide = "right" ), $v = 0 - ( $sSide = "top" ) + ( $sSide = "bottom" )
    WinMove ( $hWnd, "", $aScreen_Res[0] - ( ( $h = -1 ) * ( $m = -1 ) * ( $aWPos[2] - 10 ) ) _
            + ( ( $h = 1 ) * ( ( $h = 1 ) * $aScreen_Res[2] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[2] ) ) _
            + ( ( $h = 0 ) * ( ( $h = 0 ) * ( $aScreen_Res[2] / 2 ) - ( $aWPos[2] / 2 ) ) ) _
            , $aScreen_Res[1] - ( ( $v = -1 ) * ( $m = -1 ) * ( $aWPos[3] - 10 ) ) _
            + ( ( $v = 1 ) * ( ( $v = 1 ) * $aScreen_Res[3] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[3] ) ) _
            + ( ( $v = 0 ) * ( ( $v = 0 ) * ( $aScreen_Res[3] / 2 ) - ($aWPos[3] / 2 ) ) ) )
    $aWPos = WinGetPos ( $hWnd )
    Switch $sSide
        Case "left", "right"
            Local $STEP = ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) - ( ( ( $h = -1 ) And ( $m = 1 ) ) Or ( ( $h = 1 ) And ( $m = -1 ) ) ) ) * 10
            Local $FROM = $aWPos[0], $TO = $aWPos[0] + ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[2] ) ) _
                     - ( ( ( ( $h = 1 ) And ( $m = -1 ) ) Or ( ( $h = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[2] ) ) - $STEP
            For $i = $aWPos[0] To $TO Step $STEP
                WinMove ( $hWnd, "", $i, $aWPos[1] )
                Sleep ( 10 )
            Next
        Case "top", "bottom"
            Local $STEP = ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) - ( ( ( $v = -1 ) And ( $m = 1 ) ) Or ( ( $v = 1 ) And ( $m = -1 ) ) ) ) * 10
            Local $FROM = $aWPos[1], $TO = $aWPos[1] + ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[3] ) ) _
                     - ( ( ( ( $v = 1 ) And ( $m = -1 ) ) Or ( ( $v = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[3] ) ) - $STEP     ;ConsoleWrite ( "$STEP : " & $STEP & @Crlf )        
            If $STEP > 0 Then $TO = $TO -25
            For $i = $aWPos[1] To $TO + 25 Step $STEP ; 
                WinMove ( $hWnd, "", $aWPos[0], $i )
                Sleep ( 10 )
            Next
    EndSwitch
EndFunc ;==> __Slide_WinSlide ( )

Func __Slide_CheckHover ( )
    For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
        If $__SLIDE_aGUI[$i][4] Then
            If Not $__SLIDE_aGUI[$i][3] Then
                If __Slide_WinIsHovered ( $__SLIDE_aGUI[$i][0] ) Then
                    If Not $__SLIDE_aGUI[$i][2] Then _Slide_SlideIn ( $__SLIDE_aGUI[$i][0] )
                Else
                    If $__SLIDE_aGUI[$i][2] Then _Slide_SlideOut ( $__SLIDE_aGUI[$i][0] )
                EndIf
            EndIf
        EndIf
    Next
EndFunc ;==> __Slide_CheckHover ( )

Func __Slide_UnloadDLL ( )
    DllClose ( $__SLIDE_hDLL )
EndFunc ;==> __Slide_UnloadDLL ( )

Func __Slide_WinIsHovered ( $hWnd, $vDLL = "User32.dll" )
    Local $aResult, $aWPos = WinGetPos ( $hWnd ) 
    If @error Then Return 
    Local $aMPos = MouseGetPos ( )
    If @error Then Return   
    Local $tRect = DllStructCreate ( "int Left;int Top;int Right;int Bottom" )
    Local $iLeft = $aWPos[0], $iTop = $aWPos[1], $iWidth = $aWPos[2], $iHeight = $aWPos[3]
    Local $iX = $aMPos[0], $iY = $aMPos[1]
    DllStructSetData ( $tRect, "Left", $iLeft )
    DllStructSetData ( $tRect, "Top", $iTop )
    DllStructSetData ( $tRect, "Right", $iLeft + $iWidth )
    DllStructSetData ( $tRect, "Bottom", $iTop + $iHeight )
    $aResult = DllCall ( $vDLL, "int", "PtInRect", "ptr", DllStructGetPtr ( $tRect ), "int", $iX, "int", $iY )
    If @error Then Return SetError ( @error, 0, False )
    Return $aResult[0] <> 0
EndFunc ;==> __Slide_WinIsHovered ( )

And Thanks to SEuBo for his _Slide Fonctions ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I remove the OnTop gui attrib, who could interfere and to save time at startup

i add a backup registry with a control of website update and

an image of the record cover !

And we can now select music genre otherwise random genre will be select after 10 sec ! Posted Image

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Radio.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs -----------------------------------------------------------------------------------------------------------

 AutoIt Version  : 3.3.6.1
 Author          : Wakillon
 Title          : TinyUKChartsStreamPlayer
 Script Fonction : Listen Last 100 Uk Top Charts singles like a radio in random order and without advertising
                by getting charts List on charts website and search song's list on youtube.
                _ Right Arrow for Next random song
                _ ESC for Quit
                _ WebSite http://www.theofficialcharts.com/singles-chart/ is updated weekly
                
#ce -----------------------------------------------------------------------------------------------------------
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIStatusBar.au3>
#Include <GuiListView.au3>
#include <String.au3>
#include <File.au3>
#include <Misc.au3>
#include <Date.au3>
#include <IE.au3>

HotKeySet ( "{ESC}", "_Terminate" )
If Not _Singleton ( @ScriptName, 1 ) Then Exit 

Dim $Sec, $Min, $Hour, $Time, $_SelectButtonWidth = 120, $_X=368, $_PicSize=100, $_Spaces='        '
Dim $_Text=$_Spaces & '_ Right Arrow for Next random song' & @Crlf & $_Spaces & '_ ESC for Quit'
Dim $_DurationDiff, $_DurationMs, $_GetItem, $_Auto=1, $_IE, $_SelectOld, $_PicShow=0
Dim $_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\TinyUKChartsStreamPlayer"
Global $_LastUkTopChartsListArray[1], $_ImagesUrlArray[1], $_RandomArray[1]
Global $_Duration, $_UpDateDate, $_LastChartPageSourceCode, $_Invert=True, $_InvertTimerInit=TimerInit ( )
Global $_StatusParts[1] = [500], $_TempStatus[1] = [""]
Global $__SLIDE_aGUI[1][5] = [["Winhandle", "sSide", "sState", "locked", "OnHover"]]
Global $__SLIDE_hDLL = DllOpen ( "user32.dll" ) 

Opt ( "TrayMenuMode", 1 )
TraySetIcon ( "Shell32.dll", -129 ) 
TraySetToolTip ( "   TinyUKChartsStreamPlayer" & @Crlf & StringStripWS ( $_Text, 7 ) ) 
TraySetState ( 4 )

AdlibRegister ( "__Slide_CheckHover", 100 )
OnAutoItExitRegister ( "_OnAutoItExit" )    
If Not FileExists ( @TempDir & '\Pics' ) Then DirCreate ( @TempDir & '\Pics' )

Do    
    Sleep ( 1000 )
    ToolTip ( $_Spaces & 'Waiting for Internet connection', @DesktopWidth/2-100, 0, 'Tiny UK Charts Stream Player', 1, 4 )
Until _IsConnected ( )
ToolTip ( '' )

$_Genre = StringSplit ( 'singles-chart|rock-and-metal-singles-chart|catalogue-singles-chart|dance-singles-chart', '|' )
$_SubKey = _SelectGenre ( ) 
$_LastChartsUrl = 'http://www.theofficialcharts.com/' & $_SubKey & '/'
$_UpdateDate = _GetUpdateDate ( $_LastChartsUrl )
$_RegUpdateDate = RegRead ( $_Key & '\' & $_SubKey, 'UpdateDate' )

If $_UpdateDate <> $_RegUpdateDate Then 
    ToolTip ( $_Spaces & 'Searching Last 100 Uk Top Charts List...' & @Crlf & @Crlf & $_Text, @DesktopWidth/2-100, 0, 'Tiny UK Charts Stream Player', 1, 4 )
    RegDelete ( $_Key & '\' & $_SubKey )
    $_LastUkTopChartsListArray = _GetLastUkTopChartsListArray ( $_LastChartPageSourceCode ) 
    ToolTip ( '' )
Else
    For $_J = 1 To 100
        $_Value = RegEnumVal ( $_Key & '\' & $_SubKey, $_J )        
        If @error <> 0 Then ExitLoop 
        If StringInStr ( $_Value, 'UpdateDate' ) = 0 Then 
            $_RegRead = RegRead ( $_Key & '\' & $_SubKey, $_Value )
            _ArrayAdd ( $_LastUkTopChartsListArray, $_RegRead )
        EndIf
    Next 
EndIf

$_LastUkTopChartsListArray[0] = UBound ( $_LastUkTopChartsListArray )-1
If _IsArrayEmpty ( $_LastUkTopChartsListArray ) Then Exit MsgBox ( 0, 'Error', 'Sorry Uk Top Charts List Not Found !', 5 )
Dim $_ListViewItem[$_LastUkTopChartsListArray[0]+1]
Dim $_GuiTitle='Tiny UK ' & $_SubKey & ' Stream Player ' & $_UpDateDate


$_Gui                      = GUICreate ( $_GuiTitle, 500, 330, @DesktopWidth-507, @DesktopHeight - 360, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOOLWINDOW ) ) 
                        GUISetBkColor ( 0xFFD900 ) 
                            GUISetIcon ( "Shell32.dll", -129 )
$_ListView  = GUICtrlCreateListView ( "Top Nb|Title - Artist", 15, 20, 340, 260 )
    _GUICtrlListView_SetColumnWidth ( $_ListView, 1, $LVSCW_AUTOSIZE_USEHEADER )
For $_G = 1 To UBound ( $_LastUkTopChartsListArray ) - 1
    $_ListViewItem[$_G] = GUICtrlCreateListViewItem ( StringFormat ( "%02i", $_G ) & "|" & $_LastUkTopChartsListArray[$_G], $_ListView )
Next
$_SelectButton   = GUICtrlCreateButton ( "Listen Selected Song", $_X, 221, $_SelectButtonWidth, 24 ) 
                    GUICtrlSetState ( $_SelectButton, $GUI_DISABLE ) 
$_ExitButton    = GUICtrlCreateButton ( "Exit", $_X, 257, $_SelectButtonWidth, 24 ) 
$_RandomButton   = GUICtrlCreateButton ( "Disable Random Mode", $_X, 149, $_SelectButtonWidth, 24 )                 
                    GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 )  
                    GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) 
$_NextButton    = GUICtrlCreateButton ( "Next Random Song", $_X, 185, $_SelectButtonWidth, 24 )                 
            $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X+10, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) 
$_StatusBar = _GUICtrlStatusBar_Create ( $_Gui, $_StatusParts, $_TempStatus, $SBARS_SIZEGRIP )
        _GUICtrlStatusBar_SetMinHeight ( $_StatusBar, 40 )
    $_Icons = _WinAPI_LoadShell32Icon ( 128 )
            _GUICtrlStatusBar_SetIcon ( $_StatusBar, 0, $_Icons )
                    _Slide_WinSetSlide ( $_Gui, "top" ) 
                _Slide_SlideSetOnHover ( $_Gui ) 
                        GUISetState ( @SW_SHOW )
                            


While 1
    If $_Auto Then
        $_R = _Randomize ( $_LastUkTopChartsListArray[0] ) 
        _GUICtrlStatusBar_SetText ( $_StatusBar, ' Waiting for Next Song...', 0 )   
        $_YoutubeSearch = _YoutubeSearch ( $_LastUkTopChartsListArray[$_R] & ' official' )
        If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/watch?v' ) <> 0 Then 
            $_IE = _IECreate ( $_YoutubeSearch, 0, 0, 1 )
            $_DurationInit = TimerInit ( )
            $_DurationDiff=0
            For $_P = 1 To $_ImagesUrlArray[0]
                $_PicPath = @TempDir & '\Pics\' & $_LastUkTopChartsListArray[$_P] & '.jpg'
                If Not FileExists ( $_PicPath ) Then InetGet ( $_ImagesUrlArray[$_P], $_PicPath, 0, 1 )
            Next
            $_PicPath = @TempDir & '\Pics\' & $_LastUkTopChartsListArray[$_R] & '.jpg'
            If FileExists ( $_PicPath ) Then
                GUICtrlSetState ( $_Pic, $GUI_HIDE )
                $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+10, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) )     
            EndIf   
            _WinSetOnTopOneTime ( $_GuiTitle )
        Else    
            _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_LastUkTopChartsListArray[$_R] & @Crlf & 'Music Not Found !', 0 )    
            _WinSetOnTopOneTime ( $_GuiTitle )
            Sleep ( 2000 )
        EndIf
    EndIf   
    While 1
        If $_DurationDiff > $_DurationMs Or ( $_Auto And _IsPressed ( "27" ) ) Then
            _IEQuit ( $_IE ) 
            $_GetItem=''
            $_Duration=0
            $_DurationInit=0
            $_DurationDiff=0
            $_PicShow=0
            ExitLoop 
        EndIf       
        Sleep ( 20 )
        $_Msg = GUIGetMsg ( )
        Switch $_Msg
            Case $_SelectButton 
                _IEQuit ( $_IE ) 
                $_PicShow=0
                $_GetItem = _GetItem ( )
                If $_GetItem Then
                    _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Waiting for Next Song...', 0 )
                    $_YoutubeSearch = _YoutubeSearch ( $_GetItem & ' official' )
                    $_IE = _IECreate ( $_YoutubeSearch, 0, 0, 1 )
                    $_DurationInit = TimerInit ( )
                    $_DurationDiff=0
                    $_PicPath = @TempDir & '\Pics\' & $_GetItem & '.jpg'
                    If FileExists ( $_PicPath ) Then
                        GUICtrlSetState ( $_Pic, $GUI_HIDE )
                        $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+10, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) )     
                    EndIf
                EndIf
            Case $_NextButton
                _IEQuit ( $_IE ) 
                $_GetItem=''
                $_Duration=0
                $_DurationInit=0
                $_DurationDiff=0
                $_PicShow=0
                ExitLoop                    
            Case $_RandomButton 
                _IEQuit ( $_IE ) 
                $_PicShow=0
                If $_Auto = 1 Then 
                    $_Auto=0
                    GUICtrlSetState ( $_SelectButton, $GUI_ENABLE ) 
                    GUICtrlSetState ( $_NextButton, $GUI_DISABLE )
                    GUICtrlSetState ( $_RandomButton, $GUI_HIDE )
                    $_RandomButton = GUICtrlCreateButton ( "Enable Random Mode", $_X, 146, $_SelectButtonWidth, 24 ) 
                    GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 )  
                    GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) 
                Else    
                    $_Auto = 1
                    GUICtrlSetState ( $_SelectButton, $GUI_DISABLE )
                    GUICtrlSetState ( $_RandomButton, $GUI_HIDE )
                    GUICtrlSetState ( $_NextButton, $GUI_ENABLE )
                    $_RandomButton = GUICtrlCreateButton ( "Disable Random Mode", $_X, 146, $_SelectButtonWidth, 24 ) 
                    GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 )  
                    GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) 
                    ExitLoop 
                EndIf   
            Case $GUI_EVENT_CLOSE
                GUIDelete ( )   
                _Terminate ( )
            Case $_ExitButton
                GUIDelete ( )    
                _Terminate ( )              
            Case $_Msg <> 0
                $_Select = _GetItem ( )
                If $_Select <> $_SelectOld Then
                    $_PicPath = @TempDir & '\Pics\' & $_Select & '.jpg'
                    If FileExists ( $_PicPath ) Then
                        GUICtrlSetState ( $_Pic, $GUI_HIDE )
                        $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+10, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) )     
                    EndIf
                    $_SelectOld = $_Select
                    $_Select=''
                EndIf               
        EndSwitch
        If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) 
        $_DurationMs = $_Duration * 1000    
        If $_Duration Then $_DurationDiff = Round ( TimerDiff ( $_DurationInit ) )
        _TicksToTime ( $_DurationMs - $_DurationDiff, $Hour, $Min, $Sec )
        If $_Auto Then  
            $_Text2 = $_LastUkTopChartsListArray[$_R]
        Else
            $_Text2 = $_GetItem
        EndIf
        If $_Text2 Then 
            _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_Text2 & ' - ' & StringFormat ( "%02i:%02i", $Min, $Sec ), 0 )
            If Not $_PicShow Then
                $_PicPath = @TempDir & '\Pics\' & $_Text2 & '.jpg'
                If FileExists ( $_PicPath ) Then
                    GUICtrlSetState ( $_Pic, $GUI_HIDE )
                    $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+10, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) 
                    $_PicShow = 1               
                EndIf
            EndIf   
        EndIf
    WEnd
WEnd

Func _SelectGenre ( )
    $_Gui = GUICreate ( "Tiny UK Charts Stream Player, Select Genre...", 250, 130, -1, -1, -1, BitOR ( $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) ) 
    GUISetBkColor ( 0xFFD900 ) 
    Dim $_Radio[UBound ( $_Genre )]
    For $_I = 1 To UBound ( $_Genre ) -1
        $_Radio[$_I] = GUICtrlCreateRadio ( _StringProper ( StringReplace ( $_Genre[$_I], '-', ' ' ) ), 10, $_I*20 -10, 160, 20 )
    Next
    GUISetState ( )    
    $_TimerInit =  TimerInit ( )
    $_InvertTimerInit = TimerInit ( )
    While 1
        $msg = GUIGetMsg ( )    
        Select
            Case $msg = $GUI_EVENT_CLOSE
            Exit
            Case $msg <> -11 And $msg <> 0
                For $_I = 1 To UBound ( $_Genre ) -1
                    If $msg = $_Radio[$_I] And BitAND ( GUICtrlRead ( $_Radio[$_I] ), $GUI_CHECKED ) = $GUI_CHECKED Then
                        $_SubKey = $_Genre[$_I]
                        GUIDelete ( $_Gui )
                        Return $_SubKey
                    EndIf
                Next
        EndSelect
        $_ChoiceTimerDiff = Round ( TimerDiff ( $_TimerInit )/1000 )
        If _EachXseconds ( 1 ) Then GUICtrlCreateLabel ( StringFormat ( "%02i", ( 11-$_ChoiceTimerDiff ) ) & ' Secondes to make your Choice...', 10, ( $_I+1 ) * 20 -10 )
        If $_ChoiceTimerDiff > 10 Then
            Dim $_SubKey = $_Genre[Random ( 1, $_Genre[0], 1 )]
            GUIDelete ( $_Gui )
            Return $_SubKey
        EndIf       
        Sleep ( 20 )
    WEnd
EndFunc ;==> _SelectGenre ( )

Func _InvertColorButton ( $_GuiCtrl )
    If $_Invert Then
        GUICtrlSetBkColor ( $_GuiCtrl, 0xFF0000 )  
        GUICtrlSetColor ( $_GuiCtrl, 0xFFFF00 ) 
        $_Invert=False
    Else
        GUICtrlSetBkColor ( $_GuiCtrl, 0xFFFF00 )  
        GUICtrlSetColor ( $_GuiCtrl, 0xFF0000 )     
        $_Invert=True
    EndIf
EndFunc ;==> _InvertColorButton ( )

Func _EachXseconds ( $_Interval )
    $_TimerDiff = Round ( TimerDiff ( $_InvertTimerInit )/ 1000 )
    If $_TimerDiff >= $_Interval Then
        $_InvertTimerInit = TimerInit ( )
        Return 1
    Else
        Return 0
    EndIf
EndFunc ;==> _EachXseconds ( )

Func _GetItem ( )
    $_Select = GUICtrlRead ( GUICtrlRead ( $_ListView ) ) 
    $_Stringlen = Stringlen ( $_Select )
    $_Select = StringReplace ( StringRight ( $_Select, $_Stringlen - 3 ), '|', '' )
    If $_Select Then Return $_Select 
EndFunc ;==> _GetItem ( )

Func _GetUpdateDate ( $_LastChartsUrl )
    Local $_UpDateDate
    $_LastChartPageSourceCode = _GetSourceCode ( $_LastChartsUrl )  
    $_UpDateDate = _StringBetween ( $_LastChartPageSourceCode, '"date"> -', "<" )               
    If Not @error Then $_UpDateDate = '( Week of ' & StringStripWS ( $_UpDateDate[0], 7 ) & ' )'
    Return $_UpDateDate
EndFunc

Func _GetLastUkTopChartsListArray ( $_SourceCode )
    Local $_NamesArray[1], $_Add
    $_LastChartsArray = StringSplit ( $_SourceCode, @CRLF ) 
    Local $_ChartsArray[1] 
    For $_I = 1 To UBound ( $_LastChartsArray ) -1
        If StringInStr ( $_LastChartsArray[$_I], '</h4>' ) <> 0 Then
            $_Title = _StringBetween ( $_LastChartsArray[$_I], '<h4>', '</h4>' )
            If Not @error Then
                $_Artist = StringReplace ( $_LastChartsArray[$_I+2], '<br />', '' )
                $_Name = _CleanVideoName ( $_Title[0] & ' - ' & $_Artist )
                If Not _AlreadyInArray ( $_NamesArray, $_Name ) Then 
                    _ArrayAdd ( $_NamesArray, $_Name )
                    $_Add = $_Add + 1
                    RegWrite ( $_Key & '\' & $_SubKey, StringFormat ( "%03i", $_Add ), "REG_SZ", $_Name )
                    If $_I+43 < UBound ( $_LastChartsArray ) -1 Then
                        For $_J = $_I-3 To $_I+3
                            $_ImagesUrl = _StringBetween ( $_LastChartsArray[$_J], 'coverimage" src="', '"' )               
                            If Not @error Then 
                                $_ImagesUrl = $_ImagesUrl[0]
                                If StringLeft ( $_ImagesUrl, 4 ) <> 'http' Then $_ImagesUrl = 'http://www.theofficialcharts.com' & $_ImagesUrl
                                If Not _IsValidUrl ( $_ImagesUrl ) Then $_ImagesUrl=''
                            _ArrayAdd ( $_ImagesUrlArray, $_ImagesUrl )
                            EndIf 
                        Next
                    EndIf 
                EndIf 
            EndIf 
        EndIf 
    Next 
    $_ImagesUrlArray[0] = UBound ( $_ImagesUrlArray ) -1
    $_NamesArray[0] = UBound ( $_NamesArray ) -1
    RegWrite ( $_Key & '\' & $_SubKey, 'UpdateDate', "REG_SZ", $_UpdateDate )
    Return $_NamesArray
EndFunc ;==> _GetLastUkTopChartsListArray ( )

Func _YoutubeSearch ( $_Query )
    Dim $_WordOfQuery[1]
    $_QuerySplit = StringSplit ( StringStripWS ( StringRegExpReplace ( StringReplace ( StringReplace ( $_Query, 'è', 'e' ), 'é', 'e' ), "\W", " " ) , 7 ), ' ' )
    For $_I = 1 To UBound ( $_QuerySplit ) - 1
    If StringLen ( $_QuerySplit[$_I] ) > 1 Then _ArrayAdd ( $_WordOfQuery, StringReplace ( $_QuerySplit[$_I], ',', ' ' ) )
    Next
    $_WordOfQuery[0] = UBound ( $_WordOfQuery ) - 1 
    $_Query = StringReplace ( $_Query, " ", "+" )
    $_Query = StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace _
    ( StringReplace ( StringStripWS ( $_Query, 7 ), ',', '%2C' ), '&', '%26' ), '(', '%28' ), ')', '%29' ), "'", '%27' ), 'è', 'e' ), 'é', 'e' ), '«', ' ' ), '»', ' ' )
    $_SourceCode = _GetSourceCode ( "http://www.youtube.com/results?search_query=" & $_Query ) 
    $_SourceCodeSplit = StringSplit ( $_SourceCode, @CRLF )     
    Dim $_Watch[1] 
    For $_I = 1 To UBound ( $_SourceCodeSplit )-1
        If StringInStr ( $_SourceCodeSplit[$_I], '/watch?v=' ) <> 0 And StringInStr ( $_SourceCodeSplit[$_I], 'video-long-title' ) <> 0 Then
            _ArrayAdd ( $_Watch, $_SourceCodeSplit[$_I] )
        EndIf 
    Next    
    For $_I = 1 To UBound ( $_Watch )-1
        $Titles = _StringBetween ( $_Watch[$_I], 'title="', '" rel=' )
        If Not @error Then 
            If Not _OneOfThisStringInStr ( $Titles[0], 'Karaok|Singing|parod' ) Then
                $_Duration = _StringBetween ( $_SourceCode, 'time">', '<' ) 
                If Not @error Then 
                    $_Duration = StringSplit ( $_Duration[0], ':' )
                    $_Duration[0]=UBound ( $_Duration ) -1
                    $_Duration = $_Duration[1]*60 + $_Duration[$_Duration[0]]
                    $Link = _StringBetween ( $_Watch[$_I], 'href="', '"' )  
                    If Not @error Then 
                        If StringInStr ( $Link[0], 'http://www.youtube.com' ) = 0 Then 
                            $_UrlToExtract = "http://www.youtube.com" & $Link[0]
                        Else
                            $_UrlToExtract = $Link[0]
                        EndIf
                        Return $_UrlToExtract
                    EndIf
                EndIf
            EndIf   
        EndIf
    Next 
Endfunc ;==> _YoutubeSearch ( )

Func _OneOfThisStringInStr ( $_InStr, $_String )
    $_StringArray = StringSplit ( $_String, '|' ) 
    If @error Then Return 0
    For $_I = 1 To UBound ( $_StringArray ) -1
        $_StringInStr = StringInStr ( $_InStr, $_StringArray[$_I] ) 
        If $_StringInStr <> 0 Then Return 1 
    Next
    Return 0
EndFunc ;==> _OneOfThisStringInStr ( )

Func _CleanVideoName ( $_Name )
    $_Name2 = StringRegExpReplace ( $_Name, '(&quot;)|(&quot;)|(quot;)|(&amp;)|(amp;)|(&lt;)|(lt;)|(&gt;)|(gt;)|(#39;)', '' )   
    $_Name2 = StringReplace ( $_Name2, 'ç', 'c' )    
    $_Name2 = StringReplace ( $_Name2, 'ß', 'ss' )       
    $_Name2 = StringReplace ( $_Name2, '€', '€' )   
    $_Name2 = StringRegExpReplace ( $_Name2, '(à )|(â)|(ä)|(À)|(ã)|(á)|(Ã¥)', 'a' )
    $_Name2 = StringRegExpReplace ( $_Name2, '(Ú)|(ê)|(é)|(è)|(ë)', 'e' )
    $_Name2 = StringRegExpReplace ( $_Name2, '(ï)|(î)|(Ã)', 'i' )
    $_Name2 = StringRegExpReplace ( $_Name2, '(ÃŽ)|(ö)|(ó)|(ô)', 'o' )
    $_Name2 = StringRegExpReplace ( $_Name2, '(û)|(ü)|(ù)|(ÃŒ)|(ú)', 'u' )
    $_Name2 = StringReplace ( $_Name2, 'Ã', 'a' )      
    $_Name2 = StringReplace ( $_Name2, '\', '' )    
    $_Name2 = StringRegExpReplace ( $_Name2, "[|!?_*~´’'`³¹¼¯,]", ' ' )  
    $_Name2 = StringRegExpReplace ( $_Name2, '[âªâ™«»¥¶£¢€¡†Ø§³ÙŠšØ¹±ª#®¤©‰¨¹¬·/;:"]', '' )  
    Return _StringProper ( StringStripWS ( _CleanHtmlName ( $_Name2 ), 7 ) )
EndFunc ;==> _CleanVideoName ( )

Func _CleanHtmlName ( $_Name )
    $_Name2 = StringReplace ( $_Name, '%2C', ',' )
    $_Name2 = StringReplace ( $_Name2, '%82', ',' )
    $_Name2 = StringReplace ( $_Name2, '%27', "'" )
    $_Name2 = StringReplace ( $_Name2, '&039', "'" )    
    Return $_Name2
EndFunc ;==> _CleanHtmlName ( )

Func _Randomize ( $_Max=100 )   
    Do 
        $_Random = Random ( 1, $_Max, 1 )
    Until Not _AlreadyInArray ( $_RandomArray, $_Random )
    _ArrayAdd ( $_RandomArray, $_Random ) 
    $_RandomArray[0] = UBound ( $_RandomArray ) -1
    If $_RandomArray[0] >= $_Max Then ReDim $_RandomArray[1]
    Return $_Random
EndFunc ;==> _Randomize ( ) 

Func _AlreadyInArray ( $_SearchArray, $_Item )
    $_Index = _ArraySearch ( $_SearchArray, $_Item ) 
    If @error Then      
        Return False
    Else  
        If  $_Index <> 0 Then
            Return True
        Else 
            Return False
        EndIf   
    EndIf
EndFunc ;==> _AlreadyInArray ( )
 
Func _GetSourceCode ( $_Url )
    $_InetRead = InetRead ( $_Url )
    If Not @Error Then
        $_BinaryToString = BinaryToString ( $_InetRead )
        If Not @Error Then Return $_BinaryToString
    EndIf   
EndFunc ;==> _GetSourceCode ( )

Func _IsArrayEmpty ( $_EmptyArray )
    Local $_V = UBound ( $_EmptyArray ) -1, $_P 
    If $_V = 0 Then Return True
    For $_F = 1 To $_V      
        If $_EmptyArray[$_F] = '' Then $_P = $_P + 1
    Next
    If $_P = $_V Then 
        Return True
    Else
        Return False
    EndIf
EndFunc ;==> _IsArrayEmpty ( )

Func _IsConnected ( )
    $_SrcFilePath = _TempFile ( @TempDir & "\", '~google_', ".src", 7 ) 
    Local $IsConnected = InetGet ( "http://www.google.com", $_SrcFilePath, 1, 1 )
    Local $_Info 
    Do
        $_Info = InetGetInfo ( $IsConnected )
        Sleep ( 50 )
    Until $_Info[2] = True 
    InetClose ( $IsConnected )
    _Delete ( $_SrcFilePath )   
    If $_Info[3] <> True Then   
        Return 0
    Else
        Return 1
    EndIf   
EndFunc ;==> _IsConnected ( )

Func _IsValidUrl ( $_IsValidUrl )
    $_Size = InetGetSize ( $_IsValidUrl ) 
    If $_Size <> 0 Then Return 1    
Endfunc ;==> _IsValidUrl ( )

Func _Delete ( $_FullPath )
    $_DeleteInit = TimerInit ( )
    While FileExists ( $_FullPath ) 
        If StringInStr ( FileGetAttrib ( $_FullPath ), "D" ) Then 
            DirRemove ( $_FullPath, 1 )
        Else
            FileDelete ( $_FullPath )
        EndIf
        If TimerDiff ( $_DeleteInit ) > 5000 Then Return 0
    WEnd
    Return 1    
EndFunc ;==> _Delete ( ) 

Func _ProcessClose ( $_ProcessName )
    While ProcessExists ( $_ProcessName )
        ProcessClose ( $_ProcessName )  
    WEnd
EndFunc ;==> _ProcessClose ( )

Func _Terminate ( )
    _IEQuit ( $_IE ) 
    Exit 
EndFunc ;==> _Terminate ( )

Func _OnAutoItExit ( )
    Opt ( "TrayIconHide", 0 ) 
    TrayTip ( "TinyUKChartsStreamPlayer", "        by wakillon...", 1, 1 )
    __Slide_UnloadDLL ( )
    Sleep ( 2000 )
    TrayTip ( '', '', 1, 1 )
EndFunc ;==> _OnAutoItExit ( ) 

Func _WinSetOnTopOneTime ( $_WinTitle )
    WinWait ( $_WinTitle, "", 6 )
    WinSetOnTop ( $_WinTitle, "", 1 ) 
    Sleep ( 250 )
    WinSetOnTop ( $_WinTitle, "", 0 ) 
EndFunc ;==> _WinSetOnTopOneTime ( )

Func _Slide_WinSetSlide ( $hWnd, $sSide, $iMode = 1 )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    If @error Then Return SetError ( 1, 0, 0 )
    If $iMode > 1 Or $iMode < 0 Then Return SetError ( 1, 0, 0 )
    If Not StringRegExp ( $sSide, "(?i)(left|right|top|bottom)" ) Then Return SetError ( 1, 0, 0 )
    $iUbound = UBound ( $__SLIDE_aGUI )
    Switch $iMode
        Case 1
            ReDim $__SLIDE_aGUI[$iUbound + 1][5]
            $__SLIDE_aGUI[$iUbound][0] = $hWnd
            $__SLIDE_aGUI[$iUbound][1] = $sSide
            $__SLIDE_aGUI[$iUbound][2] = True
            $__SLIDE_aGUI[$iUbound][3] = False
            $__SLIDE_aGUI[$iUbound][4] = False
            _Slide_SlideOut ( $hWnd )
            GUISetState ( @SW_SHOWNOACTIVATE, $hWnd )
        Case 0
            For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
                If $__SLIDE_aGUI[$i][0] = $hWnd Then
                    For $j = $i To UBound($__SLIDE_aGUI) - 2
                        $__SLIDE_aGUI[$j][0] = $__SLIDE_aGUI[$j + 1][0]
                        $__SLIDE_aGUI[$j][1] = $__SLIDE_aGUI[$j + 1][1]
                        $__SLIDE_aGUI[$j][2] = $__SLIDE_aGUI[$j + 1][2]
                        $__SLIDE_aGUI[$j][3] = $__SLIDE_aGUI[$j + 1][3]
                        $__SLIDE_aGUI[$j][4] = $__SLIDE_aGUI[$j + 1][4]
                        ReDim $__SLIDE_aGUI[UBound ( $__SLIDE_aGUI ) - 1][5]
                        _Slide_SlideIn ( $hWnd )
                        GUISetState ( @SW_HIDE, $hWnd )
                    Next
                EndIf
            Next
    EndSwitch
EndFunc ;==> _Slide_WinSetSlide ( )

Func _Slide_SlideSetOnHover ( $hWnd, $sMode = True )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    If @error Then Return SetError ( 1, 0, 0 )
    $iUbound = UBound ( $__SLIDE_aGUI )
    Switch $sMode
        Case True
            For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
                If $__SLIDE_aGUI[$i][0] = $hWnd Then
                    $__SLIDE_aGUI[$i][4] = True
                EndIf
            Next
        Case False
            For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
                If $__SLIDE_aGUI[$i][0] = $hWnd Then
                    $__SLIDE_aGUI[$i][4] = False
                EndIf
            Next
    EndSwitch
EndFunc ;==> _Slide_SlideSetOnHover ( )

Func _Slide_SlideOut ( $hWnd )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    If @error Then Return SetError ( 1, 0, 0 )
    For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
        If $__SLIDE_aGUI[$i][0] = $hWnd Then
            If $__SLIDE_aGUI[$i][2] Then
                __Slide_WinSlide ( $hWnd, "out", $__SLIDE_aGUI[$i][1] )
                $__SLIDE_aGUI[$i][2] = False
                Return SetError ( 0, 0, 1 )
            Else
                Return SetError ( 3, 0, 0 )
            EndIf
        EndIf
    Next
    Return SetError ( 2, 0, 0 )
EndFunc ;==> _Slide_SlideOut ( )

Func _Slide_SlideIn ( $hWnd )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    If @error Then Return SetError ( 1, 0, 0 )
    For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
        If $__SLIDE_aGUI[$i][0] = $hWnd Then
            If Not $__SLIDE_aGUI[$i][2] Then
                __Slide_WinSlide ( $hWnd, "in", $__SLIDE_aGUI[$i][1] )
                $__SLIDE_aGUI[$i][2] = True
            Else
                Return SetError ( 3, 0, 0 )
            EndIf
        EndIf
    Next
    Return SetError ( 2, 0, 0 )
EndFunc ;==> _Slide_SlideIn ( )

Func __Slide_WinSlide ( $hWnd, $sMode, $sSide )
    Local $aScreen_Res = WinGetPos ( WinGetHandle ( "Program Manager" ) )
    Local $aWPos = WinGetPos ( $hWnd ), $m = 0 - ( $sMode = "in" ) + ( $sMode = "out" )
    Local $h = 0 - ( $sSide = "left" ) + ( $sSide = "right" ), $v = 0 - ( $sSide = "top" ) + ( $sSide = "bottom" )
    WinMove ( $hWnd, "", $aScreen_Res[0] - ( ( $h = -1 ) * ( $m = -1 ) * ( $aWPos[2] - 10 ) ) _
            + ( ( $h = 1 ) * ( ( $h = 1 ) * $aScreen_Res[2] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[2] ) ) _
            + ( ( $h = 0 ) * ( ( $h = 0 ) * ( $aScreen_Res[2] / 2 ) - ( $aWPos[2] / 2 ) ) ) _
            , $aScreen_Res[1] - ( ( $v = -1 ) * ( $m = -1 ) * ( $aWPos[3] - 10 ) ) _
            + ( ( $v = 1 ) * ( ( $v = 1 ) * $aScreen_Res[3] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[3] ) ) _
            + ( ( $v = 0 ) * ( ( $v = 0 ) * ( $aScreen_Res[3] / 2 ) - ($aWPos[3] / 2 ) ) ) )
    $aWPos = WinGetPos ( $hWnd )
    Switch $sSide
        Case "left", "right"
            Local $STEP = ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) - ( ( ( $h = -1 ) And ( $m = 1 ) ) Or ( ( $h = 1 ) And ( $m = -1 ) ) ) ) * 10
            Local $FROM = $aWPos[0], $TO = $aWPos[0] + ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[2] ) ) _
                    - ( ( ( ( $h = 1 ) And ( $m = -1 ) ) Or ( ( $h = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[2] ) ) - $STEP
            For $i = $aWPos[0] To $TO Step $STEP
                WinMove ( $hWnd, "", $i, $aWPos[1] )
                Sleep ( 10 )
            Next
        Case "top", "bottom"
            Local $STEP = ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) - ( ( ( $v = -1 ) And ( $m = 1 ) ) Or ( ( $v = 1 ) And ( $m = -1 ) ) ) ) * 10
            Local $FROM = $aWPos[1], $TO = $aWPos[1] + ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[3] ) ) _
                    - ( ( ( ( $v = 1 ) And ( $m = -1 ) ) Or ( ( $v = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[3] ) ) - $STEP              
            If $STEP > 0 Then $TO = $TO -25
            For $i = $aWPos[1] To $TO + 25 Step $STEP ; 
                WinMove ( $hWnd, "", $aWPos[0], $i )
                Sleep ( 10 )
            Next
    EndSwitch
EndFunc ;==> __Slide_WinSlide ( )

Func __Slide_CheckHover ( )
    For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1
        If $__SLIDE_aGUI[$i][4] Then
            If Not $__SLIDE_aGUI[$i][3] Then
                If __Slide_WinIsHovered ( $__SLIDE_aGUI[$i][0] ) Then
                    If Not $__SLIDE_aGUI[$i][2] Then _Slide_SlideIn ( $__SLIDE_aGUI[$i][0] )
                Else
                    If $__SLIDE_aGUI[$i][2] Then _Slide_SlideOut ( $__SLIDE_aGUI[$i][0] )
                EndIf
            EndIf
        EndIf
    Next
EndFunc ;==> __Slide_CheckHover ( )

Func __Slide_UnloadDLL ( )
    DllClose ( $__SLIDE_hDLL )
EndFunc ;==> __Slide_UnloadDLL ( )

Func __Slide_WinIsHovered ( $hWnd, $vDLL = "User32.dll" )
    Local $aResult, $aWPos = WinGetPos ( $hWnd ) 
    If @error Then Return 
    Local $aMPos = MouseGetPos ( )
    If @error Then Return   
    Local $tRect = DllStructCreate ( "int Left;int Top;int Right;int Bottom" )
    Local $iLeft = $aWPos[0], $iTop = $aWPos[1], $iWidth = $aWPos[2], $iHeight = $aWPos[3]
    Local $iX = $aMPos[0], $iY = $aMPos[1]
    DllStructSetData ( $tRect, "Left", $iLeft )
    DllStructSetData ( $tRect, "Top", $iTop )
    DllStructSetData ( $tRect, "Right", $iLeft + $iWidth )
    DllStructSetData ( $tRect, "Bottom", $iTop + $iHeight )
    $aResult = DllCall ( $vDLL, "int", "PtInRect", "ptr", DllStructGetPtr ( $tRect ), "int", $iX, "int", $iY )
    If @error Then Return SetError ( @error, 0, False )
    Return $aResult[0] <> 0
EndFunc ;==> __Slide_WinIsHovered ( )

It's more fun and fast ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

The version 4 is fantastic !!!

But "Listen selected song" don't run for me.

An idea ?

Thanks a lot ! or "Merci beaucoup !" Posted Image

Have you disable Random mode before click on Listen Selected Song Button ? Posted Image

otherwise Button is greyed !

If random mode is disable you are in manual mode...

Voila voila !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Am I doing something wrong?

About 80% of the songs play at such a low volume that I can't hear them. Is there a volume control in IE that I don't know about?

I normally only use Firefox, so IE is not setup for daily use.

No, there is no volume control in IE, just in FlashPlayer embedded.

But yes, certain songs play at low volume, that's annoying ! Posted Image

Which version do you try ?

Otherwise looks your PC sound settings or take an amplifier...Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Thanks a lot ! or "Merci beaucoup !" Posted Image

Have you disable Random mode before click on Listen Selected Song Button ? Posted Image

otherwise Button is greyed !

If random mode is disable you are in manual mode...

Voila voila !

Je sais bien, mais ça ne marche pas pour moi. Il n'est même pas en random et reste souvent sur le même titre

I know, but that don't run well for me. it stay always on the same song's title

Link to comment
Share on other sites

Je sais bien, mais ça ne marche pas pour moi. Il n'est même pas en random et reste souvent sur le même titre

I know, but that don't run well for me. it stay always on the same song's title

While 1
    If $_RandomMode Then
        $_R = _Randomize ( $_LastUkTopChartsListArray[0] ) 
        _GUICtrlStatusBar_SetText ( $_StatusBar, ' Waiting for Next Song...', 0 )   
        $_YoutubeSearch = _YoutubeSearch ( $_LastUkTopChartsListArray[$_R] & ' official' )
        If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/watch?v' ) <> 0 Then 
            $_IE = _IECreate ( $_YoutubeSearch, 0, 0, 1 ) ; <====== Change 0, 0, 1 ) by 0, 1, 1 ) 
            $_DurationInit = TimerInit ( )
            $_DurationDiff=0

After this change, Run it, IE will be visible...and Look if it give you an error Message or Bug. Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Thanks!

Cracked it. If you don't use IE, then before running this script, run IE, go to Youtube and set the volume to max, then close Youtube and IE.

It should remember your setting till you change them manually again.

Hope this helps anyone else.

p.s. Is it possible to set the hotkey and right arrow as variables at the top of the script as a few friends that use your script cant use ESCAPE or RIGHT ARROW so I had to scan through your script and change it manually.

p.p.s. The slide function, slides BEHIND the last window that was on top. Is it possible to have the slide window On Top, but the anchor window as it is now?

Edited by happy2help
Link to comment
Share on other sites

While 1
    If $_RandomMode Then
        $_R = _Randomize ( $_LastUkTopChartsListArray[0] ) 
        _GUICtrlStatusBar_SetText ( $_StatusBar, ' Waiting for Next Song...', 0 )   
        $_YoutubeSearch = _YoutubeSearch ( $_LastUkTopChartsListArray[$_R] & ' official' )
        If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/watch?v' ) <> 0 Then 
            $_IE = _IECreate ( $_YoutubeSearch, 0, 0, 1 ) ; <====== Change 0, 0, 1 ) by 0, 1, 1 ) 
            $_DurationInit = TimerInit ( )
            $_DurationDiff=0

After this change, Run it, IE will be visible...and Look if it give you an error Message or Bug. Posted Image

I obtain that:

--> IE.au3 V2.4-0 Error from function _IEQuit, $_IEStatus_InvalidDataType

I am not certain to have the same version that you have (0.4)

I have that for the line that you speak about:

While 1
    If $_Auto Then
        $_R = _Randomize ( $_LastUkTopChartsListArray[0] )
        _GUICtrlStatusBar_SetText ( $_StatusBar, ' Waiting for Next Song...', 0 )
        $_YoutubeSearch = _YoutubeSearch ( $_LastUkTopChartsListArray[$_R] & ' official' )
        If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/watch?v' ) <> 0 Then
            $_IE = _IECreate ( $_YoutubeSearch, 0, 1, 1 )
            $_DurationInit = TimerInit ( )
            $_DurationDiff=0

My variable is $_Auto and your is $_RandomMode

Edited by pierrotm777
Link to comment
Share on other sites

Thanks!

Cracked it. If you don't use IE, then before running this script, run IE, go to Youtube and set the volume to max, then close Youtube and IE.

It should remember your setting till you change them manually again.

Hope this helps anyone else.

p.s. Is it possible to set the hotkey and right arrow as variables at the top of the script as a few friends that use your script cant use ESCAPE or RIGHT ARROW so I had to scan through your script and change it manually.

p.p.s. The slide function, slides BEHIND the last window that was on top. Is it possible to have the slide window On Top, but the anchor window as it is now?

Yes you can modify hotkey like you want ! Posted Image

But i don't understand your slide question, if you want the window always on top, replace

GUICreate ( $_GuiTitle, ..... BitOR ( $WS_EX_LAYERED, $WS_EX_TOOLWINDOW ) by

GUICreate ( $_GuiTitle, ..... BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW )

I had removed this OnTop attribute because it was annoying for tabbed browsing

So now gui is set one time ( one sec ) on top after a new song but doesn't keep this attribute.

I don't know if it help you ? Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
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
 Share

×
×
  • Create New...