Gillboss Posted August 9, 2008 Share Posted August 9, 2008 This script work nice, i can add words in hebrew, but i have problem with function _Edit() because _FileWriteLine not work with hebrew sentence (i guess). what can i do? expandcollapse popup#include <Constants.au3> $version = "v1.7" ; Version $dir = @TempDir ; Radio.ini dir If Not FileExists(@TempDir&"\123.ico") Or Not FileExists(@TempDir&"\321.ico") Or Not FileExists(@TempDir&"\1.ico") Then _ExtractIcons() EndIf ;Tray Option =============================================================== $ico1 = @TempDir&"\123.ico" $ico2 = @TempDir&"\321.ico" Opt("TrayMenuMode",1) TraySetIcon($ico1) $restore = TrayCreateItem("Restore") $mute = TrayCreateItem("Mute") TrayItemSetState($mute, $TRAY_UNCHECKED) TrayCreateItem("") $exit = TrayCreateItem("Exit") TraySetState() TraySetClick(8) ; Pressing secondary mouse button TraySetToolTip("Radio Player "&$version) Opt("TrayIconHide", 1) ;==> Tray Option ========================================================== #include <GUIConstants.au3> #include <WMMedia.au3> #include <File.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> global const $L_HEBREW = '040d' Global Const $WM_NOTIFY = 0x004E Global $DoubleClicked = False Global $Title, $iIndexp, $selectedp, $Titlep, $playing, $hostname, $ip, $a Local $hImage, $hListView HotKeySet("{DELETE}", "_DelKey") $asd = 1 $dsa = 1 Global $play, $stop, $add, $addGui WMStartPlayer() $hGui = GUICreate("Radio Player " & $version, 340, 340, (@DesktopWidth - 340) / 2, (@DesktopHeight - 340) / 2) $filemenu = GUICtrlCreateMenu("File") $update = GUICtrlCreateMenuItem("Update list", $filemenu) $toolsmenu = GUICtrlCreateMenu("Tools") $deleteall = GUICtrlCreateMenuItem("Delete all list", $toolsmenu) $helpmenu = GUICtrlCreateMenu("Help") $about = GUICtrlCreateMenuItem("About", $helpmenu) $play = GUICtrlCreateButton("Play", 270, 10, 60, 30) $stop = GUICtrlCreateButton("Stop", 270, 40, 60, 30) $edit = GUICtrlCreateButton("Edit", 270, 70, 60, 30) $delete = GUICtrlCreateButton("Delete", 270, 100, 60, 30) $hListView = GUICtrlCreateListView("", 10, 10, 250, 130) _GUICtrlListView_InsertColumn($hListView, 0, "Title", 150) _GUICtrlListView_InsertColumn($hListView, 1, "URL", 350) $hImage = _GUIImageList_Create(16, 16, 5, 3) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\SndVolSSO.dll", 4) _GUIImageList_AddIcon($hImage, @TempDir&"\1.ico") _GUICtrlListView_SetImageList($hListView, $hImage, 1) $label = GUICtrlCreateLabel("Playing: ", 10, 150, 260, 20) GUICtrlCreateLabel("Volume: ", 10, 170, 50, 20) GUICtrlCreateLabel("-", 58, 165, 20, 20) GUICtrlSetFont(-1, 15) $slider = GUICtrlCreateSlider(65, 165, 220, 30) GUICtrlSetData($slider, 80) GUICtrlCreateLabel("+", 290, 165, 20, 20) GUICtrlSetFont(-1, 15) GUICtrlCreateLabel("Title", 10, 210, 50, 20) $input1 = GUICtrlCreateInput("", 50, 210, 250, 20) GUICtrlCreateLabel("URL", 10, 250, 50, 20) $input2 = GUICtrlCreateInput("", 50, 250, 250, 20) $add = GUICtrlCreateButton("Add", 10, 280, 60, 30) $clear = GUICtrlCreateButton("Clear", 80, 280, 60, 30) GUICtrlCreateLabel("By Gil Hanan", 260, 300, 70, 20) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $menu1 = GUICtrlCreateContextMenu($hListView) $play2 = GUICtrlCreateMenuItem("Play", $menu1) GUICtrlCreateMenuItem("", $menu1) $edit2 = GUICtrlCreateMenuItem("Edit", $menu1) GUICtrlCreateMenuItem("", $menu1) $delete2 = GUICtrlCreateMenuItem("Delete", $menu1) $deleteall2 = GUICtrlCreateMenuItem("Delete All", $menu1) GUISetState() _Refresh() Func _Play() $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) $URL = _GUICtrlListView_GetItemText($hListView, $selected, 1) If $iIndex = "" Then MsgBox(64, "Information", "Please select station") Else GUICtrlSetData($label, "Playing: Loading") $return = _IpPing($URL) If $return = 0 Then MsgBox(0, "Information", "Wrong URL") If $playing Then GUICtrlSetData($label, "Playing: "&$Title) Else GUICtrlSetData($label, "Playing: ") EndIf Return Else $Title = _GUICtrlListView_GetItemText($hListView, $selected, 0) If $dsa Then _GUICtrlListView_SetItem($hListView, _GUICtrlListView_GetItemText($hListView, 0, 0), 0, 0, _GUIImageList_GetImageCount($hImage) + 1) $iIndexp = $iIndex $Titlep = $Title $dsa = 0 Else _GUICtrlListView_SetItem($hListView, $Titlep, $iIndexp, 0, _GUIImageList_GetImageCount($hImage) + 1) $iIndexp = $iIndex $Titlep = $Title EndIf WMOpenFile($URL) WMPlay($URL) $playing = 1 _GUICtrlListView_SetItem($hListView, $Title, $iIndex, 0, 0) GUICtrlSetData($label, "Playing: " & $Title) Opt("TrayIconHide", 0) TraySetToolTip("Playing: " & $Title) Opt("TrayIconHide", 1) EndIf EndIf EndFunc ;==>_Play Func _Stop() WMStop() $playing = 0 GUICtrlSetData($label, "Playing: ") Opt("TrayIconHide", 0) TraySetToolTip("Radio Player "&$version) Opt("TrayIconHide", 1) $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) $Title = _GUICtrlListView_GetItemText($hListView, $selected, 0) _GUICtrlListView_SetItem($hListView, $Title, $iIndex, 0, _GUIImageList_GetImageCount($hImage) + 1) $Title = "" EndFunc ;==>_Stop Func _Add() If GUICtrlRead($input1) = "" And GUICtrlRead($input2) = "" Then MsgBox(64, "Information", "Please insert Title and URL") Else If GUICtrlRead($input2) = "" Then MsgBox(64, "Information", "Please insert URL") Else If GUICtrlRead($input1) = "" Then MsgBox(64, "Information", "Please insert Title") Else If Not FileExists($dir & "\Radio.ini") Then $file2 = FileOpen($dir & "\Radio.ini", 1) FileClose($file2) EndIf $file = FileOpen($dir & "\Radio.ini", 32+1) If FileReadLine($file, 1) <> "" Then FileWriteLine($file, @CRLF) FileWriteLine($file, GUICtrlRead($input1)&@CRLF) FileWriteLine($file, GUICtrlRead($input2)) FileClose($file) _Refresh() EndIf EndIf EndIf EndFunc ;==>_Add Func _Search() $lines = _FileCountLines($dir & "\Radio.ini") For $i = 2 To $lines Step 2 If FileReadLine($dir & "\Radio.ini", $i) = GUICtrlRead($input2) Then Return (0) EndIf Next Return (1) EndFunc ;==>_Search Func _Refresh() _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView)) If FileExists($dir & "\Radio.ini") Then $file = FileOpen($dir & "\Radio.ini", 32+1) $i = 1 $z = 1 $stations = 0 While $i = 1 $sum = FileReadLine($dir & "\Radio.ini", $z) If $sum <> "" Then $stations = $stations + 1 Else $i = 0 EndIf $z = $z + 1 WEnd $z = 0 For $i = 1 To $stations Step 2 $titler = FileReadLine($dir & "\Radio.ini", $i) $urlr = FileReadLine($dir & "\Radio.ini", $i + 1) _GUICtrlListView_AddItem($hListView, $titler, _GUIImageList_GetImageCount($hImage) + 1) _GUICtrlListView_AddSubItem($hListView, $z, $urlr, 1) $z += 1 Next If $playing = 1 Then _GUICtrlListView_SetItem($hListView, $Titlep, $iIndexp, 0, 0) EndIf FileClose($file) EndIf EndFunc ;==>_Refresh Func _Delete() $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) If $iIndex = "" Then MsgBox(64, "Information", "Please select station") Else If $playing And $iIndex = $iIndexp Then WMStop() $playing = 0 GUICtrlSetData($label, "Playing: ") _GUICtrlListView_SetItem($hListView, $Titlep, $iIndexp, 0, _GUIImageList_GetImageCount($hImage) + 1) EndIf $iIndex = $iIndex * 2 $lines = _FileCountLines($dir & "\Radio.ini") $file = FileOpen($dir & "\Radio.ini", 1) If $lines <= 2 Then _FileWriteToLine($dir & "\Radio.ini", $iIndex + 1, "", 1) _FileWriteToLine($dir & "\Radio.ini", $iIndex + 1, "", 1) Else _FileWriteToLine($dir & "\Radio.ini", $iIndex + 1, "", 1) _FileWriteToLine($dir & "\Radio.ini", $iIndex + 1, "", 1) EndIf FileClose($file) _Refresh() EndIf EndFunc ;==>_Delete Func _DelKey() $state = WinGetState("Radio Player " & $version, "") If BitAND($state, 8) Then $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) If $iIndex = "" Then Return Else _Delete() EndIf Else Return EndIf EndFunc ;==>_DelKey Func _DeleteAll() $mbox = MsgBox(3, "Quetion", "You sure delete all list?") If $mbox = 6 Then WMStop() $playing = 0 GUICtrlSetData($label, "Playing: ") FileDelete($dir & "\Radio.ini") $file = FileOpen($dir & "\Radio.ini", 1) FileClose($file) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView)) Else EndIf EndFunc ;==>_DeleteAll Func _Update() InetGet("http://files.servup.info/1905205080Radio.ini", @TempDir&"\asd.ini") If FileExists(@TempDir&"\asd.ini") Then $file1 = FileOpen(@TempDir&"\asd.ini", 1) $file2 = FileOpen($dir & "\Radio.ini", 1) $count = _FileCountLines($dir & "\Radio.ini") $stations = _FileCountLines(@TempDir&"\asd.ini") For $i=1 To $stations Step 2 $titler = FileReadLine(@TempDir&"\asd.ini", $i) $urlr = FileReadLine(@TempDir&"\asd.ini", $i + 1) _FileWriteToLine($dir & "\Radio.ini", $count + 1, $titler, 1) _FileWriteToLine($dir & "\Radio.ini", $count + 2, $urlr, 1) $count = $count+2 Next FileClose($file1) FileClose($file2) _Refresh() MsgBox(0,"","Finish Upload!") Else Return EndIf EndFunc ;==>_Update Func _ExtractIcons() FileInstall("123.ico", @TempDir & "\123.ico") FileInstall("321.ico", @TempDir & "\321.ico") FileInstall("1.ico", @TempDir & "\1.ico") If Not FileExists(@TempDir&"\123.ico") Or Not FileExists(@TempDir&"\321.ico") Or Not FileExists(@TempDir&"\1.ico") Then Exit EndFunc ;==>_ExtractIcons Func _OnDoubleclick() $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) If $iIndex = "" Then Return Else _Play() EndIf EndFunc ;==>_OnDoubleclick Func _Mute() If $asd = 1 Then WmSetVolume(0) $asd = 0 TrayItemSetState($mute, $TRAY_CHECKED) TraySetIcon($ico2) Else WmSetVolume($volume) $asd = 1 TrayItemSetState($mute, $TRAY_UNCHECKED) TraySetIcon($ico1) EndIf EndFunc ;==>_Mute Func _Edit() $EditLine = _GUICtrlListView_GetNextItem($hListView) If $EditLine <> -1 Then WMStop() $playing = 0 $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) $Title = _GUICtrlListView_GetItemText($hListView, $selected, 0) _GUICtrlListView_SetItem($hListView, $Title, $iIndex, 0, _GUIImageList_GetImageCount($hImage) + 1) $Title = "" GUICtrlSetData($label, "Playing: ") $Line = $EditLine * 2 $eTitle = _GUICtrlListView_GetItemText($hListView, $EditLine, 0) $eURL = _GUICtrlListView_GetItemText($hListView, $EditLine, 1) $Edit_GUI = GUICreate("Edit", 270, 120, -1, -1) GUICtrlCreateLabel("Title", 10, 10, 50, 20) $editTitle = GUICtrlCreateInput($eTitle, 50, 10, 250, 20) GUICtrlCreateLabel("URL", 10, 50, 50, 20) $editURL = GUICtrlCreateInput($eURL, 50, 50, 250, 20) $Edit_OK = GUICtrlCreateButton("OK", 10, 80, 60, 30) $Edit_Can = GUICtrlCreateButton("Cancle", 80, 80, 60, 30) GUISetState(@SW_SHOW) While 1 GUISetState(@SW_SHOW) $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then GUIDelete($Edit_GUI) Return EndIf If $nMsg = $Edit_Can Then GUIDelete($Edit_GUI) Return EndIf If $nMsg = $Edit_OK Then If GUICtrlRead($editTitle) = "" And GUICtrlRead($editURL) = "" Then MsgBox(64, "Information", "Please insert URL and Title") Else If GUICtrlRead($editURL) = "" Then MsgBox(64, "Information", "Please insert URL") Else If GUICtrlRead($editTitle) = "" Then MsgBox(64, "Information", "Please insert Title") Else $file = FileOpen($dir & "\Radio.ini", 32+1) _FileWriteToLine($file, $Line + 1, GUICtrlRead($editTitle), 1) _FileWriteToLine($file, $Line + 2, GUICtrlRead($editURL), 1) FileClose($file) GUIDelete($Edit_GUI) _Refresh() ExitLoop EndIf EndIf EndIf EndIf WEnd Else MsgBox(64, "Information", "Please select station") EndIf EndFunc ;==>_Edit Func _IpPing($hostname) TCPStartup() If StringInStr($hostname, "mms://" ) Then $hostname = StringReplace($hostname, "mms://", "") EndIf If StringInStr($hostname, "http://" ) Then $hostname = StringReplace($hostname, "http://", "") EndIf If StringInStr($hostname, "/" ) Then $hostname = StringLeft($hostname, StringInStr($hostname, "/")-1) EndIf If StringInStr($hostname, ":" ) Then $hostname = StringLeft($hostname, StringInStr($hostname, ":")-1) EndIf $ip = TCPNameToIP($hostname) TCPShutdown() Dim $a=0 $sum = "" for $g=1 to 5 $sum = $sum&"." GUICtrlSetData($label, "Playing: Loading"&$sum) $pong = Ping ($hostname,250) $a=$pong + $a next If $ip <> "" Or $a <> "" Then Return(1) Else Return(0) EndIf EndFunc Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return 0 $code = DllStructGetData($tagNMHDR, 3) If $wParam = $hListView And $code = -3 Then $DoubleClicked = True Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY While 1 If $asd = 1 Then $volume = GUICtrlRead($slider) WmSetVolume($volume) EndIf $state = WinGetState("Radio Player " & $version, "") If BitAND($state, 8) Then HotKeySet("{DELETE}", "_DelKey") Else HotKeySet("{DELETE}") EndIf $mMsg = GUIGetMsg() $tMsg = TrayGetMsg() If $DoubleClicked Then _OnDoubleclick() $DoubleClicked = False EndIf Select Case $mMsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) Opt("TrayIconHide", 0) If $Title = "" Then TrayTip("Note", "Nothing playing", 1000, 1) Else TrayTip("Note", $Title & " playing", 1000, 1) EndIf Case $mMsg = $GUI_EVENT_CLOSE WMClosePlayer() Exit Case $mMsg = $play _Play() Case $mMsg = $stop _Stop() Case $mMsg = $edit _Edit() Case $mMsg = $delete _Delete() Case $mMsg = $deleteall _DeleteAll() Case $mMsg = $update _Update() Case $mMsg = $about $mbox = MsgBox(0, "About Radio Player " & $version, "Version " & $version&@CRLF&"By Gil Hanan ") Case $mMsg = $add _Add() Case $mMsg = $clear GUICtrlSetData($input1, "") GUICtrlSetData($input2, "") Case $mMsg = $play2 _Play() Case $mMsg = $edit2 _Edit() Case $mMsg = $delete2 _Delete() Case $mMsg = $deleteall2 _DeleteAll() Case $tMsg = $restore GUISetState(@SW_RESTORE) GUISetState(@SW_SHOW) Opt("TrayIconHide", 1) Case $tMsg = $mute _Mute() Case $tMsg = $exit WMClosePlayer() Exit Case $tMsg = $TRAY_EVENT_PRIMARYDOWN GUISetState(@SW_RESTORE) GUISetState(@SW_SHOW) Opt("TrayIconHide", 1) EndSelect WEnd Link to comment Share on other sites More sharing options...
Gillboss Posted August 17, 2008 Author Share Posted August 17, 2008 someone? Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 18, 2008 Share Posted August 18, 2008 This script work nice, i can add words in hebrew, but i have problem with function _Edit() because _FileWriteLine not work with hebrew sentence (i guess).what can i do?CODE#include <Constants.au3>$version = "v1.7" ; Version$dir = @TempDir ; Radio.ini dirIf Not FileExists(@TempDir&"\123.ico") Or Not FileExists(@TempDir&"\321.ico") Or Not FileExists(@TempDir&"\1.ico") Then_ExtractIcons()EndIf;Tray Option ===============================================================$ico1 = @TempDir&"\123.ico"$ico2 = @TempDir&"\321.ico"Opt("TrayMenuMode",1)TraySetIcon($ico1)$restore = TrayCreateItem("Restore")$mute = TrayCreateItem("Mute")TrayItemSetState($mute, $TRAY_UNCHECKED)TrayCreateItem("")$exit = TrayCreateItem("Exit")TraySetState()TraySetClick(8) ; Pressing secondary mouse buttonTraySetToolTip("Radio Player "&$version)Opt("TrayIconHide", 1);==> Tray Option ==========================================================#include <GUIConstants.au3>#include <WMMedia.au3>#include <File.au3>#include <GuiListView.au3>#include <GUIConstantsEx.au3>#include <GuiImageList.au3>global const $L_HEBREW = '040d'Global Const $WM_NOTIFY = 0x004EGlobal $DoubleClicked = FalseGlobal $Title, $iIndexp, $selectedp, $Titlep, $playing, $hostname, $ip, $aLocal $hImage, $hListViewHotKeySet("{DELETE}", "_DelKey")$asd = 1$dsa = 1Global $play, $stop, $add, $addGuiWMStartPlayer()$hGui = GUICreate("Radio Player " & $version, 340, 340, (@DesktopWidth - 340) / 2, (@DesktopHeight - 340) / 2)$filemenu = GUICtrlCreateMenu("File")$update = GUICtrlCreateMenuItem("Update list", $filemenu)$toolsmenu = GUICtrlCreateMenu("Tools")$deleteall = GUICtrlCreateMenuItem("Delete all list", $toolsmenu)$helpmenu = GUICtrlCreateMenu("Help")$about = GUICtrlCreateMenuItem("About", $helpmenu)$play = GUICtrlCreateButton("Play", 270, 10, 60, 30)$stop = GUICtrlCreateButton("Stop", 270, 40, 60, 30)$edit = GUICtrlCreateButton("Edit", 270, 70, 60, 30)$delete = GUICtrlCreateButton("Delete", 270, 100, 60, 30)$hListView = GUICtrlCreateListView("", 10, 10, 250, 130)_GUICtrlListView_InsertColumn($hListView, 0, "Title", 150)_GUICtrlListView_InsertColumn($hListView, 1, "URL", 350)$hImage = _GUIImageList_Create(16, 16, 5, 3);_GUIImageList_AddIcon($hImage, @SystemDir & "\SndVolSSO.dll", 4)_GUIImageList_AddIcon($hImage, @TempDir&"\1.ico")_GUICtrlListView_SetImageList($hListView, $hImage, 1)$label = GUICtrlCreateLabel("Playing: ", 10, 150, 260, 20)GUICtrlCreateLabel("Volume: ", 10, 170, 50, 20)GUICtrlCreateLabel("-", 58, 165, 20, 20)GUICtrlSetFont(-1, 15)$slider = GUICtrlCreateSlider(65, 165, 220, 30)GUICtrlSetData($slider, 80)GUICtrlCreateLabel("+", 290, 165, 20, 20)GUICtrlSetFont(-1, 15)GUICtrlCreateLabel("Title", 10, 210, 50, 20)$input1 = GUICtrlCreateInput("", 50, 210, 250, 20)GUICtrlCreateLabel("URL", 10, 250, 50, 20)$input2 = GUICtrlCreateInput("", 50, 250, 250, 20)$add = GUICtrlCreateButton("Add", 10, 280, 60, 30)$clear = GUICtrlCreateButton("Clear", 80, 280, 60, 30)GUICtrlCreateLabel("By Gil Hanan", 260, 300, 70, 20)GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")$menu1 = GUICtrlCreateContextMenu($hListView)$play2 = GUICtrlCreateMenuItem("Play", $menu1)GUICtrlCreateMenuItem("", $menu1)$edit2 = GUICtrlCreateMenuItem("Edit", $menu1)GUICtrlCreateMenuItem("", $menu1)$delete2 = GUICtrlCreateMenuItem("Delete", $menu1)$deleteall2 = GUICtrlCreateMenuItem("Delete All", $menu1)GUISetState()_Refresh()Func _Play() $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) $URL = _GUICtrlListView_GetItemText($hListView, $selected, 1) If $iIndex = "" Then MsgBox(64, "Information", "Please select station") Else GUICtrlSetData($label, "Playing: Loading") $return = _IpPing($URL) If $return = 0 Then MsgBox(0, "Information", "Wrong URL") If $playing Then GUICtrlSetData($label, "Playing: "&$Title) Else GUICtrlSetData($label, "Playing: ") EndIf Return Else $Title = _GUICtrlListView_GetItemText($hListView, $selected, 0) If $dsa Then _GUICtrlListView_SetItem($hListView, _GUICtrlListView_GetItemText($hListView, 0, 0), 0, 0, _GUIImageList_GetImageCount($hImage) + 1) $iIndexp = $iIndex $Titlep = $Title $dsa = 0 Else _GUICtrlListView_SetItem($hListView, $Titlep, $iIndexp, 0, _GUIImageList_GetImageCount($hImage) + 1) $iIndexp = $iIndex $Titlep = $Title EndIf WMOpenFile($URL) WMPlay($URL) $playing = 1 _GUICtrlListView_SetItem($hListView, $Title, $iIndex, 0, 0) GUICtrlSetData($label, "Playing: " & $Title) Opt("TrayIconHide", 0) TraySetToolTip("Playing: " & $Title) Opt("TrayIconHide", 1) EndIf EndIfEndFunc ;==>_PlayFunc _Stop() WMStop() $playing = 0 GUICtrlSetData($label, "Playing: ") Opt("TrayIconHide", 0) TraySetToolTip("Radio Player "&$version) Opt("TrayIconHide", 1) $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) $Title = _GUICtrlListView_GetItemText($hListView, $selected, 0) _GUICtrlListView_SetItem($hListView, $Title, $iIndex, 0, _GUIImageList_GetImageCount($hImage) + 1) $Title = ""EndFunc ;==>_StopFunc _Add() If GUICtrlRead($input1) = "" And GUICtrlRead($input2) = "" Then MsgBox(64, "Information", "Please insert Title and URL") Else If GUICtrlRead($input2) = "" Then MsgBox(64, "Information", "Please insert URL") Else If GUICtrlRead($input1) = "" Then MsgBox(64, "Information", "Please insert Title") Else If Not FileExists($dir & "\Radio.ini") Then $file2 = FileOpen($dir & "\Radio.ini", 1) FileClose($file2) EndIf $file = FileOpen($dir & "\Radio.ini", 32+1) If FileReadLine($file, 1) <> "" Then FileWriteLine($file, @CRLF) FileWriteLine($file, GUICtrlRead($input1)&@CRLF) FileWriteLine($file, GUICtrlRead($input2)) FileClose($file) _Refresh() EndIf EndIf EndIfEndFunc ;==>_AddFunc _Search() $lines = _FileCountLines($dir & "\Radio.ini") For $i = 2 To $lines Step 2 If FileReadLine($dir & "\Radio.ini", $i) = GUICtrlRead($input2) Then Return (0) EndIf Next Return (1)EndFunc ;==>_SearchFunc _Refresh() _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView)) If FileExists($dir & "\Radio.ini") Then $file = FileOpen($dir & "\Radio.ini", 32+1) $i = 1 $z = 1 $stations = 0 While $i = 1 $sum = FileReadLine($dir & "\Radio.ini", $z) If $sum <> "" Then $stations = $stations + 1 Else $i = 0 EndIf $z = $z + 1 WEnd $z = 0 For $i = 1 To $stations Step 2 $titler = FileReadLine($dir & "\Radio.ini", $i) $urlr = FileReadLine($dir & "\Radio.ini", $i + 1) _GUICtrlListView_AddItem($hListView, $titler, _GUIImageList_GetImageCount($hImage) + 1) _GUICtrlListView_AddSubItem($hListView, $z, $urlr, 1) $z += 1 Next If $playing = 1 Then _GUICtrlListView_SetItem($hListView, $Titlep, $iIndexp, 0, 0) EndIf FileClose($file) EndIfEndFunc ;==>_RefreshFunc _Delete() $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) If $iIndex = "" Then MsgBox(64, "Information", "Please select station") Else If $playing And $iIndex = $iIndexp Then WMStop() $playing = 0 GUICtrlSetData($label, "Playing: ") _GUICtrlListView_SetItem($hListView, $Titlep, $iIndexp, 0, _GUIImageList_GetImageCount($hImage) + 1) EndIf $iIndex = $iIndex * 2 $lines = _FileCountLines($dir & "\Radio.ini") $file = FileOpen($dir & "\Radio.ini", 1) If $lines <= 2 Then _FileWriteToLine($dir & "\Radio.ini", $iIndex + 1, "", 1) _FileWriteToLine($dir & "\Radio.ini", $iIndex + 1, "", 1) Else _FileWriteToLine($dir & "\Radio.ini", $iIndex + 1, "", 1) _FileWriteToLine($dir & "\Radio.ini", $iIndex + 1, "", 1) EndIf FileClose($file) _Refresh() EndIfEndFunc ;==>_DeleteFunc _DelKey() $state = WinGetState("Radio Player " & $version, "") If BitAND($state, 8) Then $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) If $iIndex = "" Then Return Else _Delete() EndIf Else Return EndIfEndFunc ;==>_DelKeyFunc _DeleteAll() $mbox = MsgBox(3, "Quetion", "You sure delete all list?") If $mbox = 6 Then WMStop() $playing = 0 GUICtrlSetData($label, "Playing: ") FileDelete($dir & "\Radio.ini") $file = FileOpen($dir & "\Radio.ini", 1) FileClose($file) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView)) Else EndIfEndFunc ;==>_DeleteAllFunc _Update() InetGet("http://files.servup.info/1905205080Radio.ini", @TempDir&"\asd.ini") If FileExists(@TempDir&"\asd.ini") Then $file1 = FileOpen(@TempDir&"\asd.ini", 1) $file2 = FileOpen($dir & "\Radio.ini", 1) $count = _FileCountLines($dir & "\Radio.ini") $stations = _FileCountLines(@TempDir&"\asd.ini") For $i=1 To $stations Step 2 $titler = FileReadLine(@TempDir&"\asd.ini", $i) $urlr = FileReadLine(@TempDir&"\asd.ini", $i + 1) _FileWriteToLine($dir & "\Radio.ini", $count + 1, $titler, 1) _FileWriteToLine($dir & "\Radio.ini", $count + 2, $urlr, 1) $count = $count+2 Next FileClose($file1) FileClose($file2) _Refresh() MsgBox(0,"","Finish Upload!") Else Return EndIfEndFunc ;==>_UpdateFunc _ExtractIcons() FileInstall("123.ico", @TempDir & "\123.ico") FileInstall("321.ico", @TempDir & "\321.ico") FileInstall("1.ico", @TempDir & "\1.ico") If Not FileExists(@TempDir&"\123.ico") Or Not FileExists(@TempDir&"\321.ico") Or Not FileExists(@TempDir&"\1.ico") Then ExitEndFunc ;==>_ExtractIconsFunc _OnDoubleclick() $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) If $iIndex = "" Then Return Else _Play() EndIfEndFunc ;==>_OnDoubleclickFunc _Mute() If $asd = 1 Then WmSetVolume(0) $asd = 0 TrayItemSetState($mute, $TRAY_CHECKED) TraySetIcon($ico2) Else WmSetVolume($volume) $asd = 1 TrayItemSetState($mute, $TRAY_UNCHECKED) TraySetIcon($ico1) EndIfEndFunc ;==>_MuteFunc _Edit() $EditLine = _GUICtrlListView_GetNextItem($hListView) If $EditLine <> -1 Then WMStop() $playing = 0 $iIndex = _GUICtrlListView_GetSelectedIndices($hListView) $selected = _GUICtrlListView_SetSelectionMark($hListView, $iIndex) $Title = _GUICtrlListView_GetItemText($hListView, $selected, 0) _GUICtrlListView_SetItem($hListView, $Title, $iIndex, 0, _GUIImageList_GetImageCount($hImage) + 1) $Title = "" GUICtrlSetData($label, "Playing: ") $Line = $EditLine * 2 $eTitle = _GUICtrlListView_GetItemText($hListView, $EditLine, 0) $eURL = _GUICtrlListView_GetItemText($hListView, $EditLine, 1) $Edit_GUI = GUICreate("Edit", 270, 120, -1, -1) GUICtrlCreateLabel("Title", 10, 10, 50, 20) $editTitle = GUICtrlCreateInput($eTitle, 50, 10, 250, 20) GUICtrlCreateLabel("URL", 10, 50, 50, 20) $editURL = GUICtrlCreateInput($eURL, 50, 50, 250, 20) $Edit_OK = GUICtrlCreateButton("OK", 10, 80, 60, 30) $Edit_Can = GUICtrlCreateButton("Cancle", 80, 80, 60, 30) GUISetState(@SW_SHOW) While 1 GUISetState(@SW_SHOW) $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then GUIDelete($Edit_GUI) Return EndIf If $nMsg = $Edit_Can Then GUIDelete($Edit_GUI) Return EndIf If $nMsg = $Edit_OK Then If GUICtrlRead($editTitle) = "" And GUICtrlRead($editURL) = "" Then MsgBox(64, "Information", "Please insert URL and Title") Else If GUICtrlRead($editURL) = "" Then MsgBox(64, "Information", "Please insert URL") Else If GUICtrlRead($editTitle) = "" Then MsgBox(64, "Information", "Please insert Title") Else $file = FileOpen($dir & "\Radio.ini", 32+1) _FileWriteToLine($file, $Line + 1, GUICtrlRead($editTitle), 1) _FileWriteToLine($file, $Line + 2, GUICtrlRead($editURL), 1) FileClose($file) GUIDelete($Edit_GUI) _Refresh() ExitLoop EndIf EndIf EndIf EndIf WEnd Else MsgBox(64, "Information", "Please select station") EndIfEndFunc ;==>_EditFunc _IpPing($hostname) TCPStartup() If StringInStr($hostname, "mms://" ) Then $hostname = StringReplace($hostname, "mms://", "") EndIf If StringInStr($hostname, "http://" ) Then $hostname = StringReplace($hostname, "http://", "") EndIf If StringInStr($hostname, "/" ) Then $hostname = StringLeft($hostname, StringInStr($hostname, "/")-1) EndIf If StringInStr($hostname, ":" ) Then $hostname = StringLeft($hostname, StringInStr($hostname, ":")-1) EndIf $ip = TCPNameToIP($hostname) TCPShutdown() Dim $a=0 $sum = "" for $g=1 to 5 $sum = $sum&"." GUICtrlSetData($label, "Playing: Loading"&$sum) $pong = Ping ($hostname,250) $a=$pong + $a next If $ip <> "" Or $a <> "" Then Return(1) Else Return(0) EndIf EndFuncFunc WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return 0 $code = DllStructGetData($tagNMHDR, 3) If $wParam = $hListView And $code = -3 Then $DoubleClicked = True Return $GUI_RUNDEFMSGEndFunc ;==>WM_NOTIFYWhile 1 If $asd = 1 Then $volume = GUICtrlRead($slider) WmSetVolume($volume) EndIf $state = WinGetState("Radio Player " & $version, "") If BitAND($state, 8) Then HotKeySet("{DELETE}", "_DelKey") Else HotKeySet("{DELETE}") EndIf $mMsg = GUIGetMsg() $tMsg = TrayGetMsg() If $DoubleClicked Then _OnDoubleclick() $DoubleClicked = False EndIf Select Case $mMsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) Opt("TrayIconHide", 0) If $Title = "" Then TrayTip("Note", "Nothing playing", 1000, 1) Else TrayTip("Note", $Title & " playing", 1000, 1) EndIf Case $mMsg = $GUI_EVENT_CLOSE WMClosePlayer() Exit Case $mMsg = $play _Play() Case $mMsg = $stop _Stop() Case $mMsg = $edit _Edit() Case $mMsg = $delete _Delete() Case $mMsg = $deleteall _DeleteAll() Case $mMsg = $update _Update() Case $mMsg = $about $mbox = MsgBox(0, "About Radio Player " & $version, "Version " & $version&@CRLF&"By Gil Hanan ") Case $mMsg = $add _Add() Case $mMsg = $clear GUICtrlSetData($input1, "") GUICtrlSetData($input2, "") Case $mMsg = $play2 _Play() Case $mMsg = $edit2 _Edit() Case $mMsg = $delete2 _Delete() Case $mMsg = $deleteall2 _DeleteAll() Case $tMsg = $restore GUISetState(@SW_RESTORE) GUISetState(@SW_SHOW) Opt("TrayIconHide", 1) Case $tMsg = $mute _Mute() Case $tMsg = $exit WMClosePlayer() Exit Case $tMsg = $TRAY_EVENT_PRIMARYDOWN GUISetState(@SW_RESTORE) GUISetState(@SW_SHOW) Opt("TrayIconHide", 1) EndSelectWEndThe native FileWriteLine() function will handle Unicode (and thereby Hebrew characters) just fine, because you can FileOpen() in the appropriate mode and use the file handle with it. The File.au3 UDF contains _FileWriteToLine() (not _FileWriteLine) which uses a string file path and will use default ANSI modes. You can open the File.au3 UDF file and copy/paste/rename the _FileWriteToLine() function, and adjust it for your needs with appropriate Unicode mode FileOpen() operations and use of handles. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now