orange Posted June 8, 2006 Share Posted June 8, 2006 well, this is my second program ever with AUTOIT, and I am having a ridiculous problem. I can't figure out how to clear the lyric output box if someone wants to look up more than one song in a row! There has to be a simple function for this, but I can't find it. Here we go:expandcollapse popup#include <GUIConstants.au3> #include<file.au3> GUICreate("Lyric Finder",275,300) $artist = GUICtrlCreateInput ( "", 50, 10, 200, 20) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel ( "Artist", 14, 14) $song = GUICtrlCreateInput ( "", 50, 40, 200, 20) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel ( "Song", 14, 44) $myedit=GUICtrlCreateEdit ("",10,74,255,156,$ES_AUTOVSCROLL+$WS_VSCROLL) $okbutton = GuiCtrlCreateButton ("Find Lyrics",15,260,70,20) GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $okbutton clickapply() EndSelect ;GUIctrlread($slider1) WEnd GUIDelete() Exit Func clickapply() $var1 = String("") $var2 = String("") $artist = StringReplace($artist," ","_") $song = StringReplace($song," ","_") InetGet ( "http://www.absolutelyrics.com/lyrics/view/" & GUIctrlread($artist) & "/" & GUIctrlread($song), "C:\foo.html") FileOpen ( "C:\foo.html", 1) $path = String("c:\foo.html") $line = _FileLineSearch($path,"id=lyricsinformation") $line2 = _FileLineSearch($path,"---------------") if $line+2>$line2 Then _FileCreate("c:\foo.temp") Fileopen("c:\foo.temp",1) for $int = $Line to $line2 FilewriteLine("c:\foo.temp",StringReplace(Filereadline("c:\foo.html",$line),"<br />",@CRLF & "<br />")) $line2 = _FileLineSearch("c:\foo.html","---------------") Next $path = String("c:\foo.temp") Fileclose ( "C:\foo.temp") EndIf $line = _FileLineSearch($path,"id=lyricsinformation") $line2 = _FileLineSearch($path,"---------------") $handle1 = Fileopen("c:\foo.temp",0) $handle = FileOpen ( "C:\foo.html", 0) $line = $line+2 For $count = $line to $line2 $var1 = FileReadLine($path,$count) $var2 = StringTrimLeft($var1,6) if (Stringinstr($var2,"div id=") > 0) then $var2 = stringtrimleft($var2,19) if $count = $line2 then $var2 = Stringtrimright($var2,Stringlen($var2)-Stringinstr($var2,"</div")+1) GUICtrlSetData ($myedit, $var2 & @CRLF,1) Next FileDelete($handle) FileDelete($handle1) EndFunc Func _FileLineSearch ($string,$search) FileOpen($string,1) $linecount = _FileCountLines($string) for $increment = 1 to $linecount step 1 $tempstring = FileReadLine($string, $increment) ;MsgBox(1,"",$tempstring) if StringInStr($tempstring,$search) > 0 then Return $increment ExitLoop EndIf Next EndFunc What do I do? Are there any improvements that you think that I can make? I am sure that there are some! Link to comment Share on other sites More sharing options...
ptrex Posted June 8, 2006 Share Posted June 8, 2006 @orange Did some quick changes expandcollapse popup#include <GUIConstants.au3> #include<file.au3> #include<GuiList.au3> ; ADDED GUICreate("Lyric Finder",375,400,(@DesktopWidth/2)-150, (@DesktopHeight/2)-200, _ ; CHANGED $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $artist = GUICtrlCreateInput ( "", 50, 10, 200, 20) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel ( "Artist", 14, 14) $song = GUICtrlCreateInput ( "", 50, 40, 200, 20) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel ( "Song", 14, 44) $myedit=GUICtrlCreateList ("",10,74,355,300,$ES_AUTOVSCROLL+$WS_VSCROLL) ; CHANGED $okbutton = GuiCtrlCreateButton ("Find Lyrics",15,370,70,20) ; CHANGED GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $okbutton clickapply() EndSelect ;GUIctrlread($slider1) WEnd GUIDelete() Exit Func clickapply() _GUICtrlListClear($myedit) ; ADDED $var1 = String("") $var2 = String("") $artist = StringReplace($artist," ","_") $song = StringReplace($song," ","_") InetGet ( "http://www.absolutelyrics.com/lyrics/view/" & GUIctrlread($artist) & "/" & GUIctrlread($song), "C:\foo.html") FileOpen ( "C:\foo.html", 1) $path = String("c:\foo.html") $line = _FileLineSearch($path,"id=lyricsinformation") $line2 = _FileLineSearch($path,"---------------") if $line+2>$line2 Then _FileCreate("c:\foo.temp") Fileopen("c:\foo.temp",1) for $int = $Line to $line2 FilewriteLine("c:\foo.temp",StringReplace(Filereadline("c:\foo.html",$line),"<br />",@CRLF & "<br />")) $line2 = _FileLineSearch("c:\foo.html","---------------") Next $path = String("c:\foo.temp") Fileclose ( "C:\foo.temp") EndIf $line = _FileLineSearch($path,"id=lyricsinformation") $line2 = _FileLineSearch($path,"---------------") $handle1 = Fileopen("c:\foo.temp",0) $handle = FileOpen ( "C:\foo.html", 0) $line = $line+2 For $count = $line to $line2 $var1 = FileReadLine($path,$count) $var2 = StringTrimLeft($var1,6) if (Stringinstr($var2,"div id=") > 0) then $var2 = stringtrimleft($var2,19) if $count = $line2 then $var2 = Stringtrimright($var2,Stringlen($var2)-Stringinstr($var2,"</div")+1) GUICtrlSetData ($myedit, $var2 & @CR ,1) ; Next FileDelete($handle) FileDelete($handle1) EndFunc Func _FileLineSearch ($string,$search) FileOpen($string,1) $linecount = _FileCountLines($string) for $increment = 1 to $linecount step 1 $tempstring = FileReadLine($string, $increment) ;MsgBox(1,"",$tempstring) if StringInStr($tempstring,$search) > 0 then Return $increment ExitLoop EndIf Next EndFunc Nice application by the way. Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Emperor Posted June 8, 2006 Share Posted June 8, 2006 Maybe you could make it show up a box saying the lyrics could not be found or something, been waiting for like 5 mins only to find out the site doesnt have the lyrics im looking for Link to comment Share on other sites More sharing options...
JSThePatriot Posted June 8, 2006 Share Posted June 8, 2006 Another suggestion would be to add several lyrics sites that it could search through. Great little program! JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008Â Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
RazerM Posted June 8, 2006 Share Posted June 8, 2006 This is really good. Only problem is each line has a box character at the end My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
Busti Posted June 8, 2006 Share Posted June 8, 2006 stringregexpreplace( $string , "" , @CRLF ) replaces the box charackters My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
orange Posted June 8, 2006 Author Share Posted June 8, 2006 Maybe you could make it show up a box saying the lyrics could not be found or something, been waiting for like 5 mins only to find out the site doesnt have the lyrics im looking for Yeah, I know about that problem. sorry that you were waiting. but I am going to fix that. as for the box characters, I am not getting those on my machine, so I dont know! Link to comment Share on other sites More sharing options...
Busti Posted June 8, 2006 Share Posted June 8, 2006 i get them too. My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
orange Posted June 8, 2006 Author Share Posted June 8, 2006 actually, runnning the second version, I do as well. I am going to try and fix that, as well as adding support for other websites, and a notification that your song does not exist. However, a plebian problem first: My Auitoit can't find GUIlist.au3!!! THis is excruciatingly annoying. any suggestions? I am running the latest Beta. Link to comment Share on other sites More sharing options...
JSThePatriot Posted June 8, 2006 Share Posted June 8, 2006 actually, runnning the second version, I do as well. I am going to try and fix that, as well as adding support for other websites, and a notification that your song does not exist.However, a plebian problem first:My Auitoit can't find GUIlist.au3!!! THis is excruciatingly annoying. any suggestions?I am running the latest Beta.Its in my latest beta\includes folder.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008Â Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
orange Posted June 8, 2006 Author Share Posted June 8, 2006 Its in my latest beta\includes folder.JSthanks much. I will check that out when I get home tonight. I am assuming then that I have to copy that in to the directory of the program so that it can find it?Also, the next version of this program that I am working on is going to have the ability to choose which search engine, or search all -- also I have included a fuction that fixes the problem that I initally addressed.I liked the solution provided, but the list did not appeal to me, so I am trying to do it again with an edit box, so that the lyrics can be saved in a file, or so that they can be copied as a file.Also is there any way that I can download any part of an HTML script, so that it does not take so long to dowload the page? Link to comment Share on other sites More sharing options...
RazerM Posted June 8, 2006 Share Posted June 8, 2006 you don't have to copy the file. Just make sure you run the file using beta My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted June 8, 2006 Moderators Share Posted June 8, 2006 (edited) I messed aroud with this a little bit. expandcollapse popup#include <IE.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", True) $oIE = _IECreateEmbedded () GUICreate("Lyric Finder", 375, 400, (@DesktopWidth / 2) - 150, (@DesktopHeight / 2) - 200, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlCreateObj($oIE, 320, 5, 50, 50) GUICtrlSetState(-1, $GUI_HIDE) $artist = GUICtrlCreateInput("", 50, 10, 200, 20) GUICtrlSetState(-1, $GUI_ACCEPTFILES) GUICtrlCreateLabel("Artist", 14, 14) $song = GUICtrlCreateInput("", 50, 40, 200, 20) GUICtrlSetState(-1, $GUI_ACCEPTFILES) GUICtrlCreateLabel("Song", 14, 44) $myedit = GUICtrlCreateEdit("", 10, 74, 355, 290, $ES_AUTOVSCROLL + $WS_VSCROLL) $okbutton = GUICtrlCreateButton("Find Lyrics", 15, 370, 70, 20) GUICtrlSetOnEvent(-1, "clickapply") GUISetState() _IELoadWaitTimeout (30000) While 1 Sleep(100) WEnd Func clickapply() Local $sText = "", $sArtist = "", $sSong = "" GUICtrlSetData($myedit, "") $sArtist = StringLower(StringReplace(GUICtrlRead($artist), " ", "_")) $sSong = StringLower(StringReplace(GUICtrlRead($song), " ", "_")) If $sArtist <> "" And $sSong <> "" Then ; toggle images off RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "no") _IENavigate($oIE, "http://www.absolutelyrics.com/lyrics/view/" & $sArtist & "/" & $sSong) ; i hate advertisements! If WinExists("http://www.absolutelyrics.com - Advertisement") Then WinClose("http://www.absolutelyrics.com - Advertisement") EndIf ; see if page was found If StringInStr(_IEDocReadHTML ($oIE), "is not found at ABSOLUTELYRICS.COM") Then MsgBox(64, "Lyrics Unavailable", "Sorry that song and artist combination did not return any results.") Return EndIf ; get div tag collection $oDivs = _IETagNameGetCollection ($oIE, "div") ; find the div that has realText as the Id For $oDiv In $oDivs $Id = $oDiv.Id If $Id == "realText" Then ; get the innerText of the div (the lyrics) $sText = $oDiv.innerText ExitLoop EndIf Next ; toggle images on RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "yes") _IENavigate($oIE, "about:blank") If $sText <> "" Then GUICtrlSetData($myedit, $sText) Else MsgBox(64, "Lyrics Unavailable", "Sorry that song and artist combination did not return any results.") EndIf Else MsgBox(64, "Error", "You must provide a song and artist name.") EndIf EndFunc ;==>clickapply Func _Exit() Exit EndFunc ;==>_Exit Edit: why are all the autoit code tags in boxes now? Edited June 8, 2006 by big_daddy Link to comment Share on other sites More sharing options...
orange Posted June 9, 2006 Author Share Posted June 9, 2006 Here we go --- this should have fixed 90% of the problems. Once this is done and reviewed and tweaked, I am going to add other search engines to the mix to see what we have. expandcollapse popup#include <GUIConstants.au3> #include<file.au3> GUICreate("Lyric Finder",275,108,(@DesktopWidth/2)-150, (@DesktopHeight/2)-200, _ ; CHANGED $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $artist = GUICtrlCreateInput ( "", 50, 10, 200, 20) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel ( "Artist", 14, 14) $song = GUICtrlCreateInput ( "", 50, 40, 200, 20) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel ( "Song", 14, 44) ;$myedit=GUICtrlCreateEdit ("",10,74,355,290, $ES_AUTOVSCROLL+$WS_VSCROLL); CHANGED $okbutton = GuiCtrlCreateButton ("Find Lyrics",15,74,70,20); CHANGED GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $okbutton clickapply() EndSelect ;GUIctrlread($slider1) WEnd GUIDelete() Exit Func clickapply() $var1 = String("") $var2 = String("") $artist = StringReplace($artist," ","_") $song = StringReplace($song," ","_") InetGet ( "http://www.absolutelyrics.com/lyrics/view/" & GUIctrlread($artist) & "/" & GUIctrlread($song), "C:\foo.html") FileOpen ( "C:\foo.html", 1) $path = String("c:\foo.html") $line = _FileLineSearch($path,"id=lyricsinformation") $line2 = _FileLineSearch($path,"---------------") if $line+2>$line2 Then _FileCreate("c:\foo.temp") Fileopen("c:\foo.temp",1) for $int = $Line to $line2 FilewriteLine("c:\foo.temp",StringReplace(Filereadline("c:\foo.html",$line),"<br />",@CRLF & "<br />")) $line2 = _FileLineSearch("c:\foo.html","---------------") Next $path = String("c:\foo.temp") Fileclose ( "C:\foo.temp") EndIf $line = _FileLineSearch($path,"id=lyricsinformation") $line2 = _FileLineSearch($path,"---------------") if $line = 0 then msgbox(4096,"No Lyrics", "Lyrics Not Found.") $handle1 = Fileopen("c:\foo.temp",0) $handle = FileOpen ( "C:\foo.html", 0) $line = $line;+2 _filecreate("c:\temp.txt") FileOpen("c:\temp.txt",2) For $count = $line to $line2 $var1 = FileReadLine($path,$count) $var2 = StringTrimLeft($var1,6) if (Stringinstr($var2,"div id=") > 0) then $var2 = stringtrimleft($var2,19) if $count = $line2 then $var2 = Stringtrimright($var2,Stringlen($var2)-Stringinstr($var2,"</div")+1) Filewriteline("c:\temp.txt",$var2 & @CRLF) Next _filecreate("c:\formtlyrics.txt") Fileopen("c:\formtlyrics.txt",1) for $temp = 1 to _FileCountLines("c:\temp.txt") $line = FileReadline("c:\temp.txt",$temp) filewriteline("c:\formtlyrics.txt",stringtrimleft($line,Stringinstr($line,">",0,-1))) Next Fileclose("c:\formtlyrics.txt") _fileinedit("c:\formtlyrics.txt") Fileclose($handle) FileClose($handle1) EndFunc func _fileinEdit($file) GUICreate("Lyrics Found",375,400,(@DesktopWidth/2)-150, (@DesktopHeight/2)-200, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS ) $myedit=GUICtrlCreateEdit ("",5,5,365,390, $ES_AUTOVSCROLL+$WS_VSCROLL) GuiSetState() Fileopen($file,0) for $temp = 1 to _FileCountLines($file) if not filereadline($file,$temp) = "" then GUICtrlSetData ($myedit, filereadline($file,$temp) & @CRLF,1) next fileclose($file) endfunc Func _FileLineSearch ($string,$search) FileOpen($string,1) $linecount = _FileCountLines($string) for $increment = 1 to $linecount step 1 $tempstring = FileReadLine($string, $increment) ;MsgBox(1,"",$tempstring) if StringInStr($tempstring,$search) > 0 then Return $increment ExitLoop EndIf Next EndFunc also, just as a note, I have noticed that some bands have "the" and others do not... "The Rolling stones" "Eagles" Just an odd thing. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted June 9, 2006 Moderators Share Posted June 9, 2006 (edited) This includes: lyrics, album name, album cover, release date, and a status bar. The only thing that I can't figure out is how to keep the ads from poping up.p.s. the file below contains a picture, put it in the same directory as the script.See this post for the latest version.Edit: added a status bar, also fixed a couple bugsEdit: added link to updated version Edited June 12, 2006 by big_daddy Link to comment Share on other sites More sharing options...
slightly_abnormal Posted June 9, 2006 Share Posted June 9, 2006 be careful some of the lyric sites try to download viruses. nice job though Link to comment Share on other sites More sharing options...
orange Posted June 10, 2006 Author Share Posted June 10, 2006 you totally had to upshow me there didn't you!!! Excellent job. Helps me out alot! Could you upload an exe perhaps? orange Link to comment Share on other sites More sharing options...
orange Posted June 10, 2006 Author Share Posted June 10, 2006 you don't have to copy the file. Just make sure you run the file using betamy beta has never functioned correctly. I have downloaded it time and again, and the error is always the same. I have installed and uninstalled, I have reinstalled and deleted. All to no avail.However, it would be excellent if I could get this problem fixed. I seem to be the only one with it. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted June 11, 2006 Moderators Share Posted June 11, 2006 you totally had to upshow me there didn't you!!!Excellent job. Helps me out alot!Could you upload an exe perhaps?orangeDefinatly not what I was trying to do. You just came up with a great idea and start, so I ran with it. I have a few ideas that I'm working on; browse for .mp3 and read artist & song name, save the lyrics in the idv3 tags of the opened .mp3.As far as the exe, I won't be able to until tommorow morning. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted June 12, 2006 Moderators Share Posted June 12, 2006 This is a big improvement over my previous version!Fixed: Popup ads (as long as you have popup blocking enabled)Added: Ability to save lyrics and album photoAdded: Ability to browse for song file; reads song title and artist if available, imports saved lyrics and album photo if availableexpandcollapse popupFileInstall("default.gif", @TempDir & "\default.gif", 1) #include <File.au3> #include <IE.au3> #include <GUIConstants.au3> #include <GUIStatusBar.au3> #include <String.au3> Opt("GUIOnEventMode", True) Opt("WinWaitDelay", 0) Global $sPath = "", $oIE1 = "", $oIE2 = "" Global $aStatusMSG[15] =[" Enter song and artist, and then press enter.", _ " Please Wait...", " Looking for artist and song", " Gathering lyrics", _ " Looking for album info", " Complete", " Sorry, that did not return any results.", _ " Sorry, there was a problem opening the file.", " Sorry, could not pull artist and song name.", _ " Looking for tag info", " Tag info found, ready to search for ryrics.", " Unable to create file.", _ " The file was saved successfully.", " The file was not saved.", " Lyrics acquired from previous save."] Dim $aStatusParts[2] =[230, -1] $GUI = GUICreate("Lyric Finder", 400, 470, (@DesktopWidth / 2) - 200, (@DesktopHeight / 2) - 225, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetOnEvent($GUI_EVENT_RESIZED, "_Resize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_Resize") GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Resize") GUISetOnEvent($GUI_EVENT_RESTORE, "_Resize") $pic = GUICtrlCreatePic(@TempDir & "\default.gif", 260, 10, 130, 130) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKRIGHT + $GUI_DOCKSIZE) $artist = GUICtrlCreateInput("", 50, 10, 200, 20) GUICtrlSetState(-1, $GUI_ACCEPTFILES) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT) GUICtrlCreateLabel("Artist", 10, 14) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) $song = GUICtrlCreateInput("", 50, 40, 200, 20) GUICtrlSetState(-1, $GUI_ACCEPTFILES) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT) GUICtrlCreateLabel("Song", 10, 44) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) $album = GUICtrlCreateLabel("Album :", 100, 75, 140, "", $SS_LEFTNOWORDWRAP) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) $date = GUICtrlCreateLabel("Release :", 100, 95, 140, "", $SS_LEFTNOWORDWRAP) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) $edit1 = GUICtrlCreateEdit("", 10, 150, 380, 290, $ES_AUTOVSCROLL + $WS_VSCROLL) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKLEFT + $GUI_DOCKRIGHT) $button1 = GUICtrlCreateButton("Find Lyrics", 10, 120, 70, 20, $BS_DEFPUSHBUTTON) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) GUICtrlSetOnEvent(-1, "_FindLyrics") $button2 = GUICtrlCreateButton("Browse", 90, 120, 70, 20) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) GUICtrlSetOnEvent(-1, "_Browse") $button3 = GUICtrlCreateButton("Save", 170, 120, 70, 20) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) GUICtrlSetOnEvent(-1, "_Save") $StatusBar = _GuiCtrlStatusBarCreate($GUI, $aStatusParts, "", $SBARS_SIZEGRIP) _GuiCtrlStatusBarSetMinHeight($StatusBar, 20) _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[0]) GUICtrlSetState($artist, $GUI_FOCUS) GUISetState() _IEErrorHandlerRegister () _IELoadWaitTimeout (30000) $oIE1 = _IECreate ("about:blank", Default, 0, 0) $oIE2 = _IECreate ("about:blank", Default, 0, 0) While 1 Sleep(100) WEnd Func _FindLyrics() Local $sText = "", $sArtist = "", $sSong = "" ; reset fields to default GUICtrlSetData($edit1, "") GUICtrlSetData($album, "Album :") GUICtrlSetData($date, "Release :") GUICtrlSetImage($pic, @TempDir & "\default.gif") _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[1]) _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[2], 1) ; make artist and song strings lowercase and replace spaces with underscores $sArtist = StringLower(StringReplace(GUICtrlRead($artist), " ", "_")) $sSong = StringLower(StringReplace(GUICtrlRead($song), " ", "_")) If $sArtist <> "" And $sSong <> "" Then ; toggle images off RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "no") ; navigate to lyrics page _IENavigate ($oIE1, "http://www.absolutelyrics.com/lyrics/view/" & $sArtist & "/" & $sSong) ; see if page was found $sBodyText = _IEBodyReadText ($oIE1) If StringInStr($sBodyText, "is not found at ABSOLUTELYRICS.COM") Or _ StringInStr($sBodyText, "The page cannot be found") Then ; toggle images on RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "yes") _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[6]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Return 0 EndIf _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[3], 1) ; get div tag collection $oDivs = _IETagNameGetCollection ($oIE1, "div") ; find the div that has realText as the Id For $oDiv In $oDivs $Id = $oDiv.Id If $Id == "realText" Then ; get the innerText of the div (the lyrics) $sText = $oDiv.innerText ExitLoop EndIf Next _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[4], 1) ; navigate to the artists page _IENavigate ($oIE2, "http://www.absolutelyrics.com/lyrics/artist/" & $sArtist) ; get a collection of all links $oLinks = _IETagNameGetCollection ($oIE2, "a") ; loop through links For $oLink In $oLinks ; url of the current link $href = $oLink.href ; see if the link matches our song and artist If $href == "http://www.absolutelyrics.com/lyrics/view/" & $sArtist & "/" & $sSong & "/" Then $li = $oLink.parentElement $ul = $li.parentElement $td1 = $ul.parentElement $sAlbum = $td1.innerText $td2 = $td1.previousSibling $sRelease = $td2.innerText $img = $td2.firstChild $img = $img.src ExitLoop EndIf Next ; toggle images on RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "yes") _IENavigate ($oIE1, "about:blank") _IENavigate ($oIE2, "about:blank") ; download the album photo and set as image If InetGet($img, @TempDir & "\temp_album.jpg") Then GUICtrlSetImage($pic, @TempDir & "\temp_album.jpg") EndIf ; format and display album info If $sAlbum <> "" And $sRelease <> "" Then $sAlbum = StringSplit($sAlbum, @LF) $sRelease = StringReplace($sRelease, @CRLF, "") GUICtrlSetData($album, $sAlbum[1]) GUICtrlSetData($date, $sRelease) EndIf ; display the lyrics If $sText <> "" Then GUICtrlSetData($edit1, $sText) Else _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[6]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Return 0 EndIf _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[5]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Else _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[6]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Return 0 EndIf EndFunc ;==>_FindLyrics Func _Browse() Local $sPathTemp, $sPathText, $sText, $sFileName $sPath = FileOpenDialog("Browse for .MP3", @MyDocumentsDir & _ "\My Music\", "Music Files (*.mp3;*.wav;*.wma;)", 1) _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[1]) _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[9], 1) If $sPath <> "" Then ; reset fields to default GUICtrlSetData($edit1, "") GUICtrlSetData($album, "Album :") GUICtrlSetData($date, "Release :") GUICtrlSetImage($pic, @TempDir & "\default.gif") ; get extended file properties $aProp = _GetExtProperty($sPath, -1) If $aProp[10] <> "" And $aProp[16] <> "" Then GUICtrlSetData($artist, $aProp[16]) GUICtrlSetData($song, $aProp[10]) $sFileName = $aProp[16] & "-" & $aProp[10] & ".txt" $sPathTemp = StringTrimRight($sPath, StringLen($sPath) - StringInStr($sPath, "\", 0, -1)) $sPathText = _StringInsert($sPathTemp, $sFileName, StringLen($sPathTemp)) If FileExists($sPathText) Then $sText = FileRead($sPathText) GUICtrlSetData($edit1, $sText) If FileExists($sPathTemp & "album_cover.jpg") Then GUICtrlSetImage($pic, $sPathTemp & "album_cover.jpg") EndIf _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[14]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Return 0 EndIf Else _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[8]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Return 0 EndIf Else _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[7]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Return 0 EndIf _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[10]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) EndFunc ;==>_Browse Func _Save() Local $sPathText, $sPathTemp If $sPath == "" Then $sPathText = FileSaveDialog("Save Lyrics", @MyDocumentsDir & _ "\My Music", "Text (*txt)", 16, GUICtrlRead($artist) & "-" & GUICtrlRead($song) & ".txt") Else $sPathTemp = StringTrimRight($sPath, StringLen($sPath) - StringInStr($sPath, "\", 0, -1)) $sPathText = FileSaveDialog("Save Lyrics", $sPathTemp, "Text (*txt)", 16, GUICtrlRead($artist) & _ "-" & GUICtrlRead($song) & ".txt") EndIf If $sPathText <> "" Then _FileCreate($sPathText) If Not @error Then FileWrite($sPathText, GUICtrlRead($edit1)) Else _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[11]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Return 0 EndIf Else _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[13]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) Return 0 EndIf If MsgBox(36, "Album Cover", "Would you also like to save the album cover?") == 6 Then FileCopy(@TempDir & "\temp_album.jpg", $sPathTemp & "album_cover.jpg") EndIf _GuiCtrlStatusBarSetText($StatusBar, $aStatusMSG[12]) _GuiCtrlStatusBarSetText($StatusBar, "", 1) EndFunc ;==>_Save Func _GetExtProperty($sPath, $iProp) Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty $iExist = FileExists($sPath) If $iExist = 0 Then SetError(1) Return 0 Else $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1)) $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1))) $oShellApp = ObjCreate("shell.application") $oDir = $oShellApp.NameSpace ($sDir) $oFile = $oDir.Parsename ($sFile) If $iProp = -1 Then Local $aProperty[35] For $i = 0 To 34 $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i) Next Return $aProperty Else $sProperty = $oDir.GetDetailsOf ($oFile, $iProp) If $sProperty = "" Then Return 0 Else Return $sProperty EndIf EndIf EndIf EndFunc ;==>_GetExtProperty Func _Resize() _GuiCtrlStatusBarResize($StatusBar) EndFunc ;==>_Resize Func _Exit() Exit EndFunc ;==>_Exit Func OnAutoItExit() If IsObj($oIE1) Then _IEQuit ($oIE1) If IsObj($oIE2) Then _IEQuit ($oIE2) EndFunc ;==>OnAutoItExitLyrics_Finder.rar 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