#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 <a href='http://www.theofficialcharts.com/singles-chart/' class='bbc_url' title='External link' rel='nofollow external'>http://www.theofficialcharts.com/singles-chart/</a> 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
( "<a href='http://www.youtube.com/results?search_query=' class='bbc_url' title='External link' rel='nofollow external'>http://www.youtube.com/results?search_query="</a
> & $_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 = "<a href='http://www.youtube.com' class='bbc_url' title='External link' rel='nofollow external'>http://www.youtube.com"</a
> & $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;)|(&)|(amp;)|(<)|(lt;)|(>)|(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 ( "<a href='http://www.google.com' class='bbc_url' title='External link' rel='nofollow external'>http://www.google.com"</a
>, $_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 ( )