wontstoptalking
Joined: 14 Dec 2008 Posts: 42
|
Posted: Sat Dec 20, 2008 8:56 pm Post subject: Music Lyric Grabber |
|
|
Even more useful than you might think.
Partial credit goes to me (I really only came up with the idea and got half way there with it) but the most credit goes to the wonderful helpers at the AHK IRC chat, specifically Skwire, who came up with the final gui layout of the current version; and ahklerner1, who told me how to make sure the input isn't caps sensitive
Lyric Grabber grabs music lyrics from the Lyric Wiki site, displaying it in a simple manner.
| Code: | #NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
;;;;;;;;start code;;;;;;;;;
#persistent
#singleinstance
#NoTrayIcon
Gui, Margin, 10, 10
Gui, add, text , xm ym w30 h20 Right 0x200 , Artist:
Gui, add, edit , xm+35 ym w100 h20 vArtist ,
Gui, add, text , xm+140 ym w30 h20 Right 0x200 , Song:
Gui, add, edit , xm+175 ym w100 h20 vSong ,
Gui, add, button, xm+280 ym w50 h20 Default , Search
Gui, Add, Edit , xm ym+30 w330 h400 ReadOnly vLyrics_edt,
Gui, Add, Statusbar
SB_SetText( "Ready." )
; Gui, add, button, x90 y98, Cancel
Menu, FileMenu, Add, About, AboutFun
Menu, FileMenu, Add, Help, HelpFun
Menu, MenuBar, Add, Menu, :FileMenu
Menu, transmenu, Add, Low, Low
Menu, transmenu, Add, Medium, Medium
Menu, transmenu, Add, Full, Full
Menu, OptionsMenu, Add, Transparency, :transmenu
Menu, OptionsMenu, Add, Keep On Top, kot
Menu, MenuBar, Add, Options, :OptionsMenu
Gui, Menu, MenuBar
Gui, show, AutoSize Center, Lyric Grabber
Return
;;;;;;;;;;;;;;;;Button Actions;;;;;;;;;;;;;
AboutFun:
Msgbox, Made using AutoHotKey script
Return
HelpFun:
Msgbox, Song and artist titles MUST be capitilized and spelled properly or you will not achieve proper results. Otherwise, the problem is most likely because Lyricwiki.org does not have the song in archive.
Return
Low:
WinSet, Transparent, 100, Lyric Grabber
Menu, transmenu, check, Low
Menu, transmenu, Uncheck, Medium
Menu, transmenu, Uncheck, Full
Return
Medium:
Winset, Transparent, 200, Lyric Grabber
Menu, transmenu, check, Medium
Menu, transmenu, Uncheck, Low
Menu, transmenu, Uncheck, Full
Return
Full:
Winset, Transparent, Off, Lyric Grabber
Menu, transmenu, check, Full
Menu, transmenu, Uncheck, Medium
Menu, transmenu, Uncheck, Low
Return
kot:
Winset, AlwaysOnTop, Toggle
Menu, OptionsMenu, togglecheck, Keep On Top
Return
ButtonCancel:
exitapp
Return
GuiEscape:
GuiClose:
{
ExitApp
}
Return
ButtonSearch:
Gui, submit, NoHide
StringUpper, Artist, Artist,T
StringUpper, Song, Song,T
GuiControl, Text, Lyrics_edt
SB_SetText( "Searching..." )
Sleep, 50
UrlDownloadToFile, http://lyricwiki.org/%Artist%:%Song%, lyrics.html
FileRead, v_FileData, lyrics.html
FileDelete, lyrics.html
loop, parse, v_FileData, `n, `r
{
if A_LoopField contains <div class='lyricbox' >
{
Output:=A_LoopField
Break
}
}
Output:=Output " ENDEND"
RegExMatch(Output, "s)lyricbox' >(.+)ENDEND", Output)
Lyrics:=RegExReplace(Output1,"<br />" , "`n")
Lyrics2:=RegExReplace(Lyrics,"<i>" , "`n")
Lyrics3:=RegExReplace(Lyrics2,"</i>" , "`n")
SB_SetText( "Done." )
GuiControl, Text, Lyrics_edt, %Lyrics3% |
Thanks again to the wonderful people at the AHK IRC. |
|