Jump to content
Sign in to follow this  
magician13134

Lines through images and button color bugs..?

Recommended Posts

magician13134

Hi, I'm writing a program that has an image for a background, and other images overlayed on top of it. Some of those images have lines or misplaced pixels in them. I've tried both bmp and gif formats, I can't figure it out. Another thing is the border color around all my buttons is the bg color of my GUI, not the actual color behind the button, even though I have GUICtrlSetBKColor() set to transparent... I'll attach an image and the code.

Posted Image

#include <IE.au3>
#include <INet.au3>
#include <GUIConstants.au3>
#include <GUITab.au3>
#include <GUIListBox.au3>
#include <string.au3>
#include <misc.au3>
#include "image_get_info.au3"
#include "edit info.au3"

Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 1)

FileInstall("images\about.gif", @TempDir & "\about.gif", 1)
FileInstall("images\bg.gif", @TempDir & "\bg.gif", 1)
FileInstall("images\title.bmp", @TempDir & "\title.bmp", 1)
FileInstall("images\empty.bmp", @TempDir & "\empty.bmp", 1)
FileInstall("images\slider.bmp", @TempDir & "\slider.bmp", 1)
FileInstall("images\NoArt.bmp", @TempDir & "\NoArt.bmp", 1)
FileInstall("images\exit bright.bmp", @TempDir & "\exit bright.bmp", 1)
FileInstall("images\exit.bmp", @TempDir & "\exit.bmp", 1)
FileInstall("images\iexit.bmp", @TempDir & "\iexit.bmp", 1)
FileInstall("images\minimize.bmp", @TempDir & "\minimize.bmp", 1)
FileInstall("images\iminimize.bmp", @TempDir & "\iminimize.bmp", 1)
FileInstall("images\maximize.bmp", @TempDir & "\maximize.bmp", 1)
FileInstall("images\imaximize.bmp", @TempDir & "\imaximize.bmp", 1)
FileInstall("images\tabs2.gif", @TempDir & "\tabs2.gif", 1)
FileInstall("images\iTunesMode.bmp", @TempDir & "\iTunesMode.bmp", 1)
FileInstall("images\batchMode.bmp", @TempDir & "\batchMode.bmp", 1)
FileInstall("images\manualMode.bmp", @TempDir & "\manualMode.bmp", 1)

Dim $SysVolumeRead = 100, $ArtOrNot = 0, $TimeFormat = 0, $OldVolume, $iTunes, $color, $TrayMenuPause, $TrackOrTracks, $ArtLocation, $VolumeRead ; I should learn to Dim all vars... oh well, too late now...

; Create GUI, title bar stuff, and tray menu
$GUI = GUICreate("iDFree 2.2", 602, 559, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_POPUP, $WS_SYSMENU), -1) ; Creates GUI
$rgn = CreateRoundRectRgn(0, 0, 602, 559, 9, 9)
SetWindowRgn($GUI, $rgn)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
GUISetBkColor(0x6E6E6E)
GUICtrlCreatePic(@TempDir & "\bg.gif", -3, 10, 605, 515)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreatePic(@TempDir & "\title.bmp", 0, 0, 604, 14)
GUICtrlSetState(-1, $GUI_DISABLE)
$MoveRegion = GUICtrlCreateLabel("", 52, 0, 552, 19)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;GUICtrlSetOnEvent(-1, "move")
GUICtrlSetStyle(-1, -1, $GUI_WS_EX_PARENTDRAG)
$exit = GUICtrlCreatePic(@TempDir & "\exit.bmp", 5, 2, 0, 0)
GUICtrlSetOnEvent(-1, "ExitButton")
GUICtrlSetTip(-1, "Close iDFree")
$minimize = GUICtrlCreatePic(@TempDir & "\minimize.bmp", 22, 2, 0, 0)
GUICtrlSetOnEvent(-1, "MinimizeButton")
GUICtrlSetTip(-1, "Minimize iDFree")
$maximize = GUICtrlCreatePic(@TempDir & "\maximize.bmp", 39, 2, 0, 0)
GUICtrlSetTip(-1, "Maximize disabled")
$TrayMenuAbout = TrayCreateItem("About iDFree 2.2")
$TrayMenuHelp = TrayCreateItem("iDFree Help")
$TrayMenuSeperator1 = TrayCreateItem("")
$TrayMenuExit = TrayCreateItem("Exit")
GUICtrlCreateLabel("iDFree 2.2", 281, 4, 75, 17, $SS_CENTER)
GUICtrlSetFont(-1, -1, 800)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("iDFree 2.2", 280, 3, 75, 17, $SS_CENTER)
GUICtrlSetFont(-1, -1, 800)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

;$TabMask = GUICtrlCreatePic(@TempDir & "\tabs.bmp", 2, 530, 0, 0)                            ; Create the tabs overlay image
;GUICtrlSetState(-1, $GUI_DISABLE)                                                            ; Allow them to be clicked through
$tab = GUICtrlCreateTab(-200, -200, 1, 1, BitOr($WS_TABSTOP, $WS_CLIPSIBLINGS));, $TCS_BUTTONS)) ; Create the actual tabs (iTunes mode, batch, manual)

$message = GUICtrlCreateLabel("", 265, 536, 330, 17, 0x1001) ; The label at the bottom
GUICtrlSetOnEvent(-1, "GoToMSI") ; Open magicsoftinc.com when clicked
GUICtrlSetCursor (-1, 0) ; Set cursor over the label
GUICtrlSetBkColor(-1, 0x000000) ; Set label BK
$iTunesMode = GUICtrlCreateTabItem("iTunes Mode") ; iTunes (default) tab
    GUICtrlCreateGroup("Song information", 1, 19, 368, 230)
        $name = GUICtrlCreateLabel("Title:", 11, 40, 200, 16, $SS_SIMPLE)
        $artist = GUICtrlCreateLabel("Artist:", 11, 55, 200, 16, $SS_SIMPLE)
        $album = GUICtrlCreateLabel("Album:", 11, 70, 200, 16, $SS_SIMPLE)
        $PositionLabel = GUICtrlCreateLabel("", 5, 208, 50, 14)
        $TimeLabel = GUICtrlCreateLabel("", 337, 208, 35, 14)
        GUICtrlSetOnEvent(-1, "ChangeTimeFormat")
        GUICtrlCreatePic(@TempDir & "\empty.bmp", 5, 222, 360, 15)
        GUICtrlSetOnEvent(-1, "ChangePos")
        GUICtrlSetCursor(-1, 0)
        $position = GUICtrlCreatePic(@TempDir & "\slider.bmp", 5, 222, 1, 15)
        GUICtrlSetOnEvent(-1, "ChangePos")
        GUICtrlSetCursor(-1, 0)
        $AlbumArt = GUICtrlCreatePic("", 214, 43, 150, 150)
        GUICtrlSetCursor($AlbumArt, 0)
        GUICtrlSetOnEvent(-1, "DisplayArt")
        $ArtMenu = GUICtrlCreateContextMenu($AlbumArt)
            $ArtSave = GUICtrlCreateMenuitem("Save", $ArtMenu)
            GUICtrlSetOnEvent($ArtSave, "SaveArt")
            GUICtrlCreateMenuitem("", $ArtMenu)
            $ArtLoad = GUICtrlCreateMenuitem("Load", $ArtMenu)
            GUICtrlSetOnEvent($ArtLoad, "LoadArt")

    GUICtrlCreateGroup("Online lyrics", 374, 138, 166, 111)
        $GetLyrics = GUICtrlCreateButton("Get Lyrics", 379, 158, 75, 25)
        GUICtrlSetOnEvent(-1, "_GetLyrics")
        $ChooseSite = GUICtrlCreateCombo("LyricsOnDemand.com", 379, 188, 157, -1, 0x0003)
        GUICtrlSetData(-1, "AZLyrics.com")
        $SetLyrics = GUICtrlCreateButton("Apply New Lyrics", 379, 215, 95, 25)
        GUICtrlSetOnEvent(-1, "SetLyrics")
    
    GUICtrlCreateGroup("Help", 543, 138, 55, 111)
        $InfoButton = GUICtrlCreateButton("i", 560, 168, 22, 20)
        GUICtrlSetFont(-1, -1, 650)
        GUICtrlSetOnEvent(-1, "about")
        $Helpbutton = GUICtrlCreateButton("?", 560, 203, 22, 20)
        GUICtrlSetFont(-1, -1, 650)
        GUICtrlSetOnEvent(-1, "help")
        
    GUICtrlCreateGroup("iTunes control", 374, 19, 224, 115)
        $PrevTrack = GUICtrlCreateButton("9", 379, 38, 17, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_PrevTrack")
        $NextTrack = GUICtrlCreateButton(":", 397, 38, 17, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_NextTrack")
        $PlayPause = GUICtrlCreateButton("4;", 415, 38, 30, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_PlayPause")
        $stop = GUICtrlCreateButton("<", 446, 38, 17, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_Stop")
        $mute = GUICtrlCreateButton("X", 465, 38, 17, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_mute")
        ;$volume = GUICtrlCreateSlider(485, 38, 110, 20)
        ;GUICtrlSetBkColor(-1, 0xFF0000)
        ;GUICtrlSetLimit(-1, 100, 0)
        GUICtrlCreateLabel("iTunes volume:", 485, 40, 120, 17)
        GUICtrlCreatePic(@TempDir & "\empty.bmp", 485, 54, 110, 16) ; iTunes volume
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetOnEvent(-1, "_volume")
        $volume = GUICtrlCreatePic(@TempDir & "\slider.bmp", 485, 31, 0, 16)
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetOnEvent(-1, "_volume")
        GUICtrlCreateLabel("System volume:", 485, 75, 120, 17)
        GUICtrlCreatePic(@TempDir & "\empty.bmp", 485, 89, 110, 16) ; System Volume
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetOnEvent(-1, "_SysVolume")
        $SysVolume = GUICtrlCreatePic(@TempDir & "\slider.bmp", 485, 31, 0, 16)
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetOnEvent(-1, "_SysVolume")
        $EditInfoButton = GUICtrlCreateButton("Edit track info", 379, 68, 103)
        GUICtrlSetOnEvent(-1, "EditInfo")
        $iBoostButton = GUICtrlCreateButton("iBoost", 379, 99, 103)
        GUICtrlSetOnEvent(-1, "iBoost")
        
    ; Should be a group here, but I ran out of space :o
    GUICtrlCreateLabel("Current Lyrics:", 1, 253)
    $LyricsEdit = GUICtrlCreateEdit("", 1, 268, 289, 258, BitOr($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY))
    GUIctrlSetBkColor(-1, 0xAAAAAA)
    #cs ; Huh! You can't make a context menu on an edit! WTF?!
    $LyricsEditContext = GUICtrlCreateContextMenu($LyricsEdit)
    $LyricsEditContextCopy = GUICtrlCreateMenuitem("Copy to clipboard", $LyricsEditContext)
    $LyricsEditContextEdit = GUICtrlCreateMenuitem("Edit lyrics", $LyricsEditContext)
    GUICtrlSetOnEvent(-1, "copy")
    #ce
    GUICtrlCreateLabel("New Lyrics:", 306, 253)
    $NewLyricsEdit = GUICtrlCreateEdit("", 306, 268, 292, 258)
    $copy = GUICtrlCreateButton(">", 293, 378, 12)
    GUICtrlSetOnEvent(-1, "copy")
$BatchMode = GUICtrlCreateTabItem("Batch Mode") ; Batch Mode tab
    $reminder = GUICtrlCreateLabel("Choose a playlist or source:", 2, 19, 250, 16) 
    $ChoosePlaylist = GUICtrlCreateList("", 0, 34, 199, 280, BitOr($WS_BORDER, $WS_VSCROLL))
    GUICtrlSetOnEvent(-1, "UpdateMessage")
    If ProcessExists("itunes.exe") Then
        $iTunes = ObjCreate("iTunes.application") ; Create iTunes COM connection
        If IsObj($iTunes) Then ; If iTunes is up and running
            $sources = $iTunes.Sources
            For $i in $sources ; List all sources/playlists into the listview
                GUICtrlSetData(-1, $i.Name & "|")
                $playlists = $i.Playlists
                For $j in $playlists
                    If $j.name <> $i.name Then GUICtrlSetData(-1, "     " & $j.Name & "|")
                Next
            Next
        EndIf
    EndIf
    $SkipSongsWithLyrics = GUICtrlCreateCheckbox("Skip songs with lyrics", 2, 313) 
    GUICtrlSetState(-1, $GUI_CHECKED)
    $ArtistsToExclude = GUICtrlCreateInput("", 1, 343, 199)
    GUICtrlCreateLabel("Enter artists to exclude, seperated with a |", 1, 368)
    GUICtrlCreateLabel("IE 'band1|band2|band3'", 1, 383)
    $BatchApply = GUICtrlCreateButton("Get Lyrics", 2, 403, 90, 30)
    GUICtrlSetOnEvent(-1, "BatchApply")
    $SaveLog = GUICtrlCreateButton("Save Log", 100, 403, 90, 30)
    GUICtrlSetOnEvent(-1, "SaveLog")
    $BatchSave = GUICtrlCreateCombo("Apply to song", 1, 468, 210, -1, 0x0003)
    GUICtrlSetData(-1, "Save lyrics to file|Do both")
    $BatchChooseSite = GUICtrlCreateCombo("LyricsOnDemand.com", 1, 443, 157, -1, 0x0003)
    GUICtrlSetData(-1, "AZLyrics.com|Local files")
    GUICtrlCreateLabel("Status:", 220, 19, 100, 16)
    $BatchStatus = GUICtrlCreateEdit("", 220, 35, 379, 484, BitOr($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY))
    GUICtrlSetBkColor(-1, 0x00FFFFFF)
$ManualMode = GUICtrlCreateTabItem("Manual Mode") ; Manual Mode tab
    GUICtrlCreateLabel("Artist:", 1, 28, 100, 20)
    $ArtistEdit = GUICtrlCreateInput("", 1, 43, 375, 20)
    GUICtrlCreateLabel("Track Name:", 1, 78, 100, 20)
    $TrackEdit = GUICtrlCreateInput("", 1, 93, 375, 20)
    GUICtrlCreateGroup("Online lyrics", 400, 24, 198, 110)
        $GetLyrics = GUICtrlCreateButton("Get Lyrics", 405, 43, 75, 25)
        GUICtrlSetOnEvent(-1, "_GetLyrics")
        $ManualChooseSite = GUICtrlCreateCombo("AZLyrics.com", 405, 73, 157, -1, 0x0003)
        GUICtrlSetData(-1, "LyricsDir.com (beta)|LyricsOnDemand.com")
        $SaveLyrics = GUICtrlCreateButton("Save Lyrics", 405, 100, 95, 25)
        GUICtrlSetOnEvent(-1, "save")
        GUICtrlCreateLabel("Lyrics:", 1, 128)
        $ManualLyricsEdit = GUICtrlCreateEdit("", 1, 143, 598, 384)
GUICtrlCreateTabItem("")

$iTunesButton = GUICtrlCreatePic(@TempDir & "\iTunesMode.bmp", 4, 530, 81, 25)
    GUICtrlSetOnEvent(-1, "switchToiTunesMode")
$batchButton = GUICtrlCreatePic(@TempDir & "\batchMode.bmp", 91, 530, 77, 25)
    GUICtrlSetOnEvent(-1, "switchToBatchMode")
$manualButton = GUICtrlCreatePic(@TempDir & "\manualMode.bmp", 172, 530, 82, 25)
    GUICtrlSetOnEvent(-1, "switchToManualMode")

;This will help trap and troubleshoot errors
_IEErrorHandlerRegister()
If Not ProcessExists("itunes.exe") Then
    $iTunes = ""
    GUICtrlSetData($message, " Please reopen iDFree once iTunes is open for best functionality.")
    GUICtrlSetColor($message, 0xFF0000)
Else
    $iTunes = ObjCreate("iTunes.application")
    ;GUICtrlSetData($message, " iDFree by Ben Perkins of Magic Soft Inc. - www.magicsoftinc.com")
    GUICtrlSetData($message, " iDFree now has a new GUI, hope you like it!   -The Magician")
    GUICtrlSetColor($message, 0x2255FF)
    AdlibEnable("adlib", 1000)
EndIf
If Not IsObj($iTunes) Then
    _GUICtrlTab_SetCurFocus($tab, $ManualMode)
Else
    $OldVolume = $iTunes.SoundVolume
    GUICtrlSetData($volume, $OldVolume)
    $NowPlaying = $iTunes.CurrentTrack
    $iTunesEvent = ObjEvent($iTunes, "_Event_")
    ;If the object didn't create you don't want to enable the adlib
    AdlibEnable("adlib", 1000)
    adlib()
EndIf
GUISetState()

While 1
    If Not ProcessExists("itunes.exe") Then
        $iTunes = ""
    Else
        $iTunes = ObjCreate("iTunes.application")
    EndIf
    $msg = TrayGetMsg()
    If $msg = $TrayMenuAbout Then about()
    If $msg = $TrayMenuHelp Then help()
    If $msg = $TrayMenuExit Then _exit()
    sleep(50)
WEnd

Func switchToiTunesMode()
    _GUICtrlTab_SetCurFocus($tab, 0)
EndFunc

Func switchToBatchMode()
    _GUICtrlTab_SetCurFocus($tab, 1)
EndFunc

Func switchToManualMode()
    _GUICtrlTab_SetCurFocus($tab, 2)
EndFunc

Func UpdateMessage()
    $OldMessage = GUICtrlRead($message)
    $iTunes = ObjCreate("iTunes.application")
    $playlist = $iTunes.LibraryPlaylist
    $ChoosenPlaylist = GUICtrlRead($ChoosePlaylist)
    If $ChoosenPlaylist = "" Then Return
    $sources = $iTunes.sources
    $tracks = ""
    for $i in $sources
        If $i.name = $ChoosenPlaylist Then
            For $j in $i.playlists
                If $j.name = $i.name Then
                    $tracks = $j.tracks
                    $playlist = $j
                EndIf
            Next
        Else
            $subsource = $i.playlists
            for $j in $subsource
                If "     " & $j.name = $ChoosenPlaylist Then
                    $tracks = $j.tracks
                    $playlist = $j
                EndIf
            Next
        EndIf
    Next
    If Not IsObj($tracks) Then Return
    If $tracks.count = 1 Then
        $TrackOrTracks = " track in "
    Else
        $TrackOrTracks = " tracks in "
    EndIf
    GUICtrlSetData($message, " " & $tracks.count & $TrackOrTracks & $playlist.name)
    If $tracks.count > 700 Then
        $color = 0x00FF0000
    ElseIf $tracks.count < 100 Then
        $color = 0x0000FF00
    Else
        $color = 0x00FFFF00
    EndIf
    GUICtrlSetColor($message, $color)
EndFunc

Func _PrevTrack()
    $iTunes.BackTrack
EndFunc   ;==>_PrevTrack

Func _NextTrack()
    $iTunes.NextTrack
EndFunc   ;==>_NextTrack

Func _PlayPause()
    $iTunes.PlayPause
EndFunc   ;==>_PlayPause

Func _Stop()
    $iTunes.stop
EndFunc   ;==>_Stop

Func _mute()
    If IsObj($iTunes) Then
        If $iTunes.SoundVolume = 0 Then
            $iTunes.SoundVolume = $VolumeRead
        Else
            $VolumeRead = $iTunes.SoundVolume
            $iTunes.SoundVolume = 0
        EndIf
        ControlMove("iDFree", "", $volume, 485, 39, $iTunes.SoundVolume*1.1)
    Else
        If $VolumeRead = 0 Then
            $VolumeRead = 100
            SoundSetWaveVolume(100)
        Else
            $VolumeRead = 0
            SoundSetWaveVolume(0)
        EndIf
    EndIf
EndFunc

Func _volume()
    $win = WinGetPos("iDFree")
    $mouse = MouseGetPos()
    $VolumeRead = $win[0] + 485 + 110 - $mouse[0]
    $VolumeRead = Int(100 - $VolumeRead / 1.1)
    If $VolumeRead >= 98 Then $VolumeRead = 100
    If IsObj($iTunes) Then
        $iTunes.SoundVolume = $VolumeRead;GUICtrlRead($volume)
        ControlMove("iDFree", "", $volume, 485, 54, $iTunes.SoundVolume*1.1)
    Else
        ;SoundSetWaveVolume($VolumeRead)
        ControlMove("iDFree", "", $volume, 485, 89, $VolumeRead)
    EndIf
EndFunc

Func _SysVolume()
    $win = WinGetPos("iDFree")
    $mouse = MouseGetPos()
    $SysVolumeRead = $win[0] + 485 + 110 - $mouse[0]
    $SysVolumeRead = Int(100 - $SysVolumeRead / 1.1)
    If $SysVolumeRead >= 98 Then $SysVolumeRead = 100
    SoundSetWaveVolume($SysVolumeRead)
    ControlMove("iDFree", "", $SysVolume, 485, 89, $SysVolumeRead*1.1)
EndFunc

Func CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

Func _Event_OnCOMCallsDisabledEvent() ; When iTunes stops using COM
    AdlibDisable() ; Shut off everything that uses iTunes to avoid errors
    MsgBox(0x40030, "Error in communication!", "iTunes has disabled communication, you may have" & _ ; Display a message box stating the error
                @CR & "the 'Get info' window open, or be trying to close iTunes.")
EndFunc

Func _Event_OnCOMCallsEnabledEvent() ; When iTunes resumes COM usage
    AdlibEnable("adlib", 1000) ; Resume iTunes events
EndFunc

Func adlib() ; This function is called once a second
    $NowPlaying = $iTunes.CurrentTrack
    ; This will avoid errors when there is not a current track
    If Not IsObj($NowPlaying) Then Return ; If there is no track then don't continue
    $TrackName = $NowPlaying.name ; Get name
    $TrackArtist = $NowPlaying.artist ; artist
    $TrackAlbum = $NowPlaying.album ; and album
    ControlMove("iDFree", "", $volume, 485, 54, $iTunes.SoundVolume*1.1) ; Adjust volume slider..? Dunno why... it's been awhile since I've worked on this
    ControlMove("iDFree", "", $SysVolume, 485, 89, $SysVolumeRead*1.1) ; Ditto
    ; Grab track time/position
    $SongLength = $NowPlaying.time
    $CurrentTime = $iTunes.PlayerPosition
    $minute = int($CurrentTime/60) ; Minutes
    $second = mod($CurrentTime, 60) ; Mod gives a remainder, that's our seconds
    $SplitSecond = StringSplit($second, "") ; Split up the seconds to determine length
    If $SplitSecond[0] = 1 Then $second = "0" & $second ; if it's one digit, add a 0 (1 = 01, 2 = 02)
    $time = $minute & ":" & $second ; Put the time into a readable form
    $length = StringSplit($SongLength, ":") ; Split it up again to get song length... wow that was pointless, I'll make it more efficient... later
    $length = 60*$length[1]+$length[2]
    $Time2 = $length - $CurrentTime
    $minute = int($Time2/60)
    $second = mod($Time2, 60)
    $SplitSecond = StringSplit($second, "")
    If $SplitSecond[0] = 1 Then $second = "0" & $second
    $Time2 = "-" & $minute & ":" & $second
    ; Format track time/position
    If _GUICtrlTab_GetCurSel($tab) = 0 Then GUICtrlSetData($PositionLabel, $time)
    If $TimeFormat = 1 and _GUICtrlTab_GetCurSel($tab) = 0 Then GUICtrlSetData($TimeLabel, " " & $SongLength)
    If $TimeFormat <> 1 and _GUICtrlTab_GetCurSel($tab) = 0 Then GUICtrlSetData($TimeLabel, $Time2)
    $CurrentTime = $CurrentTime/($length/360)
    ;GUICtrlSetData($position, $CurrentTime)
    ControlMove("iDFree 2.2", "", $position, 5, 222, $CurrentTime, 15)
    If "Artist: " & $TrackArtist <> GUICtrlRead($artist) Then GUICtrlSetData($artist, "Artist: " & $TrackArtist)
    If "Album: " & $TrackAlbum <> GUICtrlRead($album) or "Title: " & $TrackName <> GUICtrlRead($name)  Then
        GUICtrlSetData($album, "Album: " & $TrackAlbum)
        If "Title: " & $TrackName <> GUICtrlRead($name) Then GUICtrlSetData($name, "Title: " & $TrackName)
        art()
    EndIf
    If "Title: " & $TrackName <> GUICtrlRead($name) Then GUICtrlSetData($name, "Title: " & $TrackName)
    $NowPlaying = $iTunes.CurrentTrack
    If GUICtrlRead($LyricsEdit) <> $NowPlaying.Lyrics Then GUICtrlSetData($LyricsEdit, $NowPlaying.Lyrics)
EndFunc

Func ChangeTimeFormat() ; Display track length or time remaining (I forget which is which)
    If $TimeFormat = 1 Then
        $TimeFormat = 0
    Else
        $TimeFormat = 1
    EndIf
    adlib()
EndFunc

Func ChangePos() ; If the slider is clicked, then adjust the song's timing
    $mouse = MouseGetPos() ; Get the mouse position
    $win = WinGetPos("iDFree 2.2") ; And window position
    $mouse[0]-=$win[0]+7 ; Do some fancy calculations to find where the mouse is
    $mouse[0] = $mouse[0] / 360 ; relative to the slider
    $SongLength = $NowPlaying.time ; Now calculate the time it needs to go to
    $length = StringSplit($SongLength, ":")
    $length = 60*$length[1]+$length[2]
    $pos = Round($length * $mouse[0])
    $iTunes.PlayerPosition = $pos ; Apply the time
    adlib() ; Update stats
EndFunc

Func copy()
    If GUICtrlRead($LyricsEdit) <> "" Then GUICtrlSetData($NewLyricsEdit, GUICtrlRead($LyricsEdit)) ; Apply updated lyrics
EndFunc

Func art() ; display current art
    GUICtrlSetTip($exit, "Close iDFree")
    GUICtrlSetTip($minimize, "Minimize iDFree")
    GUICtrlSetTip($maximize, "Maximize disabled")
    $window = WinGetPos("iDFree 2.2")
    $iTunes = ObjCreate("iTunes.application")
    If IsObj($iTunes) Then
        $NowPlaying = $iTunes.CurrentTrack
        $artwork = $NowPlaying.Artwork
        $lyrics = $NowPlaying.lyrics
        If $lyrics = 0 Then $lyrics = ""
        GUICtrlSetData($LyricsEdit, $lyrics)
        $count = 0
        For $art In $artwork
            If $art.format = 1 Then
                $art.SaveArtworkToFile(@TempDir & "\CurrentArt.jpg")
            ElseIf $art.format = 2 Then
                $art.SaveArtworkToFile(@TempDir & "\CurrentArt.png")
            EndIf
            $count+=1
        Next
        If $count <> 0 and $art.format = 1 Then ; If JPG art exists
            $ArtLocation = @TempDir & "\CurrentArt.jpg"
            GUICtrlSetCursor($AlbumArt, 0)
            GUICtrlSetOnEvent($AlbumArt, "DisplayArt")
            GUICtrlSetState($ArtLoad, $GUI_DISABLE)
            GUICtrlSetState($ArtSave, $GUI_ENABLE)
        ElseIf $count <> 0 and $art.format = 2000 Then ; If PNG art exists, doesn't work
            $ArtLocation = @TempDir & "\CurrentArt.png"
            GUICtrlSetCursor($AlbumArt, 0)
            GUICtrlSetOnEvent($AlbumArt, "DisplayArt")
        Else ; No art
            $ArtLocation = @TempDir & "\NoArt.bmp"
            GUICtrlSetCursor($AlbumArt, 2)
            GUICtrlSetOnEvent($AlbumArt, "")
            GUICtrlSetState($ArtSave, $GUI_DISABLE)
            GUICtrlSetState($ArtLoad, $GUI_ENABLE)
        EndIf
        GUICtrlSetImage($AlbumArt, $ArtLocation)
        GUICtrlSetTip($name, $NowPlaying.name)
        GUICtrlSetTip($artist, $NowPlaying.artist)
        GUICtrlSetTip($album, $NowPlaying.album)
    EndIf
    If IsArray($window) Then WinMove("iDFree 2.2", "", $window[0], $window[1], $window[2], $window[3]) ; Used to fix a RARE bug
                                                                                                ; Correction, this bug was TERMINATED!
EndFunc

Func DisplayArt() ; Create a GUI for the album art
    If $ArtLocation <> @TempDir & "\CurrentArt.jpg" Then Return 0
    $NowPlaying = $iTunes.CurrentTrack
    $TrackName = $NowPlaying.name
    $TrackAlbum = $NowPlaying.album
    $size = 1.5
    $ArtInfo = _ImageGetInfo(@TempDir & "\CurrentArt.jpg")
    $width = _ImageGetParam($ArtInfo, "Width")
    $height =  _ImageGetParam($ArtInfo, "Height")
    While $width >= @DesktopWidth or $height >= @DesktopHeight
        $width/=2
        $height/=2
    WEnd
    Opt("GUIEventOptions", 1)
    Opt("GUIOnEventMode", 0)
    Opt("GUIResizeMode", 102)
    If not Int($width) > 100 Then $width = 100 
    If not Int($height) > 100 Then $height = 100 
    $ArtGUI = GUICreate($TrackName & " (" & $TrackAlbum & ")", $width*1.5+5, $height*1.5+23, 10, 10, $WS_POPUP, -1)
    $rgn = CreateRoundRectRgn(0, 0, $width*1.5+4, $height*1.5+40, 9, 9)
    SetWindowRgn($ArtGUI, $rgn)
    GUISetBkColor(0xBBBBBB)
    GUICtrlCreatePic(@TempDir & "\title.bmp", 0, 0, $width*1.5+4, 18)
    GUICtrlSetResizing(-1, 768)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("'" & $TrackName & "'", 55, 4, $width*1.5-60, 17, $SS_CENTER)
    GUICtrlSetFont(-1, -1, 800)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateLabel("'" & $TrackName & "'", 54, 3, $width*1.5-60, 17, $SS_CENTER)
    GUICtrlSetFont(-1, -1, 800)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $ArtExit = GUICtrlCreatePic(@TempDir & "\exit.bmp", 5, 2, 0, 0)
    GUICtrlSetResizing(-1,544)
    $ArtMinimize = GUICtrlCreatePic(@TempDir & "\minimize.bmp", 22, 2, 0, 0)
    GUICtrlSetResizing(-1, 102)
    $ArtMaximize = GUICtrlCreatePic(@TempDir & "\maximize.bmp", 39, 2, 0, 0)
    GUICtrlSetResizing(-1, 102)
    GUICtrlCreatePic(@TempDir & "\CurrentArt.jpg", 2, 20, $width*1.5, $height*1.5)
    GUICtrlSetResizing(-1, 102)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        $tMsg = TrayGetMsg()
        If $msg = $ArtExit Then ExitLoop
        If $msg = $ArtMinimize Then GUISetState(@SW_MINIMIZE)
        If $msg = $GUI_EVENT_MINIMIZE Then GUISetState(@SW_MINIMIZE)
        If $msg = $GUI_EVENT_RESTORE Then GUISetState(@SW_RESTORE)
        if $tMsg = $TrayMenuExit Then _exit()
        ;If $msg = $ArtMaximize Then
        ;   If $size = 1 Then
        ;       $size = 1.5
        ;       WinMove($TrackName & " (" & $TrackAlbum & ")", "", Default, Default, $width*1.5+4, $height*1.5+25)
        ;   Else
        ;       $size = 1
        ;       WinMove($TrackName & " (" & $TrackAlbum & ")", "", Default, Default, $width+4, $height+25)
        ;   EndIf
        ;EndIf
    WEnd
    GUIDelete()
    Opt("GUIEventOptions", 0)
    Opt("GUIOnEventMode", 1)
    Opt("GUIResizeMode", 0)
EndFunc

Func SetLyrics()
    If IsObj($iTunes) Then
        If GUICtrlRead($NewLyricsEdit) = "" or GUICtrlRead($NewLyricsEdit) = "Could not find lyrics" or GUICtrlRead($NewLyricsEdit) = "Could not connect" Then
            If MsgBox(36, "No lyrics entered!", "Remove lyrics?") = 6 Then
                $CurrentTrack = $iTunes.CurrentTrack
                $CurrentTrack.lyrics = ""
                GUICtrlSetData($LyricsEdit, "")
            EndIf
        Else
            $CurrentTrack = $iTunes.CurrentTrack
            $CurrentTrack.lyrics = GUICtrlRead($NewLyricsEdit) & @CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
            MsgBox(0, "Success!", "Lyrics have been successfully changed!")
        EndIf
    EndIf
EndFunc   ;==>SetLyrics

Func AZGetLyrics($artist, $song, $edit)
    $URLName = StringReplace(StringLower($song), " ", "")
    $URLArtist = StringReplace(StringLower($artist), " ", "")
    $URLName = StringReplace($URLName, "'", "")
    $URLName = StringReplace($URLName, "/", "")
    $URLName = StringReplace($URLName, ",", "")
    $URLName = StringReplace($URLName, ".", "")
    $URLName = StringReplace($URLName, "-", "")
    $URLName = StringReplace($URLName, "#", "")
    $URLName = StringReplace($URLName, '"', "")
    $URL = "http://www.azlyrics.com/lyrics/" & $URLArtist & "/" & $URLName & ".html"
    $lyrics = _INetGetSource($URL)
    If Not @error Then
        If StringInStr($lyrics, "<TITLE>A-Z Lyrics Universe</TITLE>") Then
            GUICtrlSetData($edit, "Could not find lyrics")
        Else
            $lyrics = StringSplit($lyrics, "<FONT size=2>", 1)
            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
            $lyrics = StringSplit($lyrics, "[", 1)
            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
            $lyrics = StringReplace($lyrics, "<br>", @CRLF)
            $lyrics = StringReplace($lyrics, @LF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF, @LF)
            $lyrics = StringReplace($lyrics, 'h1', "")
            $lyrics = StringReplace($lyrics, '/', "")
            $lyrics = StringReplace($lyrics, '\', "")
            $lyrics = StringReplace($lyrics, "<br>", "")
            $lyrics = StringReplace($lyrics, "<br/>", "")
            $lyrics = StringReplace($lyrics, "<br\>", "")
            $lyrics = StringReplace($lyrics, "<br \>", "")
            $lyrics = StringReplace($lyrics, "<br />", "")
            $lyrics = StringReplace($lyrics, "&quot;", "")
            $lyrics = StringReplace($lyrics, "<i>", "")
            $lyrics = StringReplace($lyrics, "</i>", "")
            $lyrics = StringReplace($lyrics, "<b>", "")
            $lyrics = StringReplace($lyrics, "</b>", "")
            $lyrics = StringReplace($lyrics, "<u>", "")
            $lyrics = StringReplace($lyrics, "</u>", "")
            $lyrics = StringReplace($lyrics, '">', "")
            $lyrics = StringReplace($lyrics, '>', "")
            $lyrics = StringReplace($lyrics, '<"', "")
            $lyrics = StringReplace($lyrics, '<', "")
            $lyrics = StringStripWS($lyrics, 3)
            $lyrics&=@CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
            GUICtrlSetData($edit, $lyrics)
        EndIf
    Else
        GUICtrlSetData($edit, "Could not connect")
    EndIf
EndFunc   ;==>AZGetLyrics

Func LyricsDirLyrics($artist, $song, $edit)
    ;http://www.lyricsdir.com/streetlight-manifesto-as-the-footsteps-die-out-forever-lyrics.html
    $URLName = StringReplace(stringlower($song), " ", "-")
    $URLArtist = StringReplace(stringlower($artist), " ", "-")
    $URLName = StringReplace($URLName, "'", "")
    $URLName = StringReplace($URLName, "/", "")
    $URLName = StringReplace($URLName, ",", "")
    $URLName = StringReplace($URLName, ".", "")
    $URLName = StringReplace($URLName, "#", "")
    $URLName = StringReplace($URLName, '"', "")
    $URLName = StringReplace($URLName, '!', "")
    $URLName = StringReplace($URLName, '?', "")
    $URLName = StringReplace($URLName, '-', "")
    $URLName = StringReplace($URLName, '.', "")
    $URL = "http://www.lyricsdir.com/" & $URLArtist & "-" & $URLName & ".html"
    MsgBox(0, "", $URL)
    $lyrics = _INetGetSource($URL)
    If Not @error Then
        If StringInStr($lyrics, "http://www.lyricsdir.com/img/lyricsdir.gif") Then
            GUICtrlSetData($edit, "Could not find lyrics")
        Else
            $lyrics = StringSplit($lyrics, '<div id="lyrics', 1)
            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
            $lyrics = StringSplit($lyrics, "</div>", 1)
            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
            $lyrics = StringReplace($lyrics, "<br>", @CRLF)
            $lyrics = StringReplace($lyrics, @LF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF, @LF)
            $lyrics = StringReplace($lyrics, 'h1', "")
            $lyrics = StringReplace($lyrics, ' /', "")
            $lyrics = StringReplace($lyrics, ' \', "")
            $lyrics = StringReplace($lyrics, "<br>", "")
            $lyrics = StringReplace($lyrics, "<br/>", "")
            $lyrics = StringReplace($lyrics, "<br\>", "")
            $lyrics = StringReplace($lyrics, "<\ br>", "")
            $lyrics = StringReplace($lyrics, "<br \>", "")
            $lyrics = StringReplace($lyrics, "</ br>", "")
            $lyrics = StringReplace($lyrics, "<br />", "")
            $lyrics = StringReplace($lyrics, "&quot;", "")
            $lyrics = StringReplace($lyrics, "<i>", "")
            $lyrics = StringReplace($lyrics, "</i>", "")
            $lyrics = StringReplace($lyrics, "<b>", "")
            $lyrics = StringReplace($lyrics, "</b>", "")
            $lyrics = StringReplace($lyrics, "<u>", "")
            $lyrics = StringReplace($lyrics, "</u>", "")
            $lyrics = StringReplace($lyrics, '">', "")
            $lyrics = StringReplace($lyrics, '>', "")
            $lyrics = StringReplace($lyrics, '<"', "")
            $lyrics = StringReplace($lyrics, '<', "")
            $lyrics = StringStripWS($lyrics, 3)
            $lyrics&=@CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
            GUICtrlSetData($edit, $lyrics)
        EndIf
    Else
        GUICtrlSetData($edit, "Could not connect")
    EndIf
EndFunc   ;==>LyricsDirLyrics

Func ODGetLyrics($artist, $song, $edit)
    $URLName = StringReplace(StringLower($song), " ", "")
    $URLArtist = StringReplace(StringLower($artist), " ", "")
    $URLName = StringReplace($URLName, "'", "")
    $URLName = StringReplace($URLName, "/", "")
    $URLName = StringReplace($URLName, ",", "")
    $URLName = StringReplace($URLName, ".", "")
    $URLName = StringReplace($URLName, "-", "")
    $URLName = StringReplace($URLName, "#", "")
    $URLName = StringReplace($URLName, '"', "")
    $URLName = StringReplace($URLName, '?', "")
    $URLName = StringReplace($URLName, '!', "")
    $URLName&="lyrics"
    $URLArtist&="lyrics"
    $SplitArtist = StringSplit($URLArtist, "")
    $URL = "http://www.lyricsondemand.com/" & $SplitArtist[1] & "/" & $URLArtist & "/" & $URLName & ".html"
    $lyrics = _INetGetSource($URL)
    If Not @error Then
        If StringInStr($lyrics, "File Not Found") Then
            GUICtrlSetData($edit, "Could not find lyrics")
        Else
            $lyrics = StringSplit($lyrics, '<font size="2" face="Verdana">', 1)
            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
            $lyrics = StringSplit($lyrics, "&nbsp;", 1)
            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
            $lyrics = StringSplit($lyrics, "<script language", 1)
            If IsArray($lyrics) Then $lyrics = $lyrics[1]
            $lyrics = StringReplace($lyrics, "<br>", @CRLF)
            $lyrics = StringReplace($lyrics, @LF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF, @LF)            
            $lyrics = StringReplace($lyrics, 'h1', "")
            $lyrics = StringReplace($lyrics, '/', "")
            $lyrics = StringReplace($lyrics, '\', "")
            $lyrics = StringReplace($lyrics, "<p>", "")
            $lyrics = StringReplace($lyrics, "<P/>", "")
            $lyrics = StringReplace($lyrics, "<P\>", "")
            $lyrics = StringReplace($lyrics, "<P \>", "")
            $lyrics = StringReplace($lyrics, "<P />", "")
            $lyrics = StringReplace($lyrics, "<br>", "")
            $lyrics = StringReplace($lyrics, "<br/>", "")
            $lyrics = StringReplace($lyrics, "<br\>", "")
            $lyrics = StringReplace($lyrics, "<br \>", "")
            $lyrics = StringReplace($lyrics, "<br />", "")
            $lyrics = StringReplace($lyrics, "&quot;", "")
            $lyrics = StringReplace($lyrics, "<i>", "")
            $lyrics = StringReplace($lyrics, "</i>", "")
            $lyrics = StringReplace($lyrics, "<b>", "")
            $lyrics = StringReplace($lyrics, "</b>", "")
            $lyrics = StringReplace($lyrics, "<u>", "")
            $lyrics = StringReplace($lyrics, "</u>", "")
            $lyrics = StringReplace($lyrics, '">', "")
            $lyrics = StringReplace($lyrics, '>', "")
            $lyrics = StringReplace($lyrics, '<"', "")
            $lyrics = StringReplace($lyrics, '<', "")
            $lyrics = StringStripWS($lyrics, 3)
            GUICtrlSetData($edit, $lyrics)
            If StringStripWS(GUICtrlRead($edit), 3) == "" Then GUICtrlSetData($edit, "Could not find lyrics")
        EndIf
    Else
        GUICtrlSetData($edit, "Could not connect")
    EndIf
EndFunc   ;==>ODGetLyrics

Func SaveLog()
    If GUICtrlRead($BatchStatus) <> "" Then FileWrite(FileSaveDialog("Save your log file", @DesktopDir, "Text files (*.txt)|All files (*.*)", 16), GUICtrlRead($BatchStatus))
EndFunc

Func BatchApply() ; Handles batch apply
    $folder = ""
    GUICtrlSetData($BatchStatus, "")
    If GUICtrlRead($BatchSave) = "Apply to song" Then
        $mode = 0
    ElseIf GUICtrlRead($BatchSave) = "Save lyrics to file" Then
        $mode = 1
    Else 
        $mode = 2
    EndIf
    If $mode <> 0 Then
        $folder = FileSelectFolder("A 'lyrics' folder should be made in which directory?", @DesktopDir, 7, @MyDocumentsDir & "\My Music")
        If Not FileExists($folder & "\lyrics\") Then
            DirCreate($folder & "\lyrics\")
            GUICtrlSetData($BatchStatus, "Creating folder 'lyrics'" & @CRLF)
            sleep(250)
        EndIf
    EndIf
    $ExcludeArtists = GUICtrlRead($ArtistsToExclude)
    If $ExcludeArtists <> "" Then
        $ExcludeArtists = StringSplit($ExcludeArtists, "|")
        If IsArray($ExcludeArtists) Then
            For $i = 1 to $ExcludeArtists[0]
                $ExcludeArtists[$i] = StringStripWS($ExcludeArtists[$i], 1)
            Next
            $ShouldExcludeArtists = 1
        Else
            $ExcludeArtists[0] = 1
            $ExcludeArtists[1] = GUICtrlRead($ArtistsToExclude)
            $ShouldExcludeArtists = 1
        EndIf
    Else
        $ShouldExcludeArtists = 0
    EndIf
    $iTunes = ObjCreate("iTunes.application")
    $playlist = $iTunes.LibraryPlaylist
    $ChoosenPlaylist = GUICtrlRead($ChoosePlaylist)
    If $ChoosenPlaylist = "" Then
        GUICtrlSetColor($reminder, 0xFF0000)
        Return
    Else
        GUICtrlSetColor($reminder, 0x000000)
    EndIf
    $timer = TimerInit()
    $sources = $iTunes.sources
    $tracks = ""
    for $i in $sources ; Retrieve selected playlist
        If $i.name = $ChoosenPlaylist Then
            For $j in $i.playlists
                If $j.name = $i.name Then
                    $tracks = $j.tracks
                    $playlist = $j
                EndIf
            Next
        Else
            $subsource = $i.playlists
            for $j in $subsource
                If "     " & $j.name = $ChoosenPlaylist Then
                    $tracks = $j.tracks
                    $playlist = $j
                EndIf
            Next
        EndIf
    Next
    If GUICtrlRead($BatchChooseSite) = "Local files" Then
        $directory = FileSelectFolder("Where are the lyrics stored?", @DesktopDir, 7, @DesktopDir)
        If $directory = "" Then Return
    EndIf
    GUICtrlSetState($BatchStatus, $GUI_DISABLE)
    $count = 0
    For $track in $tracks ; Repeats this process for every song in that playlist\
        $count+=1
        GUICtrlSetData($message, " Song " & $count & " of " & $tracks.count) ; Updates the label at the bottom
        GUICtrlSetColor($message, 0x00FF00FF) ; Makes sure the color is right
        $SkipSong = 0
        Opt("GUIOnEventMode", 0)
        $msg = GUIGetMsg()
        $TrayMsg = TrayGetMsg()
        If $TrayMsg = $TrayMenuAbout Then about()
        If $TrayMsg = $TrayMenuHelp Then help()
        If $msg = $GUI_EVENT_CLOSE or $TrayMsg = $TrayMenuExit Then
            If MsgBox(0x134, "Quit NOW?!", "Are you SURE you want to quit while iDFree is still getting lyrics?") = 6 Then _Exit()
        EndIf
        If GUICtrlRead($SkipSongsWithLyrics) = 1 and $track.lyrics <> "" and $track.lyrics <> " " Then
            GUICtrlSetData($BatchStatus, $track.name & " already has lyrics." & @CRLF, "append")
        Else
            If $ShouldExcludeArtists = 1 Then
                For $i = 1 to $ExcludeArtists[0]
                    If $track.artist = $ExcludeArtists[$i] Then
                        GUICtrlSetData($BatchStatus, "Skipping " & $track.name & " by " & $track.artist & @CRLF, "append")
                        $SkipSong = 1
                    EndIf
                Next
            EndIf
            If $SkipSong <> 1 Then
                Global $BatchTrackName = $track.name
                Global $BatchTrackArtist = $track.artist
                If GUICtrlRead($BatchChooseSite) = "AZLyrics.com" Then ; Batch AZ lyrics
                    GUICtrlSetData($BatchStatus, $track.name & "...connecting...", "append")
                    $URLName = StringReplace(StringLower($track.name), " ", "")
                    $URLArtist = StringReplace(StringLower($track.artist), " ", "")
                    $URLName = StringReplace($URLName, "'", "")
                    $URLName = StringReplace($URLName, "/", "")
                    $URLName = StringReplace($URLName, ",", "")
                    $URLName = StringReplace($URLName, ".", "")
                    $URLName = StringReplace($URLName, "-", "")
                    $URLName = StringReplace($URLName, "#", "")
                    $URLName = StringReplace($URLName, '"', "")
                    $URL = "http://www.azlyrics.com/lyrics/" & $URLArtist & "/" & $URLName & ".html"
                    $lyrics = _INetGetSource($URL)
                    If Not @error Then
                        If StringInStr($lyrics, "<TITLE>A-Z Lyrics Universe</TITLE>") Then
                            GUICtrlSetData($BatchStatus, "searching...", "append")
                            GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                        Else
                            GUICtrlSetData($BatchStatus, "searching...", "append")
                            $lyrics = StringSplit($lyrics, "<FONT size=2>", 1)
                            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
                            $lyrics = StringSplit($lyrics, "[", 1)
                            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
                            $lyrics = StringReplace($lyrics, "<br>", "")
                            $lyrics = StringReplace($lyrics, "<i>", "")
                            $lyrics = StringReplace($lyrics, "</i>", "")
                            $lyrics = StringReplace($lyrics, "<b>", "")
                            $lyrics = StringReplace($lyrics, "</b>", "")
                            $lyrics = StringReplace($lyrics, "<u>", "")
                            $lyrics = StringReplace($lyrics, "</u>", "")
                            $lyrics = StringStripWS($lyrics, 3)
                            If $mode <> 1 Then
                                GUICtrlSetData($BatchStatus, "applying...", "append")
                                $track.lyrics = $lyrics
                                If $track.lyrics <> $lyrics Then
                                    GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                            If $mode <> 0 Then
                                GUICtrlSetData($BatchStatus, "saving...", "append")
                                If FileWrite($folder & "\lyrics\" & $track.artist & " - " & $track.name & ".txt", $lyrics) = 0 Then
                                    GUICtrlSetData($BatchStatus, "error", "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                        EndIf
                    Else
                        GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                    EndIf                   
                ElseIf GUICtrlRead($BatchChooseSite) = "LyricsOnDemand.com" Then ; Batch OD lyrics
                    GUICtrlSetData($BatchStatus, $track.name & "...connecting...", "append")
                    $URLName = StringReplace(StringLower($track.name), " ", "")
                    $URLArtist = StringReplace(StringLower($track.artist), " ", "")
                    $URLName = StringReplace($URLName, "'", "")
                    $URLName = StringReplace($URLName, "/", "")
                    $URLName = StringReplace($URLName, ",", "")
                    $URLName = StringReplace($URLName, ".", "")
                    $URLName = StringReplace($URLName, "-", "")
                    $URLName = StringReplace($URLName, "#", "")
                    $URLName = StringReplace($URLName, '"', "")
                    $URLName&="lyrics"
                    $URLArtist&="lyrics"
                    $SplitArtist = StringSplit($URLArtist, "")
                    $URL = "http://www.lyricsondemand.com/" & $SplitArtist[1] & "/" & $URLArtist & "/" & $URLName & ".html"
                    $lyrics = _INetGetSource($URL)
                    If Not @error Then
                        If StringInStr($lyrics, "File Not Found") Then
                            GUICtrlSetData($BatchStatus, "searching...", "append")
                            GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                        Else
                            GUICtrlSetData($BatchStatus, "searching...", "append")
                            $lyrics = StringSplit($lyrics, '<font size="2" face="Verdana">', 1)
                            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
                            $lyrics = StringSplit($lyrics, "&nbsp;", 1)
                            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
                            $lyrics = StringSplit($lyrics, "<script language", 1)
                            If IsArray($lyrics) Then $lyrics = $lyrics[1]
                            $lyrics = StringReplace($lyrics, "<br>", @CRLF)
                            $lyrics = StringReplace($lyrics, @LF, @CRLF)
                            $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
                            $lyrics = StringReplace($lyrics, @CRLF, @LF)
                            $lyrics = StringReplace($lyrics, 'h1', "")
                            $lyrics = StringReplace($lyrics, ' /', "")
                            $lyrics = StringReplace($lyrics, ' \', "")
                            $lyrics = StringReplace($lyrics, "<br>", "")
                            $lyrics = StringReplace($lyrics, "<br/>", "")
                            $lyrics = StringReplace($lyrics, "<br\>", "")
                            $lyrics = StringReplace($lyrics, "<\ br>", "")
                            $lyrics = StringReplace($lyrics, "<br \>", "")
                            $lyrics = StringReplace($lyrics, "</ br>", "")
                            $lyrics = StringReplace($lyrics, "<br />", "")
                            $lyrics = StringReplace($lyrics, "&quot;", "")
                            $lyrics = StringReplace($lyrics, "<i>", "")
                            $lyrics = StringReplace($lyrics, "</i>", "")
                            $lyrics = StringReplace($lyrics, "<b>", "")
                            $lyrics = StringReplace($lyrics, "</b>", "")
                            $lyrics = StringReplace($lyrics, "<u>", "")
                            $lyrics = StringReplace($lyrics, "</u>", "")
                            $lyrics = StringReplace($lyrics, '">', "")
                            $lyrics = StringReplace($lyrics, '>', "")
                            $lyrics = StringReplace($lyrics, '<"', "")
                            $lyrics = StringReplace($lyrics, '<', "")
                            $lyrics = StringStripWS($lyrics, 3)
                            $lyrics&=@CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
                            If $mode <> 1 Then
                                GUICtrlSetData($BatchStatus, "applying...", "append")
                                $track.lyrics = $lyrics
                                If $track.lyrics <> $lyrics Then
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append") ; Yeah, this /should/ be error, but that'll
                                                                                               ; never happen and was causing bugs
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                            If $mode <> 0 Then
                                GUICtrlSetData($BatchStatus, "saving...", "append")
                                If FileWrite($folder & "\lyrics\" & $track.artist & " - " & $track.name & ".txt", $lyrics) = 0 Then
                                    GUICtrlSetData($BatchStatus, "error", "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                        EndIf
                    Else
                        GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                    EndIf
                ElseIf GUICtrlRead($BatchChooseSite) = "LyricsDir.com (beta)" Then ; LyricsDir.com
                    ;http://www.lyricsdir.com/streetlight-manifesto-as-the-footsteps-die-out-forever-lyrics.html
                    $URLName = StringReplace(stringlower($song), " ", "-")
                    $URLArtist = StringReplace(stringlower($artist), " ", "-")
                    $URLName = StringReplace($URLName, "'", "")
                    $URLName = StringReplace($URLName, "/", "")
                    $URLName = StringReplace($URLName, ",", "")
                    $URLName = StringReplace($URLName, ".", "")
                    $URLName = StringReplace($URLName, "#", "")
                    $URLName = StringReplace($URLName, '"', "")
                    $URL = "http://www.lyricsdir.com/" & $URLArtist & "-" & $URLName & ".html"
                    $lyrics = _INetGetSource($URL)
                    If Not @error Then
                        If StringInStr($lyrics, "http://www.lyricsdir.com/img/lyricsdir.gif") Then
                            GUICtrlSetData($edit, "Could not find lyrics")
                        Else
                            $lyrics = StringSplit($lyrics, '<div id="lyrics', 1)
                            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
                            $lyrics = StringSplit($lyrics, "</div>", 1)
                            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
                                        $lyrics = StringReplace($lyrics, "<br>", @CRLF)
                                        $lyrics = StringReplace($lyrics, @LF, @CRLF)
                                        $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
                                        $lyrics = StringReplace($lyrics, @CRLF, @LF)
                                        $lyrics = StringReplace($lyrics, 'h1', "")
                                        $lyrics = StringReplace($lyrics, ' /', "")
                                        $lyrics = StringReplace($lyrics, ' \', "")
                                        $lyrics = StringReplace($lyrics, "<br>", "")
                                        $lyrics = StringReplace($lyrics, "<br/>", "")
                                        $lyrics = StringReplace($lyrics, "<br\>", "")
                                        $lyrics = StringReplace($lyrics, "<\ br>", "")
                                        $lyrics = StringReplace($lyrics, "<br \>", "")
                                        $lyrics = StringReplace($lyrics, "</ br>", "")
                                        $lyrics = StringReplace($lyrics, "<br />", "")
                                        $lyrics = StringReplace($lyrics, "&quot;", "")
                                        $lyrics = StringReplace($lyrics, "<i>", "")
                                        $lyrics = StringReplace($lyrics, "</i>", "")
                                        $lyrics = StringReplace($lyrics, "<b>", "")
                                        $lyrics = StringReplace($lyrics, "</b>", "")
                                        $lyrics = StringReplace($lyrics, "<u>", "")
                                        $lyrics = StringReplace($lyrics, "</u>", "")
                                        $lyrics = StringReplace($lyrics, '">', "")
                                        $lyrics = StringReplace($lyrics, '>', "")
                                        $lyrics = StringReplace($lyrics, '<"', "")
                                        $lyrics = StringReplace($lyrics, '<', "")
                            $lyrics = StringStripWS($lyrics, 3)
                            $lyrics&=@CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
                            GUICtrlSetData($edit, $lyrics)
                        EndIf
                    Else
                        GUICtrlSetData($edit, "Could not connect")
                    EndIf
                Else ; Local files
                    $file = $directory & "\" & $track.artist & " - " & $track.name & ".txt"
                    GUICtrlSetData($BatchStatus, $BatchTrackName & "...locating file...", "append")
                    If Not @error Then
                        If Not FileExists($file) Then
                            GUICtrlSetData($BatchStatus, "opening...", "append")
                            GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                        Else
                            GUICtrlSetData($BatchStatus, "opening...", "append")
                            $lyrics = FileRead($file)
                            If $mode <> 1 Then
                                GUICtrlSetData($BatchStatus, "applying...", "append")
                                $track.lyrics = $lyrics
                                If $track.lyrics <> $lyrics Then
                                    GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                            If $mode <> 0 Then
                                GUICtrlSetData($BatchStatus, "saving...", "append")

                                If FileWrite($folder & "\lyrics\" & $track.artist & " - " & $track.name & ".txt", $lyrics) = 0 Then
                                    GUICtrlSetData($BatchStatus, "error", "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                        EndIf
                    Else
                        GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                    EndIf           
                EndIf
            EndIf
        EndIf
    Next
    $timer = TimerDiff($timer)
    $timer = Round($timer/1000)
    $seconds = Round(mod($timer, 60))
    $seconds+=1
    If $seconds < 10 Then $seconds = "0" & $seconds
    $timer = Floor($timer/60) & ":" & $seconds
    GUICtrlSetData($BatchStatus, @CRLF & "Time: " & $timer, "append")
    GUICtrlSetData($message, " Finished! (" & $timer & ")") ; Updates the label at the bottom
    GUICtrlSetColor($message, 0x0000AA44) ; Makes sure the color is right
    Opt("GUIOnEventMode", 1)
    GUICtrlSetState($BatchStatus, $GUI_ENABLE)
EndFunc 

Func save() ; Save lyrics to text file
    $RecommendedName = GUICtrlRead($ArtistEdit) & " - " & GUICtrlRead($TrackEdit) & ".txt"
    $SaveFile = FileSaveDialog("Save Your Lyrics", @MyDocumentsDir, "Text Files (*.txt)|All Files (*.*)", 16, $RecommendedName)
    FileWrite($SaveFile, GUICtrlRead($LyricsEdit))
EndFunc

Func _GetLyrics()
    If _GUICtrlTab_GetCurSel($tab) = 0 Then ; iTunes mode
        $iTunes = ObjCreate("iTunes.application")
        $CurrentTrack = $iTunes.CurrentTrack
        If GUICtrlRead($ChooseSite) = "AZLyrics.com" Then
            AZGetLyrics($CurrentTrack.artist, $CurrentTrack.name, $NewLyricsEdit)
        ElseIf GUICtrlRead($ChooseSite) = "LyricsDir.com (beta)" Then
            LyricsDirLyrics($CurrentTrack.artist, $CurrentTrack.name, $NewLyricsEdit)
        Else
            ODGetLyrics($CurrentTrack.artist, $CurrentTrack.name, $NewLyricsEdit)
        EndIf
    ElseIf _GUICtrlTab_GetCurSel($tab) = 1 Then ; Batch mode
        Return 0
    Else
        If GUICtrlRead($ManualChooseSite) = "AZLyrics.com" Then ; Manual mode
            AZGetLyrics(GUICtrlRead($ArtistEdit), GUICtrlRead($TrackEdit), $ManualLyricsEdit)
        ElseIf GUICtrlRead($ManualChooseSite) = "LyricsDir.com (beta)" Then
            LyricsDirLyrics(GUICtrlRead($ArtistEdit), GUICtrlRead($TrackEdit), $ManualLyricsEdit)
        Else
            ODGetLyrics(GUICtrlRead($ArtistEdit), GUICtrlRead($TrackEdit), $ManualLyricsEdit)
        EndIf
    EndIf
EndFunc   ;==>_GetLyrics

Func SaveArt()
    $iTunes = ObjCreate("iTunes.application")
    If IsObj($iTunes) Then $NowPlaying = $iTunes.CurrentTrack
    If Not IsObj($NowPlaying) Then Return
    $SaveDir = FileSaveDialog("Save album art for '" & $NowPlaying.album & "'", @DesktopDir, "JPEG (*.jpg;*.jpeg)", 18, $NowPlaying.Album & " art.jpg")
    If $SaveDir <> "" Then
        $NowArt = $NowPlaying.artwork
        For $art in $NowArt
            $art.SaveArtworkToFile($SaveDir)
            ExitLoop
        Next
    EndIf
EndFunc

Func LoadArt()
    $iTunes = ObjCreate("iTunes.application")
    If IsObj($iTunes) Then $NowPlaying = $iTunes.CurrentTrack
    If Not IsObj($NowPlaying) Then Return
    $LoadDir = FileOpenDialog("Choose album art for '" & $NowPlaying.album & "'", @DesktopDir, "JPEG (*.jpg;*.jpeg)", 18)
    If $LoadDir <> "" Then
        $NowPlaying.AddArtworkFromFile($LoadDir)
        art()
    EndIf
EndFunc

Func GoToMSI()
    _IECreate("http://www.magicsoftinc.com")
EndFunc

Func move()
    Opt("WinTitleMatchMode", 4)
    $bar = WinGetPos("classname=Shell_TrayWnd")
    $win = WinGetPos("iDFree 2.2")
    $mouse = MouseGetPos()
    $XOff = $mouse[0] - $win[0]
    $YOff = $mouse[1] - $win[1]
    While _IsPressed(01)
        $mouse = MouseGetPos()
        $win = WinGetPos("iDFree 2.2")
        If $XOff - $mouse[0] < 0 Then
            If $mouse[1] + $win[3] + $bar[3] < @DesktopHeight Then
                WinMove("iDFree 2.2", "", $mouse[0] - $XOff, $mouse[1] - $YOff)
            Else
                WinMove("iDFree 2.2", "", $mouse[0] - $XOff, @DesktopHeight - $win[3] - $bar[3])
            EndIf
        Else
            If $mouse[1] + $win[3] + $bar[3] < @DesktopHeight Then
                WinMove("iDFree 2.2", "", 0, $mouse[1] - $YOff)
            Else
                WinMove("iDFree 2.2", "", 0, @DesktopHeight - $win[3] - $bar[3])
            EndIf
        EndIf
    WEnd
    If $win[1] < 0 Then WinMove("iDFree 2.2", "", $mouse[0] - $XOff, 0)
EndFunc

Func MinimizeButton()
    ;GUICtrlSetImage($minimize, @TempDir & "\minimize bright.bmp", -1)
    _minimize()
    ;GUICtrlSetImage($minimize, @TempDir & "\minimize.bmp")
EndFunc 

Func ExitButton()
    ;GUICtrlSetImage($exit, @TempDir & "\exit bright.bmp")
    _exit()
    ;GUICtrlSetImage($exit, @TempDir & "\exit.bmp")
EndFunc 

Func _minimize()
    Opt("TrayIconHide", 0)
    GUISetState(@SW_MINIMIZE)
EndFunc 

Func _exit()
    Opt("TrayIconHide", 1)
    FileDelete(@TempDir & "\about.gif")
    FileDelete(@TempDir & "\bg.gif")
    FileDelete(@TempDir & "\empty.bmp")
    FileDelete(@TempDir & "\slider.bmp")
    FileDelete(@TempDir & "\title.bmp")
    FileDelete(@TempDir & "\close.bmp")
    FileDelete(@TempDir & "\minimize.bmp")
    FileDelete(@TempDir & "\title.bmp")
    Exit
EndFunc[code]


edit info.au3
[code]#include <GUIConstants.au3>
#include-once

Func EditInfo()
    Global $iTunes = ObjCreate("iTunes.application")
    Global $track = $iTunes.CurrentTrack
    $TrackName = $track.name
    $TrackLength = $track.time
    $TrackArtist = $track.artist
    $TrackAlbum = $track.album
    $TrackNumber = $track.TrackNumber
    $TracksOnAlbum = $track.TrackCount
    $TrackComposer = $track.composer
        If $TrackComposer = '0' Then $TrackComposer = ""
    $TrackYear = $track.year
    $TrackGenre = $track.genre
    $TrackComments = $track.comment
        If $TrackComments = '0' Then $TrackComments = ""
    $TrackLyrics = $track.lyrics
        If $TrackLyrics = '0' Then $TrackLyrics = ""
    $TrackPlayCount = $track.PlayedCount
    $TrackPlayDate = $track.PlayedDate
        $x = StringSplit($TrackPlayDate, "")
        $TrackPlayDate = $x[5] & $x[6] & "/" & $x[7] & $x[8] & "/" & $x[1] & $x[2] & $x[3] & $x[4]
        $time = int($x[9] & $x[10])
        $suffix = " am"
        If $time >= 13 Then
            $time-=12
            $suffix = " pm"
        EndIf
        If $time <= 0 Then $time = 12
        $time = " - " & $time & ":" & $x[11] & $x[12] & ":" & $x[13] & $x[14] & $suffix
        $TrackPlayDate&=$time
    $TrackPlaylist = $track.playlist
    $TrackPlaylist = $TrackPlaylist.name
    $TrackRating = $track.rating
        If $TrackRating = 0 Then
            $TrackRating = "No rating"
        Else
            $TrackRating = $TrackRating & " stars"
        EndIf   
    $TrackSize = $track.size
        $SizeRem = Mod($TrackSize, 1000000)
        $SizeRem = StringSplit($SizeRem, "")
        $TrackSize = int($TrackSize/1000000)
        $TrackSize = $TrackSize & "." & $SizeRem[1] & $SizeRem[2] & " MB"
    $TrackLocation = $track.location
        If $TrackLocation = '0' Then $TrackLocation = "iPod"

    $InfoGUI = GUICreate("Edit info for '" & $track.name &"' - iDFree", 527, 395, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_POPUP, $WS_SYSMENU), -1) ; Creates GUI
    $rgn = CreateRoundRectRgn(0, 0, 530, 398, 9, 9)
    SetWindowRgn($InfoGUI, $rgn)
    GUISetBkColor(0x6E6E6E)
    GUICtrlCreatePic(@TempDir & "\bg.gif", 0, -3, 535, 360)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("Edit '" & $TrackName & "'  ", 55, 4, 465, 17, $SS_CENTER)
    GUICtrlSetFont(-1, -1, 800)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateLabel("Edit '" & $TrackName & "'  ", 54, 3, 465, 17, $SS_CENTER)
    GUICtrlSetFont(-1, -1, 800)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $InfoMoveRegion = GUICtrlCreateLabel("", 52, 0, 552, 19)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $InfoExit = GUICtrlCreatePic(@TempDir & "\iexit.bmp", 5, 2, 0, 0)
    GUICtrlSetTip(-1, "Exit without saving")
    $InfoMinimize = GUICtrlCreatePic(@TempDir & "\iminimize.bmp", 22, 2, 0, 0)
    GUICtrlSetTip(-1, "Minimize edit window")
    $InfoMaximize = GUICtrlCreatePic(@TempDir & "\imaximize.bmp", 39, 2, 0, 0)
    GUICtrlSetTip(-1, "Maximize disabled")
    GUICtrlCreatePic(@TempDir & "\tabs2.gif", 10, 360, 165, 30)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $InfoTab = GUICtrlCreateTab(10, 360, 165, 30, BitOr($WS_TABSTOP, $WS_CLIPSIBLINGS, $TCS_BUTTONS))
    $summary = GUICtrlCreateTabItem("Summary")
        If $ArtLocation <> @TempDir & "\NoArt.bmp" Then
            GUICtrlCreatePic(@TempDir & "\CurrentArt.jpg", 17, 36, 108, 108)
        Else
            GUICtrlCreateGroup("", 15, 30, 115, 115)
            GUICtrlCreateLabel("No album art", 44, 83)
            GUICtrlSetColor(-1, 0xFFFFFF)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlCreateLabel("No album art", 43, 82)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        EndIf
        GUICtrlCreateLabel($TrackName, 135, 40, 375, 17, 0x0C)
        GUICtrlCreateLabel($TrackArtist, 135, 55, 375, 17, 0x0C)
        GUICtrlCreateLabel($TrackAlbum, 135, 70, 375, 17, 0x0C)
        GUICtrlCreateLabel($TrackLength, 135, 93, 375, 17)
        $LocateAndPlay = GUICtrlCreateButton("  Locate and Play  ", 135, 119)
        GUICtrlCreateLabel("", 15, 152, 495, 2, $SS_SUNKEN)
        GUICtrlCreateLabel("Size:", 32, 163, 30, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackSize, 63, 164, 100, 16)
        GUICtrlCreateLabel("Track", 25, 179, 40, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackNumber, 63, 180, 100, 16)
        GUICtrlCreateLabel("of", 46, 194, 20, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TracksOnAlbum, 63, 195, 100, 16)
        GUICtrlCreateLabel("Genre:", 22, 210, 40, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackGenre, 63, 211, 100, 16)
        GUICtrlCreateLabel("Plays:", 25, 227, 40, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackPlayCount, 63, 228, 100, 16)
        GUICtrlCreateLabel("Last:", 31, 243, 40, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackPlayDate, 63, 244, 200, 16)
        GUICtrlCreateLabel("", 15, 271, 495, 2, $SS_SUNKEN)
        GUICtrlCreateLabel("Playlist:", 1, 275, 63, 16, $SS_RIGHT)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackPlaylist, 69, 276, 200, 16)
        GUICtrlCreateLabel("Where:", 1, 290, 63, 57, $SS_RIGHT)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackLocation, 69, 291, 448, 57)
    $edit = GUICtrlCreateTabItem("Edit")
        GUICtrlCreateLabel("Name:", 15, 37, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $NameEdit = GUICtrlCreateInput($TrackName, 15, 55, 495, 20)
        GUICtrlCreateLabel("Artist:", 15, 82, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $ArtistEdit = GUICtrlCreateInput($TrackArtist, 15, 100, 405, 20)     
        GUICtrlCreateLabel(" Year:", 427, 82, 60, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $YearEdit = GUICtrlCreateInput($TrackYear, 430, 100, 60, 20)     
        GUICtrlCreateLabel("Album:", 15, 127, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $AlbumEdit = GUICtrlCreateInput($TrackAlbum, 15, 144, 405, 20)
        GUICtrlCreateLabel("Track number:", 427, 127, 120, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $Num1Edit = GUICtrlCreateInput($TrackNumber, 430, 144, 25, 20)
        GUICtrlCreateLabel("of", 462, 147, 20, 20)
        Global $Num2Edit = GUICtrlCreateInput($TracksOnAlbum, 480, 144, 25, 20)
        GUICtrlCreateLabel("Playcount:", 15, 171, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $PlaycountEdit = GUICtrlCreateInput($TrackPlaycount, 15, 188, 73, 20)
        GUICtrlCreateLabel("Composer:", 100, 171, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $ComposerEdit = GUICtrlCreateInput($TrackComposer, 100, 188, 405, 20)
        GUICtrlCreateLabel("Comments:", 15, 212, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $CommentsEdit = GUICtrlCreateEdit($TrackComments, 15, 229, 495, 85, BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL))
        Global $GenreCombo = GUICtrlCreateCombo("Genre", 15, 320, 157, -1, BitOr($WS_VSCROLL, $CBS_DROPDOWNLIST))
        $genres = "Acoustic|Alternative|Alternative & Punk|Blues/R&B|Books and Spoken|Children's Music|Classical|Country|Dance|Easy Listening|Electronic|Folk|General Rock|Hip Hop/Rap|Holiday|Industrial|" & _ 
                    "Jazz|New Age|Other|Pop|Pop Punk|Punk Rock|Reggae|Religious|Rock|Ska|Soundtrack|Techno|Unclassifiable|World"
            GUICtrlSetData(-1, $genres, $TrackGenre)
        Global $OtherGenreEdit = GUICtrlCreateInput("", 190, 320, 257, 20)
            GUICtrlSetState(-1, $GUI_DISABLE)
    $lyrics = GUICtrlcreateTabItem("Lyrics")
        Global $LyricsInWindowBox = GUICtrlCreateEdit($TrackLyrics, 15, 38, 496, 306)
    GUICtrlCreateTabItem("")
    $ExitNoSave = GUICtrlCreateButton("Exit without saving", 250, 360, 100, 26)
    $ExitAndSave = GUICtrlCreateButton("Save && exit", 360, 360, 100, 26)
    $enabled = 0
    GUISetState()
    $track.lyrics = ""

    While 1
        Opt("GUIOnEventMode", 0)
        $msg = GUIGetMsg()
        If GUICtrlRead($GenreCombo) = "Other" and $enabled = 0 Then
            GUICtrlSetState($OtherGenreEdit, $GUI_ENABLE)
            $enabled = 1
        EndIf
        If GUICtrlRead($GenreCombo) <> "Other" and $enabled = 1 Then
            GUICtrlSetState($OtherGenreEdit, $GUI_DISABLE)
            $enabled = 0
        EndIf
        If $msg = $ExitNoSave Then ExitLoop
        If $msg = $ExitAndSave Then
            SaveInfo()
            ExitLoop
        EndIf
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $LocateAndPlay Then $track.play
        If $msg = $InfoMinimize Then GUISetState(@SW_MINIMIZE)
        If $msg = $InfoExit Then ExitLoop
    WEnd

    Opt("GUIOnEventMode", 1)
    GUIDelete($InfoGUI) 
EndFunc

Func SaveInfo()
    If GUICtrlRead($NameEdit) <> $track.name Then $track.name = GUICtrlRead($NameEdit)
    If GUICtrlRead($ArtistEdit) <> $track.artist Then $track.artist = GUICtrlRead($ArtistEdit)
    $track.album = GUICtrlRead($AlbumEdit)
    If GUICtrlRead($Num1Edit) <> $track.TrackNumber Then $track.TrackNumber = GUICtrlRead($Num1Edit)
    If GUICtrlRead($Num2Edit) <> $track.TrackCount Then $track.TrackCount = GUICtrlRead($Num2Edit)
    If GUICtrlRead($ComposerEdit) <> $track.composer Then $track.composer = GUICtrlRead($ComposerEdit)
    If GUICtrlRead($CommentsEdit) <> $track.comment Then $track.comment = GUICtrlRead($CommentsEdit)
    If GUICtrlRead($YearEdit) <> $track.year Then $track.year = GUICtrlRead($YearEdit)
    If GUICtrlRead($LyricsInWindowBox) <> "" Then $track.lyrics = GUICtrlRead($LyricsInWindowBox)
    If GUICtrlRead($PlaycountEdit) <> "" Then $track.PlayedCount = GUICtrlRead($PlaycountEdit)
    If GUICtrlRead($GenreCombo) <> "Other" Then
        If GUICtrlRead($GenreCombo) <> "Genre" Then $track.genre = GUICtrlRead($GenreCombo)
    Else
        If GUICtrlRead($OtherGenreEdit) <> "" Then $track.genre = GUICtrlRead($OtherGenreEdit)
    EndIf   
    art()
EndFunc 

Func about()
    Opt("GUIOnEventMode", 0)
    $AboutGUI = GUICreate("About iDFree", 431, 246, -1, -1, $WS_POPUP)
    WinSetOnTop("About iDFree", "", 1)
    GUISetBkColor(0xFFFFFF)
    GUICtrlCreatePic(@TempDir & "\about.gif", 0, 0, 431, 246)
    GUICtrlSetState(-1, $GUI_DISABLE)

    $close = GUICtrlCreateButton(" Ok! ", 380, 100, 35, 22)
    $win = WinGetPos("About iDFree")
    $child = GUICreate("About scroller", 175, 115, $win[0]+255, $win[1]+125, $WS_POPUP, $WS_EX_TRANSPARENT, $AboutGUI)
    GUISetBkColor(0xFFFFFF)
    $AboutLabel = GUICtrlCreateLabel("Coded by Ben Perkins" & @CR & "Magic Soft Inc." & @CR & "Inspired by:" & @CR & "Alex Bagby and Ichaelmay58" & _
                        @CR & "BG image thanks to Reel Big Fish" & @CR & @CR & "-The Magician", 1, -80, 170, 105, BitOr($SS_NOTIFY, $SS_RIGHT))
    GUISetState(@SW_SHOW, $AboutGUI)
    GUISetState(@SW_SHOW, $child)

    While 1
        For $i = -105 to 130
            $msg = GUIGetMsg()
            ControlMove("About scroller", "", $AboutLabel, 1, 30-$i)
            If $msg = $close Then
                Opt("GUIOnEventMode", 1)
                GUIDelete($AboutGUI)
                Return
            EndIf
            sleep(50)
        Next
    WEnd
EndFunc

Func help()
    $HelpGUI = GUICreate("iDFree Help", 775, 550, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))    
    $AboutBugs = "Known bugs:" & @CRLF & "PNG album art doesn't always work" & @CRLF & "Always chooses first playlist of duplicates" & @CRLF & "LyricsDir.com doesn't work, I believe the site is down" & @CRLF & @CRLF & "Email others to: magician13134@gmail.com" & @CRLF & @CRLF & "Fixed bugs:" & @CRLF & "Local files don't work (2/05/07)" & @CRLF & "Crashes if opened on a song with no art (2/11/07)" &   @CRLF & "Window resizes when song w/o album art starts (2/11/07)" & @CRLF & "No help file exists yet (2/12/07)"
    $AboutHelp = "Choose a sub catagory for more"
    $AboutiTunes = "In iTunes Mode iDFree will read the current song and find lyrics for it from the choosen site" & @CRLF & "These lyrics appear in the 'New lyrics' box, and can be applied by pressing 'Apply New Lyrics'" & @CRLF & "To edit current lyrics press the '>' button or use 'Edit info'" & @CRLF & "iTunes mode also allows you to control the iTunes player without leaving iDFree" & @CRLF & "by using the control buttons in the top-left" & @CRLF & @CRLF & "Pressing 'iBoost' opens the included copy of iBoost. (See 'iBoost' for more.)" & @CRLF & "Pressing 'Edit info' will edit the track info. (See 'Edit Info' for more)" & @CRLF & "Click the remaining song time to switch time view" & @CRLF & "Click the artwork for a zoomed view"
    $AboutBatch = "Begin by choosing any playlist or source. If the source has too many songs (around 700), the log file will be cut off," & @CRLF & "the bottom of iDFree will tell you how many songs it contains and a color corresponding to that number" & @CRLF & "(Green is good, yellow is ok, and red is bad)" & @CRLF & "Choose the options to fit your needs and press 'Get lyrics' and let iDFree work" & @CRLF & "It is not recommended that you direct iDFree away from batch apply while it is getting lyrics" & @CRLF & "Choosing 'Save log' will save a log file of the batch apply"
    $AboutManual = "Begin by entering an artist and a track name into the corresponding boxes, choose a website and click 'Get lyrics'." & @CRLF & "To save these lyrics, press 'Save lyrics'"
    $AboutAbout = "Written by Ben Perkins, owner and founder of Magic Soft Inc." & @CRLF & "www.magicsoftinc.com" & @CRLF & "Thanks for the idea Alex and Mike... And the critism to keep me working ;)" & @CRLF & "The background image for the about box was stolen from The Reel Big Fish, please don't sue me! :)" & @CRLF & @CRLF & "Please don't buy the Reel Big Fish 'Greatest Hit' album!" & @CRLF & "It was made without the consent of RBF and without paying them a cent!"
    $contents = GUICtrlCreateTreeView(0, 0, 198, 550, BitOr($TVS_HASBUTTONS, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    GUICtrlSetResizing(-1, 354)
    $help = GUICtrlCreateTreeViewItem("Help", $contents)
        $iTunesItem = GUICtrlCreateTreeViewItem("iTunes Mode", $help)
        $BatchItem = GUICtrlCreateTreeViewItem("Batch Mode", $help)
        $ManualItem = GUICtrlCreateTreeViewItem("Manual Mode", $help)
    $bugs = GUICtrlCreateTreeViewItem("Bugs", $contents)
    $about = GUICtrlCreateTreeViewItem("About", $contents)  
    $view = GUICtrlCreateEdit("", 200, 0, 575, 550, BitOr($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY))
    GUICtrlSetFont(-1, -1, -1, -1, "arial")
    GUICtrlSetResizing(-1, 102)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUISetState()
    $SelAbout = 0
    While 1
        Opt("GUIOnEventMode", 0)
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then
            Opt("GUIOnEventMode", 1)
            GUIDelete($HelpGUI)
            Return
        EndIf
        $ContentsRead = GUICtrlRead($contents)
        $ViewRead = GUICtrlRead($view)
        If $ContentsRead = $bugs and $ViewRead <> $AboutBugs Then GUICtrlSetData($view, $AboutBugs)
        If $ContentsRead = $help and $ViewRead <> $AboutHelp Then GUICtrlSetData($view, $AboutHelp)
        If $ContentsRead = $iTunesItem and $ViewRead <> $AboutiTunes Then GUICtrlSetData($view, $AboutiTunes)
        If $ContentsRead = $BatchItem and $ViewRead <> $AboutBatch Then GUICtrlSetData($view, $AboutBatch)
        If $ContentsRead = $ManualItem and $ViewRead <> $AboutManual Then GUICtrlSetData($view, $AboutManual)
        If $ContentsRead = $about and $SelAbout = 0 Then
            GUICtrlSetData($view, $AboutAbout)
            $SelAbout = 1
        EndIf
        If $ContentsRead <> $about Then $SelAbout = 0
        sleep(10)
    WEnd
EndFunc

Func iBoost()
    Opt("GUIOnEventMode", 0)
    $iBoost = GUICreate("iBoost - Boost you iTunes playcount", 300, 140)
    $iTunes = ObjCreate("iTunes.application")
    $remind = GUICtrlCreateLabel("Don't forget to" & @LF & "choose a source", 165, 2, 134, 35)
    GUICtrlSetColor(-1, 0x00FF0000)
    $ChooseSource = GUICtrlCreateCombo("Choose source", 5, 5, 157, -1, 0x0003)
    If IsObj($iTunes) Then
        $sources = $iTunes.Sources
        For $i in $sources
            $playlists = $i.Playlists
            For $j in $playlists
                GUICtrlsetData(-1, $j.Name & "|")
            Next
        Next
    EndIf
    $progress = GUICtrlCreateProgress(160, 95, 135, 20, $PBS_SMOOTH) 
    $ChooseFunction = GUICtrlCreateCombo("Multiply by", 5, 35, 157, -1, 0x0003)
    GUICtrlSetData(-1, "Add|Set to")
    $amount = GUICtrlCreateInput("2", 172, 35, 118, 20, 0x2000)
    $SetToOne = GUICtrlCreateCheckbox("Set unplayed songs to one before multiplying", 5, 65)
    GUICtrlSetState(-1, $GUI_ENABLE)
    GUICtrlSetState(-1, $GUI_CHECKED)
    $randomize = GUICtrlCreateCheckbox("Randomize by", 5, 95)
    $RandomAmount = GUICtrlCreateInput("1", 100, 95, 50, 20, 0x2000)
    GUICtrlCreateUpdown(-1)
    $begin = GUICtrlCreateButton("Boost!", 245, 64, 50)
    GUICtrlCreateLabel("By Ben Perkins of Magic Soft Inc.  --  www.magicsoftinc.com", 5, 120, 290, 18, 0x1001)
    GUICtrlSetFont(-1, 8, 400, -1, "Microsoft Sans Serif")
    GUICtrlSetColor(-1, 0x000000FF)
    GUISetState()
    While 1
        If GUICtrlRead($ChooseSource) <> "Choose source" and GUICtrlRead($remind) <> "" Then GUICtrlSetData($remind, "")
        If GUICtrlRead($ChooseSource) = "Choose source" and GUICtrlRead($remind) = "" Then GUICtrlSetData($remind, "Don't forget to" & @LF & "choose a source") 
        If GUICtrlRead($ChooseSource) = "Choose source" and GUICtrlGetState($begin) <> 144 Then GUICtrlSetState($begin, $GUI_DISABLE)
        If GUICtrlRead($ChooseSource) <> "Choose source" and GUICtrlGetState($begin) = 144 Then GUICtrlSetState($begin, $GUI_ENABLE)
        If GUICtrlRead($ChooseFunction) <> "Multiply by" and GUICtrlGetState($SetToOne) <> 144 Then
            GUICtrlSetState($SetToOne, $GUI_DISABLE)
        EndIf
        If GUICtrlRead($ChooseFunction) = "Multiply by" and GUICtrlGetState($SetToOne) = 144 Then
            GUICtrlSetState($SetToOne, $GUI_ENABLE)
        EndIf
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $begin Then
            $begin = 1
            ExitLoop
        EndIf
    WEnd
    If $begin = 1 Then
        $error = 1
        $iTunes = ObjCreate("iTunes.application")
        $playlist = $iTunes.LibraryPlaylist
        $sources = $iTunes.sources
        for $i in $sources
            $subsource = $i.playlists
            for $j in $subsource
                if $j.name = GUICtrlRead($ChooseSource) Then
                    $tracks = $j.tracks
                    $error = 0
                EndIf
            Next
        Next
        If $error = 1 Then
            MsgBox(0, "", "No source was selected!")
        Else
            If GUICtrlRead($randomize) = 1 Then
                $randomize = GUICtrlRead($RandomAmount)
            Else
                $randomize = 0
            EndIf
            $amount = GUICtrlRead($amount)
            If GUICtrlRead($SetToOne) = 1 Then
                $alter = 1
            Else
                $alter = 0
            EndIf
            If GUICtrlRead($ChooseFunction) = "Multiply by" Then
                $function = 1
            ElseIf GUICtrlRead($ChooseFunction) = "Add" Then
                $function = 2
            Else
                $function = 3
            EndIf
            $TrackCount = $tracks.count
            GUICtrlSetLimit($progress, $TrackCount, 0)
            $i = 0
            For $track in $tracks
                $i+=1
                GUICtrlSetData($progress, $i*(100/$TrackCount))
                If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
                $playcount = $track.PlayedCount
                If $alter = 1 and $function = 1 and $playcount = 0 Then $playcount = 1
                If $function = 1 Then
                    $NewCount = $playcount * $amount
                ElseIf $function = 2 Then
                    $NewCount = $playcount + $amount
                Else
                    $NewCount = $amount
                EndIf
                $random = Random(0, $randomize, 1)
                $NewCount+=$random
                $NewCount = Int($NewCount)
                $track.PlayedCount = $NewCount
            Next    
        EndIf   
    EndIf
    Opt("GUIOnEventMode", 1)
    GUIDelete($iBoost)
EndFunc

Func ExitAbout()
    GUIDelete($AboutGUI)
EndFunc

Share this post


Link to post
Share on other sites
magician13134

*sigh* Sorry, those two autoit files got put into one box and I can't edit posts for some weird reason, so here they are again...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=idfree.ico
#AutoIt3Wrapper_outfile=iDFree 2.2.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_Res_Comment=Written by Ben Perkins of Magic Soft Inc.
#AutoIt3Wrapper_Res_Description=Edit songs/lyrics in your iTunes library
#AutoIt3Wrapper_Res_Fileversion=2.2.0.0
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_PassPhrase=013573462489
#Region converted Directives from C:\Users\magician13134\Desktop\msi\software\iTunes Apps\iDFree\iDFree 2.2.au3.ini
#EndRegion converted Directives from C:\Users\magician13134\Desktop\msi\software\iTunes Apps\iDFree\iDFree 2.2.au3.ini
;
#include <IE.au3>
#include <INet.au3>
#include <GUIConstants.au3>
#include <GUITab.au3>
#include <GUIListBox.au3>
#include <string.au3>
#include <misc.au3>
#include "image_get_info.au3"
#include "edit info.au3"

Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 1)

FileInstall("images\about.gif", @TempDir & "\about.gif", 1)
FileInstall("images\bg.gif", @TempDir & "\bg.gif", 1)
FileInstall("images\title.bmp", @TempDir & "\title.bmp", 1)
FileInstall("images\empty.bmp", @TempDir & "\empty.bmp", 1)
FileInstall("images\slider.bmp", @TempDir & "\slider.bmp", 1)
FileInstall("images\NoArt.bmp", @TempDir & "\NoArt.bmp", 1)
FileInstall("images\exit bright.bmp", @TempDir & "\exit bright.bmp", 1)
FileInstall("images\exit.bmp", @TempDir & "\exit.bmp", 1)
FileInstall("images\iexit.bmp", @TempDir & "\iexit.bmp", 1)
FileInstall("images\minimize.bmp", @TempDir & "\minimize.bmp", 1)
FileInstall("images\iminimize.bmp", @TempDir & "\iminimize.bmp", 1)
FileInstall("images\maximize.bmp", @TempDir & "\maximize.bmp", 1)
FileInstall("images\imaximize.bmp", @TempDir & "\imaximize.bmp", 1)
FileInstall("images\tabs2.gif", @TempDir & "\tabs2.gif", 1)
FileInstall("images\iTunesMode.bmp", @TempDir & "\iTunesMode.bmp", 1)
FileInstall("images\batchMode.bmp", @TempDir & "\batchMode.bmp", 1)
FileInstall("images\manualMode.bmp", @TempDir & "\manualMode.bmp", 1)

Dim $SysVolumeRead = 100, $ArtOrNot = 0, $TimeFormat = 0, $OldVolume, $iTunes, $color, $TrayMenuPause, $TrackOrTracks, $ArtLocation, $VolumeRead ; I should learn to Dim all vars... oh well, too late now...

; Create GUI, title bar stuff, and tray menu
$GUI = GUICreate("iDFree 2.2", 602, 559, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_POPUP, $WS_SYSMENU), -1) ; Creates GUI
$rgn = CreateRoundRectRgn(0, 0, 602, 559, 9, 9)
SetWindowRgn($GUI, $rgn)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
GUISetBkColor(0x6E6E6E)
GUICtrlCreatePic(@TempDir & "\bg.gif", -3, 10, 605, 515)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreatePic(@TempDir & "\title.bmp", 0, 0, 604, 14)
GUICtrlSetState(-1, $GUI_DISABLE)
$MoveRegion = GUICtrlCreateLabel("", 52, 0, 552, 19)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;GUICtrlSetOnEvent(-1, "move")
GUICtrlSetStyle(-1, -1, $GUI_WS_EX_PARENTDRAG)
$exit = GUICtrlCreatePic(@TempDir & "\exit.bmp", 5, 2, 0, 0)
GUICtrlSetOnEvent(-1, "ExitButton")
GUICtrlSetTip(-1, "Close iDFree")
$minimize = GUICtrlCreatePic(@TempDir & "\minimize.bmp", 22, 2, 0, 0)
GUICtrlSetOnEvent(-1, "MinimizeButton")
GUICtrlSetTip(-1, "Minimize iDFree")
$maximize = GUICtrlCreatePic(@TempDir & "\maximize.bmp", 39, 2, 0, 0)
GUICtrlSetTip(-1, "Maximize disabled")
$TrayMenuAbout = TrayCreateItem("About iDFree 2.2")
$TrayMenuHelp = TrayCreateItem("iDFree Help")
$TrayMenuSeperator1 = TrayCreateItem("")
$TrayMenuExit = TrayCreateItem("Exit")
GUICtrlCreateLabel("iDFree 2.2", 281, 4, 75, 17, $SS_CENTER)
GUICtrlSetFont(-1, -1, 800)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("iDFree 2.2", 280, 3, 75, 17, $SS_CENTER)
GUICtrlSetFont(-1, -1, 800)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

;$TabMask = GUICtrlCreatePic(@TempDir & "\tabs.bmp", 2, 530, 0, 0)                            ; Create the tabs overlay image
;GUICtrlSetState(-1, $GUI_DISABLE)                                                            ; Allow them to be clicked through
$tab = GUICtrlCreateTab(-200, -200, 1, 1, BitOr($WS_TABSTOP, $WS_CLIPSIBLINGS));, $TCS_BUTTONS)) ; Create the actual tabs (iTunes mode, batch, manual)

$message = GUICtrlCreateLabel("", 265, 536, 330, 17, 0x1001) ; The label at the bottom
GUICtrlSetOnEvent(-1, "GoToMSI") ; Open magicsoftinc.com when clicked
GUICtrlSetCursor (-1, 0) ; Set cursor over the label
GUICtrlSetBkColor(-1, 0x000000) ; Set label BK
$iTunesMode = GUICtrlCreateTabItem("iTunes Mode") ; iTunes (default) tab
    GUICtrlCreateGroup("Song information", 1, 19, 368, 230)
        $name = GUICtrlCreateLabel("Title:", 11, 40, 200, 16, $SS_SIMPLE)
        $artist = GUICtrlCreateLabel("Artist:", 11, 55, 200, 16, $SS_SIMPLE)
        $album = GUICtrlCreateLabel("Album:", 11, 70, 200, 16, $SS_SIMPLE)
        $PositionLabel = GUICtrlCreateLabel("", 5, 208, 50, 14)
        $TimeLabel = GUICtrlCreateLabel("", 337, 208, 35, 14)
        GUICtrlSetOnEvent(-1, "ChangeTimeFormat")
        GUICtrlCreatePic(@TempDir & "\empty.bmp", 5, 222, 360, 15)
        GUICtrlSetOnEvent(-1, "ChangePos")
        GUICtrlSetCursor(-1, 0)
        $position = GUICtrlCreatePic(@TempDir & "\slider.bmp", 5, 222, 1, 15)
        GUICtrlSetOnEvent(-1, "ChangePos")
        GUICtrlSetCursor(-1, 0)
        $AlbumArt = GUICtrlCreatePic("", 214, 43, 150, 150)
        GUICtrlSetCursor($AlbumArt, 0)
        GUICtrlSetOnEvent(-1, "DisplayArt")
        $ArtMenu = GUICtrlCreateContextMenu($AlbumArt)
            $ArtSave = GUICtrlCreateMenuitem("Save", $ArtMenu)
            GUICtrlSetOnEvent($ArtSave, "SaveArt")
            GUICtrlCreateMenuitem("", $ArtMenu)
            $ArtLoad = GUICtrlCreateMenuitem("Load", $ArtMenu)
            GUICtrlSetOnEvent($ArtLoad, "LoadArt")

    GUICtrlCreateGroup("Online lyrics", 374, 138, 166, 111)
        $GetLyrics = GUICtrlCreateButton("Get Lyrics", 379, 158, 75, 25)
        GUICtrlSetOnEvent(-1, "_GetLyrics")
        $ChooseSite = GUICtrlCreateCombo("LyricsOnDemand.com", 379, 188, 157, -1, 0x0003)
        GUICtrlSetData(-1, "AZLyrics.com")
        $SetLyrics = GUICtrlCreateButton("Apply New Lyrics", 379, 215, 95, 25)
        GUICtrlSetOnEvent(-1, "SetLyrics")
    
    GUICtrlCreateGroup("Help", 543, 138, 55, 111)
        $InfoButton = GUICtrlCreateButton("i", 560, 168, 22, 20)
        GUICtrlSetFont(-1, -1, 650)
        GUICtrlSetOnEvent(-1, "about")
        $Helpbutton = GUICtrlCreateButton("?", 560, 203, 22, 20)
        GUICtrlSetFont(-1, -1, 650)
        GUICtrlSetOnEvent(-1, "help")
        
    GUICtrlCreateGroup("iTunes control", 374, 19, 224, 115)
        $PrevTrack = GUICtrlCreateButton("9", 379, 38, 17, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_PrevTrack")
        $NextTrack = GUICtrlCreateButton(":", 397, 38, 17, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_NextTrack")
        $PlayPause = GUICtrlCreateButton("4;", 415, 38, 30, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_PlayPause")
        $stop = GUICtrlCreateButton("<", 446, 38, 17, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_Stop")
        $mute = GUICtrlCreateButton("X", 465, 38, 17, 20)
        GUICtrlSetFont(-1, 10, -1, -1, "Webdings")
        GUICtrlSetOnEvent(-1, "_mute")
        ;$volume = GUICtrlCreateSlider(485, 38, 110, 20)
        ;GUICtrlSetBkColor(-1, 0xFF0000)
        ;GUICtrlSetLimit(-1, 100, 0)
        GUICtrlCreateLabel("iTunes volume:", 485, 40, 120, 17)
        GUICtrlCreatePic(@TempDir & "\empty.bmp", 485, 54, 110, 16) ; iTunes volume
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetOnEvent(-1, "_volume")
        $volume = GUICtrlCreatePic(@TempDir & "\slider.bmp", 485, 31, 0, 16)
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetOnEvent(-1, "_volume")
        GUICtrlCreateLabel("System volume:", 485, 75, 120, 17)
        GUICtrlCreatePic(@TempDir & "\empty.bmp", 485, 89, 110, 16) ; System Volume
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetOnEvent(-1, "_SysVolume")
        $SysVolume = GUICtrlCreatePic(@TempDir & "\slider.bmp", 485, 31, 0, 16)
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetOnEvent(-1, "_SysVolume")
        $EditInfoButton = GUICtrlCreateButton("Edit track info", 379, 68, 103)
        GUICtrlSetOnEvent(-1, "EditInfo")
        $iBoostButton = GUICtrlCreateButton("iBoost", 379, 99, 103)
        GUICtrlSetOnEvent(-1, "iBoost")
        
    ; Should be a group here, but I ran out of space :o
    GUICtrlCreateLabel("Current Lyrics:", 1, 253)
    $LyricsEdit = GUICtrlCreateEdit("", 1, 268, 289, 258, BitOr($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY))
    GUIctrlSetBkColor(-1, 0xAAAAAA)
    #cs ; Huh! You can't make a context menu on an edit! WTF?!
    $LyricsEditContext = GUICtrlCreateContextMenu($LyricsEdit)
    $LyricsEditContextCopy = GUICtrlCreateMenuitem("Copy to clipboard", $LyricsEditContext)
    $LyricsEditContextEdit = GUICtrlCreateMenuitem("Edit lyrics", $LyricsEditContext)
    GUICtrlSetOnEvent(-1, "copy")
    #ce
    GUICtrlCreateLabel("New Lyrics:", 306, 253)
    $NewLyricsEdit = GUICtrlCreateEdit("", 306, 268, 292, 258)
    $copy = GUICtrlCreateButton(">", 293, 378, 12)
    GUICtrlSetOnEvent(-1, "copy")
$BatchMode = GUICtrlCreateTabItem("Batch Mode") ; Batch Mode tab
    $reminder = GUICtrlCreateLabel("Choose a playlist or source:", 2, 19, 250, 16) 
    $ChoosePlaylist = GUICtrlCreateList("", 0, 34, 199, 280, BitOr($WS_BORDER, $WS_VSCROLL))
    GUICtrlSetOnEvent(-1, "UpdateMessage")
    If ProcessExists("itunes.exe") Then
        $iTunes = ObjCreate("iTunes.application") ; Create iTunes COM connection
        If IsObj($iTunes) Then ; If iTunes is up and running
            $sources = $iTunes.Sources
            For $i in $sources ; List all sources/playlists into the listview
                GUICtrlSetData(-1, $i.Name & "|")
                $playlists = $i.Playlists
                For $j in $playlists
                    If $j.name <> $i.name Then GUICtrlSetData(-1, "     " & $j.Name & "|")
                Next
            Next
        EndIf
    EndIf
    $SkipSongsWithLyrics = GUICtrlCreateCheckbox("Skip songs with lyrics", 2, 313) 
    GUICtrlSetState(-1, $GUI_CHECKED)
    $ArtistsToExclude = GUICtrlCreateInput("", 1, 343, 199)
    GUICtrlCreateLabel("Enter artists to exclude, seperated with a |", 1, 368)
    GUICtrlCreateLabel("IE 'band1|band2|band3'", 1, 383)
    $BatchApply = GUICtrlCreateButton("Get Lyrics", 2, 403, 90, 30)
    GUICtrlSetOnEvent(-1, "BatchApply")
    $SaveLog = GUICtrlCreateButton("Save Log", 100, 403, 90, 30)
    GUICtrlSetOnEvent(-1, "SaveLog")
    $BatchSave = GUICtrlCreateCombo("Apply to song", 1, 468, 210, -1, 0x0003)
    GUICtrlSetData(-1, "Save lyrics to file|Do both")
    $BatchChooseSite = GUICtrlCreateCombo("LyricsOnDemand.com", 1, 443, 157, -1, 0x0003)
    GUICtrlSetData(-1, "AZLyrics.com|Local files")
    GUICtrlCreateLabel("Status:", 220, 19, 100, 16)
    $BatchStatus = GUICtrlCreateEdit("", 220, 35, 379, 484, BitOr($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY))
    GUICtrlSetBkColor(-1, 0x00FFFFFF)
$ManualMode = GUICtrlCreateTabItem("Manual Mode") ; Manual Mode tab
    GUICtrlCreateLabel("Artist:", 1, 28, 100, 20)
    $ArtistEdit = GUICtrlCreateInput("", 1, 43, 375, 20)
    GUICtrlCreateLabel("Track Name:", 1, 78, 100, 20)
    $TrackEdit = GUICtrlCreateInput("", 1, 93, 375, 20)
    GUICtrlCreateGroup("Online lyrics", 400, 24, 198, 110)
        $GetLyrics = GUICtrlCreateButton("Get Lyrics", 405, 43, 75, 25)
        GUICtrlSetOnEvent(-1, "_GetLyrics")
        $ManualChooseSite = GUICtrlCreateCombo("AZLyrics.com", 405, 73, 157, -1, 0x0003)
        GUICtrlSetData(-1, "LyricsDir.com (beta)|LyricsOnDemand.com")
        $SaveLyrics = GUICtrlCreateButton("Save Lyrics", 405, 100, 95, 25)
        GUICtrlSetOnEvent(-1, "save")
        GUICtrlCreateLabel("Lyrics:", 1, 128)
        $ManualLyricsEdit = GUICtrlCreateEdit("", 1, 143, 598, 384)
GUICtrlCreateTabItem("")

$iTunesButton = GUICtrlCreatePic(@TempDir & "\iTunesMode.bmp", 4, 530, 81, 25)
    GUICtrlSetOnEvent(-1, "switchToiTunesMode")
$batchButton = GUICtrlCreatePic(@TempDir & "\batchMode.bmp", 91, 530, 77, 25)
    GUICtrlSetOnEvent(-1, "switchToBatchMode")
$manualButton = GUICtrlCreatePic(@TempDir & "\manualMode.bmp", 172, 530, 82, 25)
    GUICtrlSetOnEvent(-1, "switchToManualMode")

;This will help trap and troubleshoot errors
_IEErrorHandlerRegister()
If Not ProcessExists("itunes.exe") Then
    $iTunes = ""
    GUICtrlSetData($message, " Please reopen iDFree once iTunes is open for best functionality.")
    GUICtrlSetColor($message, 0xFF0000)
Else
    $iTunes = ObjCreate("iTunes.application")
    ;GUICtrlSetData($message, " iDFree by Ben Perkins of Magic Soft Inc. - www.magicsoftinc.com")
    GUICtrlSetData($message, " iDFree now has a new GUI, hope you like it!   -The Magician")
    GUICtrlSetColor($message, 0x2255FF)
    AdlibEnable("adlib", 1000)
EndIf
If Not IsObj($iTunes) Then
    _GUICtrlTab_SetCurFocus($tab, $ManualMode)
Else
    $OldVolume = $iTunes.SoundVolume
    GUICtrlSetData($volume, $OldVolume)
    $NowPlaying = $iTunes.CurrentTrack
    $iTunesEvent = ObjEvent($iTunes, "_Event_")
    ;If the object didn't create you don't want to enable the adlib
    AdlibEnable("adlib", 1000)
    adlib()
EndIf
GUISetState()

While 1
    If Not ProcessExists("itunes.exe") Then
        $iTunes = ""
    Else
        $iTunes = ObjCreate("iTunes.application")
    EndIf
    $msg = TrayGetMsg()
    If $msg = $TrayMenuAbout Then about()
    If $msg = $TrayMenuHelp Then help()
    If $msg = $TrayMenuExit Then _exit()
    sleep(50)
WEnd

Func switchToiTunesMode()
    _GUICtrlTab_SetCurFocus($tab, 0)
EndFunc

Func switchToBatchMode()
    _GUICtrlTab_SetCurFocus($tab, 1)
EndFunc

Func switchToManualMode()
    _GUICtrlTab_SetCurFocus($tab, 2)
EndFunc

Func UpdateMessage()
    $OldMessage = GUICtrlRead($message)
    $iTunes = ObjCreate("iTunes.application")
    $playlist = $iTunes.LibraryPlaylist
    $ChoosenPlaylist = GUICtrlRead($ChoosePlaylist)
    If $ChoosenPlaylist = "" Then Return
    $sources = $iTunes.sources
    $tracks = ""
    for $i in $sources
        If $i.name = $ChoosenPlaylist Then
            For $j in $i.playlists
                If $j.name = $i.name Then
                    $tracks = $j.tracks
                    $playlist = $j
                EndIf
            Next
        Else
            $subsource = $i.playlists
            for $j in $subsource
                If "     " & $j.name = $ChoosenPlaylist Then
                    $tracks = $j.tracks
                    $playlist = $j
                EndIf
            Next
        EndIf
    Next
    If Not IsObj($tracks) Then Return
    If $tracks.count = 1 Then
        $TrackOrTracks = " track in "
    Else
        $TrackOrTracks = " tracks in "
    EndIf
    GUICtrlSetData($message, " " & $tracks.count & $TrackOrTracks & $playlist.name)
    If $tracks.count > 700 Then
        $color = 0x00FF0000
    ElseIf $tracks.count < 100 Then
        $color = 0x0000FF00
    Else
        $color = 0x00FFFF00
    EndIf
    GUICtrlSetColor($message, $color)
EndFunc

Func _PrevTrack()
    $iTunes.BackTrack
EndFunc   ;==>_PrevTrack

Func _NextTrack()
    $iTunes.NextTrack
EndFunc   ;==>_NextTrack

Func _PlayPause()
    $iTunes.PlayPause
EndFunc   ;==>_PlayPause

Func _Stop()
    $iTunes.stop
EndFunc   ;==>_Stop

Func _mute()
    If IsObj($iTunes) Then
        If $iTunes.SoundVolume = 0 Then
            $iTunes.SoundVolume = $VolumeRead
        Else
            $VolumeRead = $iTunes.SoundVolume
            $iTunes.SoundVolume = 0
        EndIf
        ControlMove("iDFree", "", $volume, 485, 39, $iTunes.SoundVolume*1.1)
    Else
        If $VolumeRead = 0 Then
            $VolumeRead = 100
            SoundSetWaveVolume(100)
        Else
            $VolumeRead = 0
            SoundSetWaveVolume(0)
        EndIf
    EndIf
EndFunc

Func _volume()
    $win = WinGetPos("iDFree")
    $mouse = MouseGetPos()
    $VolumeRead = $win[0] + 485 + 110 - $mouse[0]
    $VolumeRead = Int(100 - $VolumeRead / 1.1)
    If $VolumeRead >= 98 Then $VolumeRead = 100
    If IsObj($iTunes) Then
        $iTunes.SoundVolume = $VolumeRead;GUICtrlRead($volume)
        ControlMove("iDFree", "", $volume, 485, 54, $iTunes.SoundVolume*1.1)
    Else
        ;SoundSetWaveVolume($VolumeRead)
        ControlMove("iDFree", "", $volume, 485, 89, $VolumeRead)
    EndIf
EndFunc

Func _SysVolume()
    $win = WinGetPos("iDFree")
    $mouse = MouseGetPos()
    $SysVolumeRead = $win[0] + 485 + 110 - $mouse[0]
    $SysVolumeRead = Int(100 - $SysVolumeRead / 1.1)
    If $SysVolumeRead >= 98 Then $SysVolumeRead = 100
    SoundSetWaveVolume($SysVolumeRead)
    ControlMove("iDFree", "", $SysVolume, 485, 89, $SysVolumeRead*1.1)
EndFunc

Func CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

Func _Event_OnCOMCallsDisabledEvent() ; When iTunes stops using COM
    AdlibDisable() ; Shut off everything that uses iTunes to avoid errors
    MsgBox(0x40030, "Error in communication!", "iTunes has disabled communication, you may have" & _ ; Display a message box stating the error
                @CR & "the 'Get info' window open, or be trying to close iTunes.")
EndFunc

Func _Event_OnCOMCallsEnabledEvent() ; When iTunes resumes COM usage
    AdlibEnable("adlib", 1000) ; Resume iTunes events
EndFunc

Func adlib() ; This function is called once a second
    $NowPlaying = $iTunes.CurrentTrack
    ; This will avoid errors when there is not a current track
    If Not IsObj($NowPlaying) Then Return ; If there is no track then don't continue
    $TrackName = $NowPlaying.name ; Get name
    $TrackArtist = $NowPlaying.artist ; artist
    $TrackAlbum = $NowPlaying.album ; and album
    ControlMove("iDFree", "", $volume, 485, 54, $iTunes.SoundVolume*1.1) ; Adjust volume slider..? Dunno why... it's been awhile since I've worked on this
    ControlMove("iDFree", "", $SysVolume, 485, 89, $SysVolumeRead*1.1) ; Ditto
    ; Grab track time/position
    $SongLength = $NowPlaying.time
    $CurrentTime = $iTunes.PlayerPosition
    $minute = int($CurrentTime/60) ; Minutes
    $second = mod($CurrentTime, 60) ; Mod gives a remainder, that's our seconds
    $SplitSecond = StringSplit($second, "") ; Split up the seconds to determine length
    If $SplitSecond[0] = 1 Then $second = "0" & $second ; if it's one digit, add a 0 (1 = 01, 2 = 02)
    $time = $minute & ":" & $second ; Put the time into a readable form
    $length = StringSplit($SongLength, ":") ; Split it up again to get song length... wow that was pointless, I'll make it more efficient... later
    $length = 60*$length[1]+$length[2]
    $Time2 = $length - $CurrentTime
    $minute = int($Time2/60)
    $second = mod($Time2, 60)
    $SplitSecond = StringSplit($second, "")
    If $SplitSecond[0] = 1 Then $second = "0" & $second
    $Time2 = "-" & $minute & ":" & $second
    ; Format track time/position
    If _GUICtrlTab_GetCurSel($tab) = 0 Then GUICtrlSetData($PositionLabel, $time)
    If $TimeFormat = 1 and _GUICtrlTab_GetCurSel($tab) = 0 Then GUICtrlSetData($TimeLabel, " " & $SongLength)
    If $TimeFormat <> 1 and _GUICtrlTab_GetCurSel($tab) = 0 Then GUICtrlSetData($TimeLabel, $Time2)
    $CurrentTime = $CurrentTime/($length/360)
    ;GUICtrlSetData($position, $CurrentTime)
    ControlMove("iDFree 2.2", "", $position, 5, 222, $CurrentTime, 15)
    If "Artist: " & $TrackArtist <> GUICtrlRead($artist) Then GUICtrlSetData($artist, "Artist: " & $TrackArtist)
    If "Album: " & $TrackAlbum <> GUICtrlRead($album) or "Title: " & $TrackName <> GUICtrlRead($name)  Then
        GUICtrlSetData($album, "Album: " & $TrackAlbum)
        If "Title: " & $TrackName <> GUICtrlRead($name) Then GUICtrlSetData($name, "Title: " & $TrackName)
        art()
    EndIf
    If "Title: " & $TrackName <> GUICtrlRead($name) Then GUICtrlSetData($name, "Title: " & $TrackName)
    $NowPlaying = $iTunes.CurrentTrack
    If GUICtrlRead($LyricsEdit) <> $NowPlaying.Lyrics Then GUICtrlSetData($LyricsEdit, $NowPlaying.Lyrics)
EndFunc

Func ChangeTimeFormat() ; Display track length or time remaining (I forget which is which)
    If $TimeFormat = 1 Then
        $TimeFormat = 0
    Else
        $TimeFormat = 1
    EndIf
    adlib()
EndFunc

Func ChangePos() ; If the slider is clicked, then adjust the song's timing
    $mouse = MouseGetPos() ; Get the mouse position
    $win = WinGetPos("iDFree 2.2") ; And window position
    $mouse[0]-=$win[0]+7 ; Do some fancy calculations to find where the mouse is
    $mouse[0] = $mouse[0] / 360 ; relative to the slider
    $SongLength = $NowPlaying.time ; Now calculate the time it needs to go to
    $length = StringSplit($SongLength, ":")
    $length = 60*$length[1]+$length[2]
    $pos = Round($length * $mouse[0])
    $iTunes.PlayerPosition = $pos ; Apply the time
    adlib() ; Update stats
EndFunc

Func copy()
    If GUICtrlRead($LyricsEdit) <> "" Then GUICtrlSetData($NewLyricsEdit, GUICtrlRead($LyricsEdit)) ; Apply updated lyrics
EndFunc

Func art() ; display current art
    GUICtrlSetTip($exit, "Close iDFree")
    GUICtrlSetTip($minimize, "Minimize iDFree")
    GUICtrlSetTip($maximize, "Maximize disabled")
    $window = WinGetPos("iDFree 2.2")
    $iTunes = ObjCreate("iTunes.application")
    If IsObj($iTunes) Then
        $NowPlaying = $iTunes.CurrentTrack
        $artwork = $NowPlaying.Artwork
        $lyrics = $NowPlaying.lyrics
        If $lyrics = 0 Then $lyrics = ""
        GUICtrlSetData($LyricsEdit, $lyrics)
        $count = 0
        For $art In $artwork
            If $art.format = 1 Then
                $art.SaveArtworkToFile(@TempDir & "\CurrentArt.jpg")
            ElseIf $art.format = 2 Then
                $art.SaveArtworkToFile(@TempDir & "\CurrentArt.png")
            EndIf
            $count+=1
        Next
        If $count <> 0 and $art.format = 1 Then ; If JPG art exists
            $ArtLocation = @TempDir & "\CurrentArt.jpg"
            GUICtrlSetCursor($AlbumArt, 0)
            GUICtrlSetOnEvent($AlbumArt, "DisplayArt")
            GUICtrlSetState($ArtLoad, $GUI_DISABLE)
            GUICtrlSetState($ArtSave, $GUI_ENABLE)
        ElseIf $count <> 0 and $art.format = 2000 Then ; If PNG art exists, doesn't work
            $ArtLocation = @TempDir & "\CurrentArt.png"
            GUICtrlSetCursor($AlbumArt, 0)
            GUICtrlSetOnEvent($AlbumArt, "DisplayArt")
        Else ; No art
            $ArtLocation = @TempDir & "\NoArt.bmp"
            GUICtrlSetCursor($AlbumArt, 2)
            GUICtrlSetOnEvent($AlbumArt, "")
            GUICtrlSetState($ArtSave, $GUI_DISABLE)
            GUICtrlSetState($ArtLoad, $GUI_ENABLE)
        EndIf
        GUICtrlSetImage($AlbumArt, $ArtLocation)
        GUICtrlSetTip($name, $NowPlaying.name)
        GUICtrlSetTip($artist, $NowPlaying.artist)
        GUICtrlSetTip($album, $NowPlaying.album)
    EndIf
    If IsArray($window) Then WinMove("iDFree 2.2", "", $window[0], $window[1], $window[2], $window[3]) ; Used to fix a RARE bug
                                                                                                ; Correction, this bug was TERMINATED!
EndFunc

Func DisplayArt() ; Create a GUI for the album art
    If $ArtLocation <> @TempDir & "\CurrentArt.jpg" Then Return 0
    $NowPlaying = $iTunes.CurrentTrack
    $TrackName = $NowPlaying.name
    $TrackAlbum = $NowPlaying.album
    $size = 1.5
    $ArtInfo = _ImageGetInfo(@TempDir & "\CurrentArt.jpg")
    $width = _ImageGetParam($ArtInfo, "Width")
    $height =  _ImageGetParam($ArtInfo, "Height")
    While $width >= @DesktopWidth or $height >= @DesktopHeight
        $width/=2
        $height/=2
    WEnd
    Opt("GUIEventOptions", 1)
    Opt("GUIOnEventMode", 0)
    Opt("GUIResizeMode", 102)
    If not Int($width) > 100 Then $width = 100 
    If not Int($height) > 100 Then $height = 100 
    $ArtGUI = GUICreate($TrackName & " (" & $TrackAlbum & ")", $width*1.5+5, $height*1.5+23, 10, 10, $WS_POPUP, -1)
    $rgn = CreateRoundRectRgn(0, 0, $width*1.5+4, $height*1.5+40, 9, 9)
    SetWindowRgn($ArtGUI, $rgn)
    GUISetBkColor(0xBBBBBB)
    GUICtrlCreatePic(@TempDir & "\title.bmp", 0, 0, $width*1.5+4, 18)
    GUICtrlSetResizing(-1, 768)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("'" & $TrackName & "'", 55, 4, $width*1.5-60, 17, $SS_CENTER)
    GUICtrlSetFont(-1, -1, 800)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateLabel("'" & $TrackName & "'", 54, 3, $width*1.5-60, 17, $SS_CENTER)
    GUICtrlSetFont(-1, -1, 800)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $ArtExit = GUICtrlCreatePic(@TempDir & "\exit.bmp", 5, 2, 0, 0)
    GUICtrlSetResizing(-1,544)
    $ArtMinimize = GUICtrlCreatePic(@TempDir & "\minimize.bmp", 22, 2, 0, 0)
    GUICtrlSetResizing(-1, 102)
    $ArtMaximize = GUICtrlCreatePic(@TempDir & "\maximize.bmp", 39, 2, 0, 0)
    GUICtrlSetResizing(-1, 102)
    GUICtrlCreatePic(@TempDir & "\CurrentArt.jpg", 2, 20, $width*1.5, $height*1.5)
    GUICtrlSetResizing(-1, 102)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        $tMsg = TrayGetMsg()
        If $msg = $ArtExit Then ExitLoop
        If $msg = $ArtMinimize Then GUISetState(@SW_MINIMIZE)
        If $msg = $GUI_EVENT_MINIMIZE Then GUISetState(@SW_MINIMIZE)
        If $msg = $GUI_EVENT_RESTORE Then GUISetState(@SW_RESTORE)
        if $tMsg = $TrayMenuExit Then _exit()
        ;If $msg = $ArtMaximize Then
        ;   If $size = 1 Then
        ;       $size = 1.5
        ;       WinMove($TrackName & " (" & $TrackAlbum & ")", "", Default, Default, $width*1.5+4, $height*1.5+25)
        ;   Else
        ;       $size = 1
        ;       WinMove($TrackName & " (" & $TrackAlbum & ")", "", Default, Default, $width+4, $height+25)
        ;   EndIf
        ;EndIf
    WEnd
    GUIDelete()
    Opt("GUIEventOptions", 0)
    Opt("GUIOnEventMode", 1)
    Opt("GUIResizeMode", 0)
EndFunc

Func SetLyrics()
    If IsObj($iTunes) Then
        If GUICtrlRead($NewLyricsEdit) = "" or GUICtrlRead($NewLyricsEdit) = "Could not find lyrics" or GUICtrlRead($NewLyricsEdit) = "Could not connect" Then
            If MsgBox(36, "No lyrics entered!", "Remove lyrics?") = 6 Then
                $CurrentTrack = $iTunes.CurrentTrack
                $CurrentTrack.lyrics = ""
                GUICtrlSetData($LyricsEdit, "")
            EndIf
        Else
            $CurrentTrack = $iTunes.CurrentTrack
            $CurrentTrack.lyrics = GUICtrlRead($NewLyricsEdit) & @CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
            MsgBox(0, "Success!", "Lyrics have been successfully changed!")
        EndIf
    EndIf
EndFunc   ;==>SetLyrics

Func AZGetLyrics($artist, $song, $edit)
    $URLName = StringReplace(StringLower($song), " ", "")
    $URLArtist = StringReplace(StringLower($artist), " ", "")
    $URLName = StringReplace($URLName, "'", "")
    $URLName = StringReplace($URLName, "/", "")
    $URLName = StringReplace($URLName, ",", "")
    $URLName = StringReplace($URLName, ".", "")
    $URLName = StringReplace($URLName, "-", "")
    $URLName = StringReplace($URLName, "#", "")
    $URLName = StringReplace($URLName, '"', "")
    $URL = "http://www.azlyrics.com/lyrics/" & $URLArtist & "/" & $URLName & ".html"
    $lyrics = _INetGetSource($URL)
    If Not @error Then
        If StringInStr($lyrics, "<TITLE>A-Z Lyrics Universe</TITLE>") Then
            GUICtrlSetData($edit, "Could not find lyrics")
        Else
            $lyrics = StringSplit($lyrics, "<FONT size=2>", 1)
            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
            $lyrics = StringSplit($lyrics, "[", 1)
            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
            $lyrics = StringReplace($lyrics, "<br>", @CRLF)
            $lyrics = StringReplace($lyrics, @LF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF, @LF)
            $lyrics = StringReplace($lyrics, 'h1', "")
            $lyrics = StringReplace($lyrics, '/', "")
            $lyrics = StringReplace($lyrics, '\', "")
            $lyrics = StringReplace($lyrics, "<br>", "")
            $lyrics = StringReplace($lyrics, "<br/>", "")
            $lyrics = StringReplace($lyrics, "<br\>", "")
            $lyrics = StringReplace($lyrics, "<br \>", "")
            $lyrics = StringReplace($lyrics, "<br />", "")
            $lyrics = StringReplace($lyrics, """, "")
            $lyrics = StringReplace($lyrics, "<i>", "")
            $lyrics = StringReplace($lyrics, "</i>", "")
            $lyrics = StringReplace($lyrics, "<b>", "")
            $lyrics = StringReplace($lyrics, "</b>", "")
            $lyrics = StringReplace($lyrics, "<u>", "")
            $lyrics = StringReplace($lyrics, "</u>", "")
            $lyrics = StringReplace($lyrics, '">', "")
            $lyrics = StringReplace($lyrics, '>', "")
            $lyrics = StringReplace($lyrics, '<"', "")
            $lyrics = StringReplace($lyrics, '<', "")
            $lyrics = StringStripWS($lyrics, 3)
            $lyrics&=@CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
            GUICtrlSetData($edit, $lyrics)
        EndIf
    Else
        GUICtrlSetData($edit, "Could not connect")
    EndIf
EndFunc   ;==>AZGetLyrics

Func LyricsDirLyrics($artist, $song, $edit)
    ;http://www.lyricsdir.com/streetlight-manifesto-as-the-footsteps-die-out-forever-lyrics.html
    $URLName = StringReplace(stringlower($song), " ", "-")
    $URLArtist = StringReplace(stringlower($artist), " ", "-")
    $URLName = StringReplace($URLName, "'", "")
    $URLName = StringReplace($URLName, "/", "")
    $URLName = StringReplace($URLName, ",", "")
    $URLName = StringReplace($URLName, ".", "")
    $URLName = StringReplace($URLName, "#", "")
    $URLName = StringReplace($URLName, '"', "")
    $URLName = StringReplace($URLName, '!', "")
    $URLName = StringReplace($URLName, '?', "")
    $URLName = StringReplace($URLName, '-', "")
    $URLName = StringReplace($URLName, '.', "")
    $URL = "http://www.lyricsdir.com/" & $URLArtist & "-" & $URLName & ".html"
    MsgBox(0, "", $URL)
    $lyrics = _INetGetSource($URL)
    If Not @error Then
        If StringInStr($lyrics, "http://www.lyricsdir.com/img/lyricsdir.gif") Then
            GUICtrlSetData($edit, "Could not find lyrics")
        Else
            $lyrics = StringSplit($lyrics, '<div id="lyrics', 1)
            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
            $lyrics = StringSplit($lyrics, "</div>", 1)
            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
            $lyrics = StringReplace($lyrics, "<br>", @CRLF)
            $lyrics = StringReplace($lyrics, @LF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF, @LF)
            $lyrics = StringReplace($lyrics, 'h1', "")
            $lyrics = StringReplace($lyrics, ' /', "")
            $lyrics = StringReplace($lyrics, ' \', "")
            $lyrics = StringReplace($lyrics, "<br>", "")
            $lyrics = StringReplace($lyrics, "<br/>", "")
            $lyrics = StringReplace($lyrics, "<br\>", "")
            $lyrics = StringReplace($lyrics, "<\ br>", "")
            $lyrics = StringReplace($lyrics, "<br \>", "")
            $lyrics = StringReplace($lyrics, "</ br>", "")
            $lyrics = StringReplace($lyrics, "<br />", "")
            $lyrics = StringReplace($lyrics, """, "")
            $lyrics = StringReplace($lyrics, "<i>", "")
            $lyrics = StringReplace($lyrics, "</i>", "")
            $lyrics = StringReplace($lyrics, "<b>", "")
            $lyrics = StringReplace($lyrics, "</b>", "")
            $lyrics = StringReplace($lyrics, "<u>", "")
            $lyrics = StringReplace($lyrics, "</u>", "")
            $lyrics = StringReplace($lyrics, '">', "")
            $lyrics = StringReplace($lyrics, '>', "")
            $lyrics = StringReplace($lyrics, '<"', "")
            $lyrics = StringReplace($lyrics, '<', "")
            $lyrics = StringStripWS($lyrics, 3)
            $lyrics&=@CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
            GUICtrlSetData($edit, $lyrics)
        EndIf
    Else
        GUICtrlSetData($edit, "Could not connect")
    EndIf
EndFunc   ;==>LyricsDirLyrics

Func ODGetLyrics($artist, $song, $edit)
    $URLName = StringReplace(StringLower($song), " ", "")
    $URLArtist = StringReplace(StringLower($artist), " ", "")
    $URLName = StringReplace($URLName, "'", "")
    $URLName = StringReplace($URLName, "/", "")
    $URLName = StringReplace($URLName, ",", "")
    $URLName = StringReplace($URLName, ".", "")
    $URLName = StringReplace($URLName, "-", "")
    $URLName = StringReplace($URLName, "#", "")
    $URLName = StringReplace($URLName, '"', "")
    $URLName = StringReplace($URLName, '?', "")
    $URLName = StringReplace($URLName, '!', "")
    $URLName&="lyrics"
    $URLArtist&="lyrics"
    $SplitArtist = StringSplit($URLArtist, "")
    $URL = "http://www.lyricsondemand.com/" & $SplitArtist[1] & "/" & $URLArtist & "/" & $URLName & ".html"
    $lyrics = _INetGetSource($URL)
    If Not @error Then
        If StringInStr($lyrics, "File Not Found") Then
            GUICtrlSetData($edit, "Could not find lyrics")
        Else
            $lyrics = StringSplit($lyrics, '<font size="2" face="Verdana">', 1)
            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
            $lyrics = StringSplit($lyrics, " ", 1)
            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
            $lyrics = StringSplit($lyrics, "<script language", 1)
            If IsArray($lyrics) Then $lyrics = $lyrics[1]
            $lyrics = StringReplace($lyrics, "<br>", @CRLF)
            $lyrics = StringReplace($lyrics, @LF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
            $lyrics = StringReplace($lyrics, @CRLF, @LF)            
            $lyrics = StringReplace($lyrics, 'h1', "")
            $lyrics = StringReplace($lyrics, '/', "")
            $lyrics = StringReplace($lyrics, '\', "")
            $lyrics = StringReplace($lyrics, "<p>", "")
            $lyrics = StringReplace($lyrics, "<P/>", "")
            $lyrics = StringReplace($lyrics, "<P\>", "")
            $lyrics = StringReplace($lyrics, "<P \>", "")
            $lyrics = StringReplace($lyrics, "<P />", "")
            $lyrics = StringReplace($lyrics, "<br>", "")
            $lyrics = StringReplace($lyrics, "<br/>", "")
            $lyrics = StringReplace($lyrics, "<br\>", "")
            $lyrics = StringReplace($lyrics, "<br \>", "")
            $lyrics = StringReplace($lyrics, "<br />", "")
            $lyrics = StringReplace($lyrics, """, "")
            $lyrics = StringReplace($lyrics, "<i>", "")
            $lyrics = StringReplace($lyrics, "</i>", "")
            $lyrics = StringReplace($lyrics, "<b>", "")
            $lyrics = StringReplace($lyrics, "</b>", "")
            $lyrics = StringReplace($lyrics, "<u>", "")
            $lyrics = StringReplace($lyrics, "</u>", "")
            $lyrics = StringReplace($lyrics, '">', "")
            $lyrics = StringReplace($lyrics, '>', "")
            $lyrics = StringReplace($lyrics, '<"', "")
            $lyrics = StringReplace($lyrics, '<', "")
            $lyrics = StringStripWS($lyrics, 3)
            GUICtrlSetData($edit, $lyrics)
            If StringStripWS(GUICtrlRead($edit), 3) == "" Then GUICtrlSetData($edit, "Could not find lyrics")
        EndIf
    Else
        GUICtrlSetData($edit, "Could not connect")
    EndIf
EndFunc   ;==>ODGetLyrics

Func SaveLog()
    If GUICtrlRead($BatchStatus) <> "" Then FileWrite(FileSaveDialog("Save your log file", @DesktopDir, "Text files (*.txt)|All files (*.*)", 16), GUICtrlRead($BatchStatus))
EndFunc

Func BatchApply() ; Handles batch apply
    $folder = ""
    GUICtrlSetData($BatchStatus, "")
    If GUICtrlRead($BatchSave) = "Apply to song" Then
        $mode = 0
    ElseIf GUICtrlRead($BatchSave) = "Save lyrics to file" Then
        $mode = 1
    Else 
        $mode = 2
    EndIf
    If $mode <> 0 Then
        $folder = FileSelectFolder("A 'lyrics' folder should be made in which directory?", @DesktopDir, 7, @MyDocumentsDir & "\My Music")
        If Not FileExists($folder & "\lyrics\") Then
            DirCreate($folder & "\lyrics\")
            GUICtrlSetData($BatchStatus, "Creating folder 'lyrics'" & @CRLF)
            sleep(250)
        EndIf
    EndIf
    $ExcludeArtists = GUICtrlRead($ArtistsToExclude)
    If $ExcludeArtists <> "" Then
        $ExcludeArtists = StringSplit($ExcludeArtists, "|")
        If IsArray($ExcludeArtists) Then
            For $i = 1 to $ExcludeArtists[0]
                $ExcludeArtists[$i] = StringStripWS($ExcludeArtists[$i], 1)
            Next
            $ShouldExcludeArtists = 1
        Else
            $ExcludeArtists[0] = 1
            $ExcludeArtists[1] = GUICtrlRead($ArtistsToExclude)
            $ShouldExcludeArtists = 1
        EndIf
    Else
        $ShouldExcludeArtists = 0
    EndIf
    $iTunes = ObjCreate("iTunes.application")
    $playlist = $iTunes.LibraryPlaylist
    $ChoosenPlaylist = GUICtrlRead($ChoosePlaylist)
    If $ChoosenPlaylist = "" Then
        GUICtrlSetColor($reminder, 0xFF0000)
        Return
    Else
        GUICtrlSetColor($reminder, 0x000000)
    EndIf
    $timer = TimerInit()
    $sources = $iTunes.sources
    $tracks = ""
    for $i in $sources ; Retrieve selected playlist
        If $i.name = $ChoosenPlaylist Then
            For $j in $i.playlists
                If $j.name = $i.name Then
                    $tracks = $j.tracks
                    $playlist = $j
                EndIf
            Next
        Else
            $subsource = $i.playlists
            for $j in $subsource
                If "     " & $j.name = $ChoosenPlaylist Then
                    $tracks = $j.tracks
                    $playlist = $j
                EndIf
            Next
        EndIf
    Next
    If GUICtrlRead($BatchChooseSite) = "Local files" Then
        $directory = FileSelectFolder("Where are the lyrics stored?", @DesktopDir, 7, @DesktopDir)
        If $directory = "" Then Return
    EndIf
    GUICtrlSetState($BatchStatus, $GUI_DISABLE)
    $count = 0
    For $track in $tracks ; Repeats this process for every song in that playlist\
        $count+=1
        GUICtrlSetData($message, " Song " & $count & " of " & $tracks.count) ; Updates the label at the bottom
        GUICtrlSetColor($message, 0x00FF00FF) ; Makes sure the color is right
        $SkipSong = 0
        Opt("GUIOnEventMode", 0)
        $msg = GUIGetMsg()
        $TrayMsg = TrayGetMsg()
        If $TrayMsg = $TrayMenuAbout Then about()
        If $TrayMsg = $TrayMenuHelp Then help()
        If $msg = $GUI_EVENT_CLOSE or $TrayMsg = $TrayMenuExit Then
            If MsgBox(0x134, "Quit NOW?!", "Are you SURE you want to quit while iDFree is still getting lyrics?") = 6 Then _Exit()
        EndIf
        If GUICtrlRead($SkipSongsWithLyrics) = 1 and $track.lyrics <> "" and $track.lyrics <> " " Then
            GUICtrlSetData($BatchStatus, $track.name & " already has lyrics." & @CRLF, "append")
        Else
            If $ShouldExcludeArtists = 1 Then
                For $i = 1 to $ExcludeArtists[0]
                    If $track.artist = $ExcludeArtists[$i] Then
                        GUICtrlSetData($BatchStatus, "Skipping " & $track.name & " by " & $track.artist & @CRLF, "append")
                        $SkipSong = 1
                    EndIf
                Next
            EndIf
            If $SkipSong <> 1 Then
                Global $BatchTrackName = $track.name
                Global $BatchTrackArtist = $track.artist
                If GUICtrlRead($BatchChooseSite) = "AZLyrics.com" Then ; Batch AZ lyrics
                    GUICtrlSetData($BatchStatus, $track.name & "...connecting...", "append")
                    $URLName = StringReplace(StringLower($track.name), " ", "")
                    $URLArtist = StringReplace(StringLower($track.artist), " ", "")
                    $URLName = StringReplace($URLName, "'", "")
                    $URLName = StringReplace($URLName, "/", "")
                    $URLName = StringReplace($URLName, ",", "")
                    $URLName = StringReplace($URLName, ".", "")
                    $URLName = StringReplace($URLName, "-", "")
                    $URLName = StringReplace($URLName, "#", "")
                    $URLName = StringReplace($URLName, '"', "")
                    $URL = "http://www.azlyrics.com/lyrics/" & $URLArtist & "/" & $URLName & ".html"
                    $lyrics = _INetGetSource($URL)
                    If Not @error Then
                        If StringInStr($lyrics, "<TITLE>A-Z Lyrics Universe</TITLE>") Then
                            GUICtrlSetData($BatchStatus, "searching...", "append")
                            GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                        Else
                            GUICtrlSetData($BatchStatus, "searching...", "append")
                            $lyrics = StringSplit($lyrics, "<FONT size=2>", 1)
                            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
                            $lyrics = StringSplit($lyrics, "[", 1)
                            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
                            $lyrics = StringReplace($lyrics, "<br>", "")
                            $lyrics = StringReplace($lyrics, "<i>", "")
                            $lyrics = StringReplace($lyrics, "</i>", "")
                            $lyrics = StringReplace($lyrics, "<b>", "")
                            $lyrics = StringReplace($lyrics, "</b>", "")
                            $lyrics = StringReplace($lyrics, "<u>", "")
                            $lyrics = StringReplace($lyrics, "</u>", "")
                            $lyrics = StringStripWS($lyrics, 3)
                            If $mode <> 1 Then
                                GUICtrlSetData($BatchStatus, "applying...", "append")
                                $track.lyrics = $lyrics
                                If $track.lyrics <> $lyrics Then
                                    GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                            If $mode <> 0 Then
                                GUICtrlSetData($BatchStatus, "saving...", "append")
                                If FileWrite($folder & "\lyrics\" & $track.artist & " - " & $track.name & ".txt", $lyrics) = 0 Then
                                    GUICtrlSetData($BatchStatus, "error", "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                        EndIf
                    Else
                        GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                    EndIf                   
                ElseIf GUICtrlRead($BatchChooseSite) = "LyricsOnDemand.com" Then ; Batch OD lyrics
                    GUICtrlSetData($BatchStatus, $track.name & "...connecting...", "append")
                    $URLName = StringReplace(StringLower($track.name), " ", "")
                    $URLArtist = StringReplace(StringLower($track.artist), " ", "")
                    $URLName = StringReplace($URLName, "'", "")
                    $URLName = StringReplace($URLName, "/", "")
                    $URLName = StringReplace($URLName, ",", "")
                    $URLName = StringReplace($URLName, ".", "")
                    $URLName = StringReplace($URLName, "-", "")
                    $URLName = StringReplace($URLName, "#", "")
                    $URLName = StringReplace($URLName, '"', "")
                    $URLName&="lyrics"
                    $URLArtist&="lyrics"
                    $SplitArtist = StringSplit($URLArtist, "")
                    $URL = "http://www.lyricsondemand.com/" & $SplitArtist[1] & "/" & $URLArtist & "/" & $URLName & ".html"
                    $lyrics = _INetGetSource($URL)
                    If Not @error Then
                        If StringInStr($lyrics, "File Not Found") Then
                            GUICtrlSetData($BatchStatus, "searching...", "append")
                            GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                        Else
                            GUICtrlSetData($BatchStatus, "searching...", "append")
                            $lyrics = StringSplit($lyrics, '<font size="2" face="Verdana">', 1)
                            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
                            $lyrics = StringSplit($lyrics, " ", 1)
                            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
                            $lyrics = StringSplit($lyrics, "<script language", 1)
                            If IsArray($lyrics) Then $lyrics = $lyrics[1]
                            $lyrics = StringReplace($lyrics, "<br>", @CRLF)
                            $lyrics = StringReplace($lyrics, @LF, @CRLF)
                            $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
                            $lyrics = StringReplace($lyrics, @CRLF, @LF)
                            $lyrics = StringReplace($lyrics, 'h1', "")
                            $lyrics = StringReplace($lyrics, ' /', "")
                            $lyrics = StringReplace($lyrics, ' \', "")
                            $lyrics = StringReplace($lyrics, "<br>", "")
                            $lyrics = StringReplace($lyrics, "<br/>", "")
                            $lyrics = StringReplace($lyrics, "<br\>", "")
                            $lyrics = StringReplace($lyrics, "<\ br>", "")
                            $lyrics = StringReplace($lyrics, "<br \>", "")
                            $lyrics = StringReplace($lyrics, "</ br>", "")
                            $lyrics = StringReplace($lyrics, "<br />", "")
                            $lyrics = StringReplace($lyrics, """, "")
                            $lyrics = StringReplace($lyrics, "<i>", "")
                            $lyrics = StringReplace($lyrics, "</i>", "")
                            $lyrics = StringReplace($lyrics, "<b>", "")
                            $lyrics = StringReplace($lyrics, "</b>", "")
                            $lyrics = StringReplace($lyrics, "<u>", "")
                            $lyrics = StringReplace($lyrics, "</u>", "")
                            $lyrics = StringReplace($lyrics, '">', "")
                            $lyrics = StringReplace($lyrics, '>', "")
                            $lyrics = StringReplace($lyrics, '<"', "")
                            $lyrics = StringReplace($lyrics, '<', "")
                            $lyrics = StringStripWS($lyrics, 3)
                            $lyrics&=@CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
                            If $mode <> 1 Then
                                GUICtrlSetData($BatchStatus, "applying...", "append")
                                $track.lyrics = $lyrics
                                If $track.lyrics <> $lyrics Then
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append") ; Yeah, this /should/ be error, but that'll
                                                                                               ; never happen and was causing bugs
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                            If $mode <> 0 Then
                                GUICtrlSetData($BatchStatus, "saving...", "append")
                                If FileWrite($folder & "\lyrics\" & $track.artist & " - " & $track.name & ".txt", $lyrics) = 0 Then
                                    GUICtrlSetData($BatchStatus, "error", "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                        EndIf
                    Else
                        GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                    EndIf
                ElseIf GUICtrlRead($BatchChooseSite) = "LyricsDir.com (beta)" Then ; LyricsDir.com
                    ;http://www.lyricsdir.com/streetlight-manifesto-as-the-footsteps-die-out-forever-lyrics.html
                    $URLName = StringReplace(stringlower($song), " ", "-")
                    $URLArtist = StringReplace(stringlower($artist), " ", "-")
                    $URLName = StringReplace($URLName, "'", "")
                    $URLName = StringReplace($URLName, "/", "")
                    $URLName = StringReplace($URLName, ",", "")
                    $URLName = StringReplace($URLName, ".", "")
                    $URLName = StringReplace($URLName, "#", "")
                    $URLName = StringReplace($URLName, '"', "")
                    $URL = "http://www.lyricsdir.com/" & $URLArtist & "-" & $URLName & ".html"
                    $lyrics = _INetGetSource($URL)
                    If Not @error Then
                        If StringInStr($lyrics, "http://www.lyricsdir.com/img/lyricsdir.gif") Then
                            GUICtrlSetData($edit, "Could not find lyrics")
                        Else
                            $lyrics = StringSplit($lyrics, '<div id="lyrics', 1)
                            If IsArray($lyrics) and $lyrics[0] >= 2 Then $lyrics = $lyrics[2]
                            $lyrics = StringSplit($lyrics, "</div>", 1)
                            If IsArray($lyrics) and $lyrics[0] >= 1 Then $lyrics = $lyrics[1]
                                        $lyrics = StringReplace($lyrics, "<br>", @CRLF)
                                        $lyrics = StringReplace($lyrics, @LF, @CRLF)
                                        $lyrics = StringReplace($lyrics, @CRLF & @CRLF, @CRLF)
                                        $lyrics = StringReplace($lyrics, @CRLF, @LF)
                                        $lyrics = StringReplace($lyrics, 'h1', "")
                                        $lyrics = StringReplace($lyrics, ' /', "")
                                        $lyrics = StringReplace($lyrics, ' \', "")
                                        $lyrics = StringReplace($lyrics, "<br>", "")
                                        $lyrics = StringReplace($lyrics, "<br/>", "")
                                        $lyrics = StringReplace($lyrics, "<br\>", "")
                                        $lyrics = StringReplace($lyrics, "<\ br>", "")
                                        $lyrics = StringReplace($lyrics, "<br \>", "")
                                        $lyrics = StringReplace($lyrics, "</ br>", "")
                                        $lyrics = StringReplace($lyrics, "<br />", "")
                                        $lyrics = StringReplace($lyrics, """, "")
                                        $lyrics = StringReplace($lyrics, "<i>", "")
                                        $lyrics = StringReplace($lyrics, "</i>", "")
                                        $lyrics = StringReplace($lyrics, "<b>", "")
                                        $lyrics = StringReplace($lyrics, "</b>", "")
                                        $lyrics = StringReplace($lyrics, "<u>", "")
                                        $lyrics = StringReplace($lyrics, "</u>", "")
                                        $lyrics = StringReplace($lyrics, '">', "")
                                        $lyrics = StringReplace($lyrics, '>', "")
                                        $lyrics = StringReplace($lyrics, '<"', "")
                                        $lyrics = StringReplace($lyrics, '<', "")
                            $lyrics = StringStripWS($lyrics, 3)
                            $lyrics&=@CRLF & @CRLF & "Lyrics from iDFree by Magic Soft Inc." & @CRLF & "www.magicsoftinc.com"
                            GUICtrlSetData($edit, $lyrics)
                        EndIf
                    Else
                        GUICtrlSetData($edit, "Could not connect")
                    EndIf
                Else ; Local files
                    $file = $directory & "\" & $track.artist & " - " & $track.name & ".txt"
                    GUICtrlSetData($BatchStatus, $BatchTrackName & "...locating file...", "append")
                    If Not @error Then
                        If Not FileExists($file) Then
                            GUICtrlSetData($BatchStatus, "opening...", "append")
                            GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                        Else
                            GUICtrlSetData($BatchStatus, "opening...", "append")
                            $lyrics = FileRead($file)
                            If $mode <> 1 Then
                                GUICtrlSetData($BatchStatus, "applying...", "append")
                                $track.lyrics = $lyrics
                                If $track.lyrics <> $lyrics Then
                                    GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                            If $mode <> 0 Then
                                GUICtrlSetData($BatchStatus, "saving...", "append")

                                If FileWrite($folder & "\lyrics\" & $track.artist & " - " & $track.name & ".txt", $lyrics) = 0 Then
                                    GUICtrlSetData($BatchStatus, "error", "append")
                                Else
                                    GUICtrlSetData($BatchStatus, "success!" & @CRLF, "append")
                                EndIf
                            EndIf
                        EndIf
                    Else
                        GUICtrlSetData($BatchStatus, "error" & @CRLF, "append")
                    EndIf           
                EndIf
            EndIf
        EndIf
    Next
    $timer = TimerDiff($timer)
    $timer = Round($timer/1000)
    $seconds = Round(mod($timer, 60))
    $seconds+=1
    If $seconds < 10 Then $seconds = "0" & $seconds
    $timer = Floor($timer/60) & ":" & $seconds
    GUICtrlSetData($BatchStatus, @CRLF & "Time: " & $timer, "append")
    GUICtrlSetData($message, " Finished! (" & $timer & ")") ; Updates the label at the bottom
    GUICtrlSetColor($message, 0x0000AA44) ; Makes sure the color is right
    Opt("GUIOnEventMode", 1)
    GUICtrlSetState($BatchStatus, $GUI_ENABLE)
EndFunc 

Func save() ; Save lyrics to text file
    $RecommendedName = GUICtrlRead($ArtistEdit) & " - " & GUICtrlRead($TrackEdit) & ".txt"
    $SaveFile = FileSaveDialog("Save Your Lyrics", @MyDocumentsDir, "Text Files (*.txt)|All Files (*.*)", 16, $RecommendedName)
    FileWrite($SaveFile, GUICtrlRead($LyricsEdit))
EndFunc

Func _GetLyrics()
    If _GUICtrlTab_GetCurSel($tab) = 0 Then ; iTunes mode
        $iTunes = ObjCreate("iTunes.application")
        $CurrentTrack = $iTunes.CurrentTrack
        If GUICtrlRead($ChooseSite) = "AZLyrics.com" Then
            AZGetLyrics($CurrentTrack.artist, $CurrentTrack.name, $NewLyricsEdit)
        ElseIf GUICtrlRead($ChooseSite) = "LyricsDir.com (beta)" Then
            LyricsDirLyrics($CurrentTrack.artist, $CurrentTrack.name, $NewLyricsEdit)
        Else
            ODGetLyrics($CurrentTrack.artist, $CurrentTrack.name, $NewLyricsEdit)
        EndIf
    ElseIf _GUICtrlTab_GetCurSel($tab) = 1 Then ; Batch mode
        Return 0
    Else
        If GUICtrlRead($ManualChooseSite) = "AZLyrics.com" Then ; Manual mode
            AZGetLyrics(GUICtrlRead($ArtistEdit), GUICtrlRead($TrackEdit), $ManualLyricsEdit)
        ElseIf GUICtrlRead($ManualChooseSite) = "LyricsDir.com (beta)" Then
            LyricsDirLyrics(GUICtrlRead($ArtistEdit), GUICtrlRead($TrackEdit), $ManualLyricsEdit)
        Else
            ODGetLyrics(GUICtrlRead($ArtistEdit), GUICtrlRead($TrackEdit), $ManualLyricsEdit)
        EndIf
    EndIf
EndFunc   ;==>_GetLyrics

Func SaveArt()
    $iTunes = ObjCreate("iTunes.application")
    If IsObj($iTunes) Then $NowPlaying = $iTunes.CurrentTrack
    If Not IsObj($NowPlaying) Then Return
    $SaveDir = FileSaveDialog("Save album art for '" & $NowPlaying.album & "'", @DesktopDir, "JPEG (*.jpg;*.jpeg)", 18, $NowPlaying.Album & " art.jpg")
    If $SaveDir <> "" Then
        $NowArt = $NowPlaying.artwork
        For $art in $NowArt
            $art.SaveArtworkToFile($SaveDir)
            ExitLoop
        Next
    EndIf
EndFunc

Func LoadArt()
    $iTunes = ObjCreate("iTunes.application")
    If IsObj($iTunes) Then $NowPlaying = $iTunes.CurrentTrack
    If Not IsObj($NowPlaying) Then Return
    $LoadDir = FileOpenDialog("Choose album art for '" & $NowPlaying.album & "'", @DesktopDir, "JPEG (*.jpg;*.jpeg)", 18)
    If $LoadDir <> "" Then
        $NowPlaying.AddArtworkFromFile($LoadDir)
        art()
    EndIf
EndFunc

Func GoToMSI()
    _IECreate("http://www.magicsoftinc.com")
EndFunc

Func move()
    Opt("WinTitleMatchMode", 4)
    $bar = WinGetPos("classname=Shell_TrayWnd")
    $win = WinGetPos("iDFree 2.2")
    $mouse = MouseGetPos()
    $XOff = $mouse[0] - $win[0]
    $YOff = $mouse[1] - $win[1]
    While _IsPressed(01)
        $mouse = MouseGetPos()
        $win = WinGetPos("iDFree 2.2")
        If $XOff - $mouse[0] < 0 Then
            If $mouse[1] + $win[3] + $bar[3] < @DesktopHeight Then
                WinMove("iDFree 2.2", "", $mouse[0] - $XOff, $mouse[1] - $YOff)
            Else
                WinMove("iDFree 2.2", "", $mouse[0] - $XOff, @DesktopHeight - $win[3] - $bar[3])
            EndIf
        Else
            If $mouse[1] + $win[3] + $bar[3] < @DesktopHeight Then
                WinMove("iDFree 2.2", "", 0, $mouse[1] - $YOff)
            Else
                WinMove("iDFree 2.2", "", 0, @DesktopHeight - $win[3] - $bar[3])
            EndIf
        EndIf
    WEnd
    If $win[1] < 0 Then WinMove("iDFree 2.2", "", $mouse[0] - $XOff, 0)
EndFunc

Func MinimizeButton()
    ;GUICtrlSetImage($minimize, @TempDir & "\minimize bright.bmp", -1)
    _minimize()
    ;GUICtrlSetImage($minimize, @TempDir & "\minimize.bmp")
EndFunc 

Func ExitButton()
    ;GUICtrlSetImage($exit, @TempDir & "\exit bright.bmp")
    _exit()
    ;GUICtrlSetImage($exit, @TempDir & "\exit.bmp")
EndFunc 

Func _minimize()
    Opt("TrayIconHide", 0)
    GUISetState(@SW_MINIMIZE)
EndFunc 

Func _exit()
    Opt("TrayIconHide", 1)
    FileDelete(@TempDir & "\about.gif")
    FileDelete(@TempDir & "\bg.gif")
    FileDelete(@TempDir & "\empty.bmp")
    FileDelete(@TempDir & "\slider.bmp")
    FileDelete(@TempDir & "\title.bmp")
    FileDelete(@TempDir & "\close.bmp")
    FileDelete(@TempDir & "\minimize.bmp")
    FileDelete(@TempDir & "\title.bmp")
    Exit
EndFunc

edit info.au3

#include <GUIConstants.au3>
#include-once

Func EditInfo()
    Global $iTunes = ObjCreate("iTunes.application")
    Global $track = $iTunes.CurrentTrack
    $TrackName = $track.name
    $TrackLength = $track.time
    $TrackArtist = $track.artist
    $TrackAlbum = $track.album
    $TrackNumber = $track.TrackNumber
    $TracksOnAlbum = $track.TrackCount
    $TrackComposer = $track.composer
        If $TrackComposer = '0' Then $TrackComposer = ""
    $TrackYear = $track.year
    $TrackGenre = $track.genre
    $TrackComments = $track.comment
        If $TrackComments = '0' Then $TrackComments = ""
    $TrackLyrics = $track.lyrics
        If $TrackLyrics = '0' Then $TrackLyrics = ""
    $TrackPlayCount = $track.PlayedCount
    $TrackPlayDate = $track.PlayedDate
        $x = StringSplit($TrackPlayDate, "")
        $TrackPlayDate = $x[5] & $x[6] & "/" & $x[7] & $x[8] & "/" & $x[1] & $x[2] & $x[3] & $x[4]
        $time = int($x[9] & $x[10])
        $suffix = " am"
        If $time >= 13 Then
            $time-=12
            $suffix = " pm"
        EndIf
        If $time <= 0 Then $time = 12
        $time = " - " & $time & ":" & $x[11] & $x[12] & ":" & $x[13] & $x[14] & $suffix
        $TrackPlayDate&=$time
    $TrackPlaylist = $track.playlist
    $TrackPlaylist = $TrackPlaylist.name
    $TrackRating = $track.rating
        If $TrackRating = 0 Then
            $TrackRating = "No rating"
        Else
            $TrackRating = $TrackRating & " stars"
        EndIf   
    $TrackSize = $track.size
        $SizeRem = Mod($TrackSize, 1000000)
        $SizeRem = StringSplit($SizeRem, "")
        $TrackSize = int($TrackSize/1000000)
        $TrackSize = $TrackSize & "." & $SizeRem[1] & $SizeRem[2] & " MB"
    $TrackLocation = $track.location
        If $TrackLocation = '0' Then $TrackLocation = "iPod"

    $InfoGUI = GUICreate("Edit info for '" & $track.name &"' - iDFree", 527, 395, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_POPUP, $WS_SYSMENU), -1) ; Creates GUI
    $rgn = CreateRoundRectRgn(0, 0, 530, 398, 9, 9)
    SetWindowRgn($InfoGUI, $rgn)
    GUISetBkColor(0x6E6E6E)
    GUICtrlCreatePic(@TempDir & "\bg.gif", 0, -3, 535, 360)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("Edit '" & $TrackName & "'  ", 55, 4, 465, 17, $SS_CENTER)
    GUICtrlSetFont(-1, -1, 800)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateLabel("Edit '" & $TrackName & "'  ", 54, 3, 465, 17, $SS_CENTER)
    GUICtrlSetFont(-1, -1, 800)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $InfoMoveRegion = GUICtrlCreateLabel("", 52, 0, 552, 19)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $InfoExit = GUICtrlCreatePic(@TempDir & "\iexit.bmp", 5, 2, 0, 0)
    GUICtrlSetTip(-1, "Exit without saving")
    $InfoMinimize = GUICtrlCreatePic(@TempDir & "\iminimize.bmp", 22, 2, 0, 0)
    GUICtrlSetTip(-1, "Minimize edit window")
    $InfoMaximize = GUICtrlCreatePic(@TempDir & "\imaximize.bmp", 39, 2, 0, 0)
    GUICtrlSetTip(-1, "Maximize disabled")
    GUICtrlCreatePic(@TempDir & "\tabs2.gif", 10, 360, 165, 30)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $InfoTab = GUICtrlCreateTab(10, 360, 165, 30, BitOr($WS_TABSTOP, $WS_CLIPSIBLINGS, $TCS_BUTTONS))
    $summary = GUICtrlCreateTabItem("Summary")
        If $ArtLocation <> @TempDir & "\NoArt.bmp" Then
            GUICtrlCreatePic(@TempDir & "\CurrentArt.jpg", 17, 36, 108, 108)
        Else
            GUICtrlCreateGroup("", 15, 30, 115, 115)
            GUICtrlCreateLabel("No album art", 44, 83)
            GUICtrlSetColor(-1, 0xFFFFFF)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlCreateLabel("No album art", 43, 82)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        EndIf
        GUICtrlCreateLabel($TrackName, 135, 40, 375, 17, 0x0C)
        GUICtrlCreateLabel($TrackArtist, 135, 55, 375, 17, 0x0C)
        GUICtrlCreateLabel($TrackAlbum, 135, 70, 375, 17, 0x0C)
        GUICtrlCreateLabel($TrackLength, 135, 93, 375, 17)
        $LocateAndPlay = GUICtrlCreateButton("  Locate and Play  ", 135, 119)
        GUICtrlCreateLabel("", 15, 152, 495, 2, $SS_SUNKEN)
        GUICtrlCreateLabel("Size:", 32, 163, 30, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackSize, 63, 164, 100, 16)
        GUICtrlCreateLabel("Track", 25, 179, 40, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackNumber, 63, 180, 100, 16)
        GUICtrlCreateLabel("of", 46, 194, 20, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TracksOnAlbum, 63, 195, 100, 16)
        GUICtrlCreateLabel("Genre:", 22, 210, 40, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackGenre, 63, 211, 100, 16)
        GUICtrlCreateLabel("Plays:", 25, 227, 40, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackPlayCount, 63, 228, 100, 16)
        GUICtrlCreateLabel("Last:", 31, 243, 40, 16)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackPlayDate, 63, 244, 200, 16)
        GUICtrlCreateLabel("", 15, 271, 495, 2, $SS_SUNKEN)
        GUICtrlCreateLabel("Playlist:", 1, 275, 63, 16, $SS_RIGHT)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackPlaylist, 69, 276, 200, 16)
        GUICtrlCreateLabel("Where:", 1, 290, 63, 57, $SS_RIGHT)
            GUICtrlSetFont(-1, -1, 750)
        GUICtrlCreateLabel($TrackLocation, 69, 291, 448, 57)
    $edit = GUICtrlCreateTabItem("Edit")
        GUICtrlCreateLabel("Name:", 15, 37, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $NameEdit = GUICtrlCreateInput($TrackName, 15, 55, 495, 20)
        GUICtrlCreateLabel("Artist:", 15, 82, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $ArtistEdit = GUICtrlCreateInput($TrackArtist, 15, 100, 405, 20)     
        GUICtrlCreateLabel(" Year:", 427, 82, 60, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $YearEdit = GUICtrlCreateInput($TrackYear, 430, 100, 60, 20)     
        GUICtrlCreateLabel("Album:", 15, 127, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $AlbumEdit = GUICtrlCreateInput($TrackAlbum, 15, 144, 405, 20)
        GUICtrlCreateLabel("Track number:", 427, 127, 120, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $Num1Edit = GUICtrlCreateInput($TrackNumber, 430, 144, 25, 20)
        GUICtrlCreateLabel("of", 462, 147, 20, 20)
        Global $Num2Edit = GUICtrlCreateInput($TracksOnAlbum, 480, 144, 25, 20)
        GUICtrlCreateLabel("Playcount:", 15, 171, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $PlaycountEdit = GUICtrlCreateInput($TrackPlaycount, 15, 188, 73, 20)
        GUICtrlCreateLabel("Composer:", 100, 171, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $ComposerEdit = GUICtrlCreateInput($TrackComposer, 100, 188, 405, 20)
        GUICtrlCreateLabel("Comments:", 15, 212, 100, 18)
            GUICtrlSetFont(-1, -1, 750)
        Global $CommentsEdit = GUICtrlCreateEdit($TrackComments, 15, 229, 495, 85, BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL))
        Global $GenreCombo = GUICtrlCreateCombo("Genre", 15, 320, 157, -1, BitOr($WS_VSCROLL, $CBS_DROPDOWNLIST))
        $genres = "Acoustic|Alternative|Alternative & Punk|Blues/R&B|Books and Spoken|Children's Music|Classical|Country|Dance|Easy Listening|Electronic|Folk|General Rock|Hip Hop/Rap|Holiday|Industrial|" & _ 
                    "Jazz|New Age|Other|Pop|Pop Punk|Punk Rock|Reggae|Religious|Rock|Ska|Soundtrack|Techno|Unclassifiable|World"
            GUICtrlSetData(-1, $genres, $TrackGenre)
        Global $OtherGenreEdit = GUICtrlCreateInput("", 190, 320, 257, 20)
            GUICtrlSetState(-1, $GUI_DISABLE)
    $lyrics = GUICtrlcreateTabItem("Lyrics")
        Global $LyricsInWindowBox = GUICtrlCreateEdit($TrackLyrics, 15, 38, 496, 306)
    GUICtrlCreateTabItem("")
    $ExitNoSave = GUICtrlCreateButton("Exit without saving", 250, 360, 100, 26)
    $ExitAndSave = GUICtrlCreateButton("Save && exit", 360, 360, 100, 26)
    $enabled = 0
    GUISetState()
    $track.lyrics = ""

    While 1
        Opt("GUIOnEventMode", 0)
        $msg = GUIGetMsg()
        If GUICtrlRead($GenreCombo) = "Other" and $enabled = 0 Then
            GUICtrlSetState($OtherGenreEdit, $GUI_ENABLE)
            $enabled = 1
        EndIf
        If GUICtrlRead($GenreCombo) <> "Other" and $enabled = 1 Then
            GUICtrlSetState($OtherGenreEdit, $GUI_DISABLE)
            $enabled = 0
        EndIf
        If $msg = $ExitNoSave Then ExitLoop
        If $msg = $ExitAndSave Then
            SaveInfo()
            ExitLoop
        EndIf
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $LocateAndPlay Then $track.play
        If $msg = $InfoMinimize Then GUISetState(@SW_MINIMIZE)
        If $msg = $InfoExit Then ExitLoop
    WEnd

    Opt("GUIOnEventMode", 1)
    GUIDelete($InfoGUI) 
EndFunc

Func SaveInfo()
    If GUICtrlRead($NameEdit) <> $track.name Then $track.name = GUICtrlRead($NameEdit)
    If GUICtrlRead($ArtistEdit) <> $track.artist Then $track.artist = GUICtrlRead($ArtistEdit)
    $track.album = GUICtrlRead($AlbumEdit)
    If GUICtrlRead($Num1Edit) <> $track.TrackNumber Then $track.TrackNumber = GUICtrlRead($Num1Edit)
    If GUICtrlRead($Num2Edit) <> $track.TrackCount Then $track.TrackCount = GUICtrlRead($Num2Edit)
    If GUICtrlRead($ComposerEdit) <> $track.composer Then $track.composer = GUICtrlRead($ComposerEdit)
    If GUICtrlRead($CommentsEdit) <> $track.comment Then $track.comment = GUICtrlRead($CommentsEdit)
    If GUICtrlRead($YearEdit) <> $track.year Then $track.year = GUICtrlRead($YearEdit)
    If GUICtrlRead($LyricsInWindowBox) <> "" Then $track.lyrics = GUICtrlRead($LyricsInWindowBox)
    If GUICtrlRead($PlaycountEdit) <> "" Then $track.PlayedCount = GUICtrlRead($PlaycountEdit)
    If GUICtrlRead($GenreCombo) <> "Other" Then
        If GUICtrlRead($GenreCombo) <> "Genre" Then $track.genre = GUICtrlRead($GenreCombo)
    Else
        If GUICtrlRead($OtherGenreEdit) <> "" Then $track.genre = GUICtrlRead($OtherGenreEdit)
    EndIf   
    art()
EndFunc 

Func about()
    Opt("GUIOnEventMode", 0)
    $AboutGUI = GUICreate("About iDFree", 431, 246, -1, -1, $WS_POPUP)
    WinSetOnTop("About iDFree", "", 1)
    GUISetBkColor(0xFFFFFF)
    GUICtrlCreatePic(@TempDir & "\about.gif", 0, 0, 431, 246)
    GUICtrlSetState(-1, $GUI_DISABLE)

    $close = GUICtrlCreateButton(" Ok! ", 380, 100, 35, 22)
    $win = WinGetPos("About iDFree")
    $child = GUICreate("About scroller", 175, 115, $win[0]+255, $win[1]+125, $WS_POPUP, $WS_EX_TRANSPARENT, $AboutGUI)
    GUISetBkColor(0xFFFFFF)
    $AboutLabel = GUICtrlCreateLabel("Coded by Ben Perkins" & @CR & "Magic Soft Inc." & @CR & "Inspired by:" & @CR & "Alex Bagby and Ichaelmay58" & _
                        @CR & "BG image thanks to Reel Big Fish" & @CR & @CR & "-The Magician", 1, -80, 170, 105, BitOr($SS_NOTIFY, $SS_RIGHT))
    GUISetState(@SW_SHOW, $AboutGUI)
    GUISetState(@SW_SHOW, $child)

    While 1
        For $i = -105 to 130
            $msg = GUIGetMsg()
            ControlMove("About scroller", "", $AboutLabel, 1, 30-$i)
            If $msg = $close Then
                Opt("GUIOnEventMode", 1)
                GUIDelete($AboutGUI)
                Return
            EndIf
            sleep(50)
        Next
    WEnd
EndFunc

Func help()
    $HelpGUI = GUICreate("iDFree Help", 775, 550, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))    
    $AboutBugs = "Known bugs:" & @CRLF & "PNG album art doesn't always work" & @CRLF & "Always chooses first playlist of duplicates" & @CRLF & "LyricsDir.com doesn't work, I believe the site is down" & @CRLF & @CRLF & "Email others to: magician13134@gmail.com" & @CRLF & @CRLF & "Fixed bugs:" & @CRLF & "Local files don't work (2/05/07)" & @CRLF & "Crashes if opened on a song with no art (2/11/07)" &   @CRLF & "Window resizes when song w/o album art starts (2/11/07)" & @CRLF & "No help file exists yet (2/12/07)"
    $AboutHelp = "Choose a sub catagory for more"
    $AboutiTunes = "In iTunes Mode iDFree will read the current song and find lyrics for it from the choosen site" & @CRLF & "These lyrics appear in the 'New lyrics' box, and can be applied by pressing 'Apply New Lyrics'" & @CRLF & "To edit current lyrics press the '>' button or use 'Edit info'" & @CRLF & "iTunes mode also allows you to control the iTunes player without leaving iDFree" & @CRLF & "by using the control buttons in the top-left" & @CRLF & @CRLF & "Pressing 'iBoost' opens the included copy of iBoost. (See 'iBoost' for more.)" & @CRLF & "Pressing 'Edit info' will edit the track info. (See 'Edit Info' for more)" & @CRLF & "Click the remaining song time to switch time view" & @CRLF & "Click the artwork for a zoomed view"
    $AboutBatch = "Begin by choosing any playlist or source. If the source has too many songs (around 700), the log file will be cut off," & @CRLF & "the bottom of iDFree will tell you how many songs it contains and a color corresponding to that number" & @CRLF & "(Green is good, yellow is ok, and red is bad)" & @CRLF & "Choose the options to fit your needs and press 'Get lyrics' and let iDFree work" & @CRLF & "It is not recommended that you direct iDFree away from batch apply while it is getting lyrics" & @CRLF & "Choosing 'Save log' will save a log file of the batch apply"
    $AboutManual = "Begin by entering an artist and a track name into the corresponding boxes, choose a website and click 'Get lyrics'." & @CRLF & "To save these lyrics, press 'Save lyrics'"
    $AboutAbout = "Written by Ben Perkins, owner and founder of Magic Soft Inc." & @CRLF & "www.magicsoftinc.com" & @CRLF & "Thanks for the idea Alex and Mike... And the critism to keep me working ;)" & @CRLF & "The background image for the about box was stolen from The Reel Big Fish, please don't sue me! :)" & @CRLF & @CRLF & "Please don't buy the Reel Big Fish 'Greatest Hit' album!" & @CRLF & "It was made without the consent of RBF and without paying them a cent!"
    $contents = GUICtrlCreateTreeView(0, 0, 198, 550, BitOr($TVS_HASBUTTONS, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    GUICtrlSetResizing(-1, 354)
    $help = GUICtrlCreateTreeViewItem("Help", $contents)
        $iTunesItem = GUICtrlCreateTreeViewItem("iTunes Mode", $help)
        $BatchItem = GUICtrlCreateTreeViewItem("Batch Mode", $help)
        $ManualItem = GUICtrlCreateTreeViewItem("Manual Mode", $help)
    $bugs = GUICtrlCreateTreeViewItem("Bugs", $contents)
    $about = GUICtrlCreateTreeViewItem("About", $contents)  
    $view = GUICt