 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Dra_Gon
Joined: 25 May 2007 Posts: 313
|
Posted: Tue Jun 24, 2008 12:19 am Post subject: Adding times together |
|
|
I'm making a little program to create a list of music. I'm using a function I got from here:
http://www.autohotkey.com/forum/topic15174.html
The problem is, I also want to add up the times for a total and I haven't been able to find the solution on my own.
This is what I've tried so far, but doesn't work:
| Code: | StringSplit, tmpLen, MP3Len, :
tmpTime1 := tmpTime1 + tmpLen1
tmpTime2 := tmpTime2 + tmpLen2
If tmpTime2 => 60
{
tmpTime1 += 1
tmpTime2 -= 60
newTime := tmpTime1 ":" tmpTime2
}
|
The "MP3Len" comes off of the function's return {Return mmss} which is time formated. I would like to convert the splits to integer, add them then put the "newTime" in an edit box {I haven't found a way to convert them}.
Any help would be appreciated. Thanks!
Ciao,
Dra'Gon _________________
For a good laugh {hopefully} >> megamatts.50megs.com
My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/ |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Tue Jun 24, 2008 12:30 am Post subject: |
|
|
I believe it would be easier to simply modify the function a bit.
| Code: |
GetMP3Len(In_PathFile)
{
; In_PathFile: Absolute path to your mp3 file - e.g. C:\Music\test.mp3
; Set variable capacities for dllcalls
VarSetCapacity(ShortName, 255)
VarSetCapacity(Length , 255)
; Transforms FilePath into it's 8.3-Value
RetValue := DllCall("kernel32.dll\GetShortPathNameA"
, "Str", In_PathFile
, "Str", ShortName
, "UInt", 255)
; Open MP3
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "open " . ShortName . " type MPEGVideo alias mp3audio"
, "Str", 0
, "UInt", 0
, "UInt", 0)
; Read Length
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "status mp3audio length"
, "Str", Length
, "UInt", 255
, "UInt", 0)
; Close MP3
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "close mp3audio"
, "Str", 0
, "UInt", 0
, "UInt", 0)
; Trim milliseconds -> just seconds needed
StringTrimRight, Length, Length, 3
; Convert the specified number of seconds to hh:mm:ss format.
time = 19990101 ; *Midnight* of an arbitrary date.
time += %Length%, seconds
FormatTime, mmss, %time%, mm:ss
Return mmss ; This method is used to support more than 24 hours worth of sections.
Return Length
} |
Omit the last four lines (shown in red), return Length instead, and then simply add the times together; this will give you all of their times in seconds. You can then use the same method that the original function maker did to convert to mm:ss.
So, your code will look like:
| Code: | totaltime:=0
Loop, Some files
totaltime+=GetMP3Len(the file)
time=19990101
time += %totaltime%, seconds
FormatTime, totaltime, %time%, mm:ss
MsgBox, %totaltime% |
Edit: Took a look at your code, and just have a couple comments. Your main problem is that it should be "If tmpTime2 >= 60" not "If tmpTime2 => 60". Also, if you're not initializing tmpTime1 and tmpTime2 to be 0, you're going to end up with blank strings... Just in case you didn't know that. |
|
| Back to top |
|
 |
Dra_Gon
Joined: 25 May 2007 Posts: 313
|
Posted: Tue Jun 24, 2008 1:08 am Post subject: |
|
|
I'm trying out your advice now. I do initialize the temp variables before it goes into the loop. Come to think of it, I'll put the code here now, just in case other info is needed about it to help.
| Code: | ; <<Description>>
; Working Name: SongLister.ahk
; Created By: Matthew "Dra'Gon" Stohler
; Begun: 15Jun08
; Completed:
; Email: mattstohler@yahoo.com
; ScreenName: Dra_Gon
; Use it however you wish and enjoy!
; -> With thanks to "AGermanUser" for the function GetMP3Len.
; -> With thanks to "Ace_NoOne" for the ListView Width Sizer.
; -> With thanks to "toralf"/"evl"/"shimanov" for the Line Color Changer
; -------------------------------------
#SingleInstance ignore
Gosub SetVaris
Menu, tray, NoStandard
Menu, tray, add, Exit, GuiClose
Menu, tray, Default, Exit
MAIN_GUI_BELOW:
Gui, Add, Button, x10 y10 h20 gStartList, New List
Gui, Add, Button, x+5 yp+0 h20 DISABLED gRedoList vRefList, Refresh List
Gui, Add, Button, x+5 yp+0 h20 DISABLED gSaveList vSvList, Save List
Gui, Add, Button, x+5 yp+0 h20 %DisEn% gOpenList vOpnList, Open List
Gui, Add, Button, x+5 yp+0 h20 DISABLED gCloseList vClsList, Close List
Gui, Add, Text, x10 y+10 w250 h15 vNoRename, Double-Click song to RENAME.
Gui, Add, ListView, x10 y+10 w500 h250 NoSortHdr Grid -Multi AltSubmit vSongView gSongClick, %lvwTtlBar%
LV_ModifyCol(1, 45)
LV_ModifyCol(2, 200)
LV_ModifyCol(3, 200)
LV_ModifyCol(4, 50)
Gui, Show, Center Autosize, Song Meister
Return
GuiClose:
ExitApp
Return
StartList:
LV_Delete()
IfExist, D:\
FileSelectFolder, mscFolder, *D:\, 0, Where is your music?
Else
FileSelectFolder, mscFolder, *%sngFolder%, 0, Where is your music?
IfEqual drvType, CDROM
{
GuiControl,, NoRename, Music Drive is CDROM. Cannot RENAME files!
YNRen = 0
}
Else
{
GuiControl,, NoRename, Double-Click song to RENAME.
YNRen = 1
}
IfNotEqual, mscFolder,
Gosub GetSongs
Else
mscFolder = C:\
IniWrite, %mscFolder%, SLData.ini, Misc, SongFldr
Return
RedoList:
LV_Delete()
Gosub GetSongs
Return
GetSongs:
LV_ActivateColor()
c = 0
Loop, %mscFolder%\*.mp3
{
MP3Len := GetMP3Len(A_LoopFileFullPath)
sngName%a_Index% := A_LoopFileName
StringReplace, tmpSong, A_LoopFileName, .mp3
IfInString, tmpSong, %a_Space%-%a_Space%
{
StringReplace, tmpSong, tmpSong, %a_Space%-%a_Space%,|
StringSplit, tmpSong, tmpSong, |
}
Else
tmpSong2 := tmpSong
LV_Add("", a_Index, tmpSong1, tmpSong2, MP3Len)
GuiControl,, sngTtlTime, %newTime%
tmpSong1 =
tmpSong2 =
if c = 1
{
LV_ChangeColor(a_index, "0x000000", "0xdadada")
c = 0
}
else
c = 1
}
LV_ModifyCol(2, "Auto")
LV_ModifyCol(3, "Auto")
GUI, +LastFound ; activate GUI window
LsVwWidth := 0 ; initialize ListView width variable
; get columns' widths
Loop % LV_GetCount("Column")
{
SendMessage, 4125, A_Index - 1, 0, SysListView321 ; 4125 is LVM_GETCOLUMNWIDTH.
LsVwWidth := LsVwWidth + ErrorLevel
}
Guicontrol, Enable, RefList
Guicontrol, Enable, SvList
Guicontrol, Enable, ClsList
; resize ListView control and GUI
GuiControl, Move, SongView, % "W" . LsVwWidth + 8
Gui, Show, AutoSize Center Resize
SplitPath, mscFolder,,,,, mscDrive
DriveGet, drvType, Type, %mscDrive%
Return
SaveList:
IniRead, nLists, SLData.ini, Lists, nbrLists
nLists += 1
lstName = SongList%nLists%
InputBox, lstFile, Name, Name of Save File,,,,,,,, %lstName%
FileSelectFolder, lstFolder, *%lstFolder%, 3, Folder to save your list?
Loop % LV_GetCount()
{
LV_GetText(svArtist, A_Index, 2)
LV_GetText(svTitle, A_Index, 3)
LV_GetText(svTime, A_Index, 4)
svCombo := a_Index "$" svArtist "$" svTitle "$" svTime
FileAppend , %svCombo%`n, %lstFolder%\%lstFile%.txt
}
IniWrite, %lstFile%, SLData.ini, Lists, List_%nLists%
IniWrite, %mscFolder%, SLData.ini, Lists, Dir_%nLists%
IniWrite, %nLists%, SLData.ini, Lists, nbrLists
Return
OpenList:
IniRead, nLists, SLData.ini, Lists, nbrLists
If nLists > 0
{
Gui, 3:Add, Text, x10 y10 h15, Select List
iX = 10
iY = 30
i = 0
Loop, %nLists%
{
IniRead, opnList_%a_Index%, SLData.ini, Lists, List_%a_Index%
tmpList := opnList_%a_Index%
Gui, 3:Add, Button, x%iX% y%iY% h20 vbtnList_%a_Index% gGetList, %tmpList%
i += 1
iX = +10
if i = 6
{
iX = 10
iY += 10
i = 0
}
}
Gui, 3:Show, Center Autosize, Song Lists
}
Return
3GUIClose:
Gui, 3:Destroy
Return
CloseList:
LV_Delete()
Return
GetList:
Gui, 1:Default
LV_Delete()
LV_ActivateColor()
c = 0
StringReplace, tmpList, A_GuiControl, btnList_
lstFile := opnList_%tmpList%
Loop, Read, %lstFolder%%lstFile%.txt
{
StringSplit, lstCol, A_LoopReadLine, $
LV_Add("", lstCol1, lstCol2, lstCol3, lstCol4)
if c = 1
{
LV_ChangeColor(a_index, "0x000000", "0xdadada")
c = 0
}
else
c = 1
}
Gosub 3GUIClose
Return
SongClick:
if A_GuiControl = SongView
{
if A_GuiEvent = Normal
{
rowSong := A_EventInfo
LV_GetText(sngArtist, rowSong, 2)
LV_GetText(sngTitle, rowSong, 3)
}
If YNRen = 1
If A_GuiEvent = DoubleClick
Gosub RenSong
}
Return
RenSong:
tmpArtist := sngArtist
tmpTitle := sngTitle
; Gui, 2:+owner1
Gui, 2:Add, Text, x10 y10 h15, Artist(s):
Gui, 2:Add, Edit, x+5 yp+0 w150 h20 vedtArtist, %tmpArtist%
Gui, 2:Add, Text, x10 y40 h15, Song:
Gui, 2:Add, Edit, x+5 yp+0 w150 h20 vedtTitle, %tmpTitle%
Gui, 2:Add, Button, x10 y+10 w50 h20 gGoRename, Do It!
Gui, 2:Add, Button, x+10 yp+0 w50 h20 g2GUIClose, Cancel
Gui, 2:Show, Center Autosize, Rename Song
Return
2GUIClose:
LV_Modify(rowSong, "-Select")
Gui, 2:Destroy
Return
GoRename:
GuiControlGet, newArtist, 2:, edtArtist
GuiControlGet, newTitle, 2:, edtTitle
oldSong := sngName%rowSong%
newSong := newArtist " - " newTitle ".mp3"
FileMove, %mscFolder%\%oldSong%, %mscFolder%\%newSong%
MsgBox, 48, Done!, Your file has been RENAMED!`nOld Name: %oldSong%`nNew Name: %newSong%
Gui, 2:Destroy
Gui, 1:Default
LV_GetText(sngTime, rowSong, 4)
LV_Delete(rowSong)
LV_Insert(rowSong, "", rowSong, newArtist, newTitle, sngTime)
Return
VARIABLE_INITIALIZER_BELOW:
Return
SetVaris:
lvwTtlBar = No.|Artist(s)|Title|Time
IniRead, lstFolder, %A_ScriptDir%\SLData.ini, Misc, SaveFldr
IniRead, sngFolder, %A_ScriptDir%\SLData.ini, Misc, SongFldr
IfExist, %lstFolder%*.txt
DisEn =
Else
DisEn = DISABLED
Return
FUNCTIONS_BELOW:
Return
GetMP3Len(In_PathFile)
{
Global newTime
; In_PathFile: Absolute path to your mp3 file - e.g. C:\Music\test.mp3
; Set variable capacities for dllcalls
VarSetCapacity(ShortName, 255)
VarSetCapacity(Length , 255)
; Transforms FilePath into it's 8.3-Value
RetValue := DllCall("kernel32.dll\GetShortPathNameA"
, "Str", In_PathFile
, "Str", ShortName
, "UInt", 255)
; Open MP3
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "open " . ShortName . " type MPEGVideo alias mp3audio"
, "Str", 0
, "UInt", 0
, "UInt", 0)
; Read Length
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "status mp3audio length"
, "Str", Length
, "UInt", 255
, "UInt", 0)
; Close MP3
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "close mp3audio"
, "Str", 0
, "UInt", 0
, "UInt", 0)
; Trim milliseconds -> just seconds needed
StringTrimRight, Length, Length, 3
; Convert the specified number of seconds to hh:mm:ss format.
time = 19990101 ; *Midnight* of an arbitrary date.
time += %Length%, seconds
FormatTime, mmss, %time%, mm:ss
Return mmss ; This method is used to support more than 24 hours worth of sections.
}
LV_ActivateColor()
{
global hw_LV_Sample
OnMessage( 0x4E, "WM_NOTIFY" )
ControlGet, hw_LV_Sample, HWND,, SysListView321
}
LV_ChangeColor(Index, TextColor, BackColor){
global
Line_Color_%Index%_Text := TextColor
Line_Color_%Index%_Back := BackColor
WinSet, Redraw,, ahk_id %hw_LV_Sample%
}
WM_NOTIFY( p_w, p_l, p_m ) {
global hw_LV_Sample
if ( DecodeInteger( "uint4", p_l, 0 ) = hw_LV_Sample ) {
if ( DecodeInteger( "int4", p_l, 8 ) = -12 ) { ; NM_CUSTOMDRAW
draw_stage := DecodeInteger( "uint4", p_l, 12 )
if ( draw_stage = 1 ) ; CDDS_PREPAINT
return, 0x20 ; CDRF_NOTIFYITEMDRAW
else if ( draw_stage = 0x10000|1 ){ ; CDDS_ITEM
Current_Line := DecodeInteger( "uint4", p_l, 36 )+1
LV_GetText(Index, Current_Line)
If (Line_Color_%Index%_Text != ""){
EncodeInteger( Line_Color_%Index%_Text, 4, p_l, 48 ) ; foreground
EncodeInteger( Line_Color_%Index%_Back, 4, p_l, 52 ) ; background
}
}
}
}
}
DecodeInteger( p_type, p_address, p_offset, p_hex=true ){
old_FormatInteger := A_FormatInteger
ifEqual, p_hex, 1, SetFormat, Integer, hex
else, SetFormat, Integer, dec
StringRight, size, p_type, 1
loop, %size%
value += *( ( p_address+p_offset )+( A_Index-1 ) ) << ( 8*( A_Index-1 ) )
if ( size <= 4 and InStr( p_type, "u" ) != 1 and *( p_address+p_offset+( size-1 ) ) & 0x80 )
value := -( ( ~value+1 ) & ( ( 2**( 8*size ) )-1 ) )
SetFormat, Integer, %old_FormatInteger%
return, value
}
EncodeInteger( p_value, p_size, p_address, p_offset ){
loop, %p_size%
DllCall( "RtlFillMemory", "uint", p_address+p_offset+A_Index-1, "uint", 1, "uchar", p_value >> ( 8*( A_Index-1 ) ) )
}
|
This is before I started trying to get the total times. It seems to work great without having the total time of all songs, but I just wanted to add that little somethin'-somethin' to it. Thanks for the reply, I'll keep trying things out.
Ciao,
Dra'Gon _________________
For a good laugh {hopefully} >> megamatts.50megs.com
My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/ |
|
| Back to top |
|
 |
Dra_Gon
Joined: 25 May 2007 Posts: 313
|
Posted: Tue Jun 24, 2008 1:21 am Post subject: |
|
|
By Jove, I think I got it!
In this section:
| Code: | StringTrimRight, Length, Length, 3
; Convert the specified number of seconds to hh:mm:ss format.
time = 19990101 ; *Midnight* of an arbitrary date.
time += %Length%, seconds
; \/--I added these three lines and made "newTime" & "tmpTime" Global
tmpTime += Length
newTime = 19990101
newTime += %tmpTime%, seconds
FormatTime, newTime, %newTime%, mm:ss
FormatTime, mmss, %time%, mm:ss
Return mmss ; This method is used to support more than 24 hours worth of sections.
|
Then:
| Code: | LV_Add("", a_Index, tmpSong1, tmpSong2, MP3Len)
GuiControl,, sngTtlTime, %newTime% ; This puts "newTime" into the disabled edit box.
tmpSong1 =
tmpSong2 =
if c = 1
{
LV_ChangeColor(a_index, "0x000000", "0xdadada")
c = 0
}
else
c = 1
|
AND:
| Code: | Gui, Add, ListView, x10 y+10 w500 h250 NoSortHdr Grid -Multi AltSubmit vSongView gSongClick, %lvwTtlBar%
Gui, Add, Text, x10 y+10 h15, Total Time:
Gui, Add, Edit, x+0 yp+0 w50 h20 Disabled vsngTtlTime,
|
Put in the last 2 lines for my GUI.
The modified script {though not quite finished}:
| Code: | ; <<Description>>
; Working Name: SongLister.ahk
; Created By: Matthew "Dra'Gon" Stohler
; Begun: 15Jun08
; Completed:
; Email: mattstohler@yahoo.com
; ScreenName: Dra_Gon
; Use it however you wish and enjoy!
; -> With thanks to "AGermanUser" for the function GetMP3Len.
; -> With thanks to "Ace_NoOne" for the ListView Width Sizer.
; -> With thanks to "toralf"/"evl"/"shimanov" for the Line Color Changer
; -------------------------------------
#SingleInstance ignore
Gosub SetVaris
Menu, tray, NoStandard
Menu, tray, add, Exit, GuiClose
Menu, tray, Default, Exit
MAIN_GUI_BELOW:
Gui, Add, Button, x10 y10 h20 gStartList, New List
Gui, Add, Button, x+5 yp+0 h20 DISABLED gRedoList vRefList, Refresh List
Gui, Add, Button, x+5 yp+0 h20 DISABLED gSaveList vSvList, Save List
Gui, Add, Button, x+5 yp+0 h20 %DisEn% gOpenList vOpnList, Open List
Gui, Add, Button, x+5 yp+0 h20 DISABLED gCloseList vClsList, Close List
Gui, Add, Text, x10 y+10 w250 h15 vNoRename, Double-Click song to RENAME.
Gui, Add, ListView, x10 y+10 w500 h250 NoSortHdr Grid -Multi AltSubmit vSongView gSongClick, %lvwTtlBar%
Gui, Add, Text, x10 y+10 h15, Total Time:
Gui, Add, Edit, x+0 yp+0 w50 h20 Disabled vsngTtlTime,
LV_ModifyCol(1, 45)
LV_ModifyCol(2, 200)
LV_ModifyCol(3, 200)
LV_ModifyCol(4, 50)
Gui, Show, Center Autosize, Song Meister
Return
GuiClose:
ExitApp
Return
StartList:
LV_Delete()
IfExist, D:\
FileSelectFolder, mscFolder, *D:\, 0, Where is your music?
Else
FileSelectFolder, mscFolder, *%sngFolder%, 0, Where is your music?
IfEqual drvType, CDROM
{
GuiControl,, NoRename, Music Drive is CDROM. Cannot RENAME files!
YNRen = 0
}
Else
{
GuiControl,, NoRename, Double-Click song to RENAME.
YNRen = 1
}
IfNotEqual, mscFolder,
Gosub GetSongs
Else
mscFolder = C:\
IniWrite, %mscFolder%, SLData.ini, Misc, SongFldr
Return
RedoList:
LV_Delete()
Gosub GetSongs
Return
GetSongs:
LV_ActivateColor()
c = 0
tmpTime =
Loop, %mscFolder%\*.mp3
{
MP3Len := GetMP3Len(A_LoopFileFullPath)
sngName%a_Index% := A_LoopFileName
StringReplace, tmpSong, A_LoopFileName, .mp3
IfInString, tmpSong, %a_Space%-%a_Space%
{
StringReplace, tmpSong, tmpSong, %a_Space%-%a_Space%,|
StringSplit, tmpSong, tmpSong, |
}
Else
tmpSong2 := tmpSong
LV_Add("", a_Index, tmpSong1, tmpSong2, MP3Len)
GuiControl,, sngTtlTime, %newTime%
tmpSong1 =
tmpSong2 =
if c = 1
{
LV_ChangeColor(a_index, "0x000000", "0xdadada")
c = 0
}
else
c = 1
}
LV_ModifyCol(2, "Auto")
LV_ModifyCol(3, "Auto")
GUI, +LastFound ; activate GUI window
LsVwWidth := 0 ; initialize ListView width variable
; get columns' widths
Loop % LV_GetCount("Column")
{
SendMessage, 4125, A_Index - 1, 0, SysListView321 ; 4125 is LVM_GETCOLUMNWIDTH.
LsVwWidth := LsVwWidth + ErrorLevel
}
Guicontrol, Enable, RefList
Guicontrol, Enable, SvList
Guicontrol, Enable, ClsList
; resize ListView control and GUI
GuiControl, Move, SongView, % "W" . LsVwWidth + 8
Gui, Show, AutoSize Center Resize
SplitPath, mscFolder,,,,, mscDrive
DriveGet, drvType, Type, %mscDrive%
Return
SaveList:
IniRead, nLists, SLData.ini, Lists, nbrLists
nLists += 1
lstName = SongList%nLists%
InputBox, lstFile, Name, Name of Save File,,,,,,,, %lstName%
FileSelectFolder, lstFolder, *%lstFolder%, 3, Folder to save your list?
Loop % LV_GetCount()
{
LV_GetText(svArtist, A_Index, 2)
LV_GetText(svTitle, A_Index, 3)
LV_GetText(svTime, A_Index, 4)
svCombo := a_Index "$" svArtist "$" svTitle "$" svTime
FileAppend , %svCombo%`n, %lstFolder%\%lstFile%.txt
}
IniWrite, %lstFile%, SLData.ini, Lists, List_%nLists%
IniWrite, %mscFolder%, SLData.ini, Lists, Dir_%nLists%
IniWrite, %nLists%, SLData.ini, Lists, nbrLists
Return
OpenList:
IniRead, nLists, SLData.ini, Lists, nbrLists
If nLists > 0
{
Gui, 3:Add, Text, x10 y10 h15, Select List
iX = 10
iY = 30
i = 0
Loop, %nLists%
{
IniRead, opnList_%a_Index%, SLData.ini, Lists, List_%a_Index%
tmpList := opnList_%a_Index%
Gui, 3:Add, Button, x%iX% y%iY% h20 vbtnList_%a_Index% gGetList, %tmpList%
i += 1
iX = +10
if i = 6
{
iX = 10
iY += 10
i = 0
}
}
Gui, 3:Show, Center Autosize, Song Lists
}
Return
3GUIClose:
Gui, 3:Destroy
Return
CloseList:
LV_Delete()
Return
GetList:
Gui, 1:Default
LV_Delete()
LV_ActivateColor()
c = 0
StringReplace, tmpList, A_GuiControl, btnList_
lstFile := opnList_%tmpList%
Loop, Read, %lstFolder%%lstFile%.txt
{
StringSplit, lstCol, A_LoopReadLine, $
LV_Add("", lstCol1, lstCol2, lstCol3, lstCol4)
if c = 1
{
LV_ChangeColor(a_index, "0x000000", "0xdadada")
c = 0
}
else
c = 1
}
Gosub 3GUIClose
Return
SongClick:
if A_GuiControl = SongView
{
if A_GuiEvent = Normal
{
rowSong := A_EventInfo
LV_GetText(sngArtist, rowSong, 2)
LV_GetText(sngTitle, rowSong, 3)
}
If YNRen = 1
If A_GuiEvent = DoubleClick
Gosub RenSong
}
Return
RenSong:
tmpArtist := sngArtist
tmpTitle := sngTitle
; Gui, 2:+owner1
Gui, 2:Add, Text, x10 y10 h15, Artist(s):
Gui, 2:Add, Edit, x+5 yp+0 w150 h20 vedtArtist, %tmpArtist%
Gui, 2:Add, Text, x10 y40 h15, Song:
Gui, 2:Add, Edit, x+5 yp+0 w150 h20 vedtTitle, %tmpTitle%
Gui, 2:Add, Button, x10 y+10 w50 h20 gGoRename, Do It!
Gui, 2:Add, Button, x+10 yp+0 w50 h20 g2GUIClose, Cancel
Gui, 2:Show, Center Autosize, Rename Song
Return
2GUIClose:
LV_Modify(rowSong, "-Select")
Gui, 2:Destroy
Return
GoRename:
GuiControlGet, newArtist, 2:, edtArtist
GuiControlGet, newTitle, 2:, edtTitle
oldSong := sngName%rowSong%
newSong := newArtist " - " newTitle ".mp3"
FileMove, %mscFolder%\%oldSong%, %mscFolder%\%newSong%
MsgBox, 48, Done!, Your file has been RENAMED!`nOld Name: %oldSong%`nNew Name: %newSong%
Gui, 2:Destroy
Gui, 1:Default
LV_GetText(sngTime, rowSong, 4)
LV_Delete(rowSong)
LV_Insert(rowSong, "", rowSong, newArtist, newTitle, sngTime)
Return
VARIABLE_INITIALIZER_BELOW:
Return
SetVaris:
lvwTtlBar = No.|Artist(s)|Title|Time
IniRead, lstFolder, %A_ScriptDir%\SLData.ini, Misc, SaveFldr
IniRead, sngFolder, %A_ScriptDir%\SLData.ini, Misc, SongFldr
IfExist, %lstFolder%*.txt
DisEn =
Else
DisEn = DISABLED
Return
FUNCTIONS_BELOW:
Return
GetMP3Len(In_PathFile)
{
Global newTime, tmpTime
; In_PathFile: Absolute path to your mp3 file - e.g. C:\Music\test.mp3
; Set variable capacities for dllcalls
VarSetCapacity(ShortName, 255)
VarSetCapacity(Length , 255)
; Transforms FilePath into it's 8.3-Value
RetValue := DllCall("kernel32.dll\GetShortPathNameA"
, "Str", In_PathFile
, "Str", ShortName
, "UInt", 255)
; Open MP3
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "open " . ShortName . " type MPEGVideo alias mp3audio"
, "Str", 0
, "UInt", 0
, "UInt", 0)
; Read Length
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "status mp3audio length"
, "Str", Length
, "UInt", 255
, "UInt", 0)
; Close MP3
RetValue := DllCall("winmm.dll\mciSendStringA"
, "Str", "close mp3audio"
, "Str", 0
, "UInt", 0
, "UInt", 0)
; Trim milliseconds -> just seconds needed
StringTrimRight, Length, Length, 3
; Convert the specified number of seconds to hh:mm:ss format.
time = 19990101 ; *Midnight* of an arbitrary date.
time += %Length%, seconds
tmpTime += Length
newTime = 19990101
newTime += %tmpTime%, seconds
FormatTime, newTime, %newTime%, mm:ss
FormatTime, mmss, %time%, mm:ss
Return mmss ; This method is used to support more than 24 hours worth of sections.
}
LV_ActivateColor()
{
global hw_LV_Sample
OnMessage( 0x4E, "WM_NOTIFY" )
ControlGet, hw_LV_Sample, HWND,, SysListView321
}
LV_ChangeColor(Index, TextColor, BackColor){
global
Line_Color_%Index%_Text := TextColor
Line_Color_%Index%_Back := BackColor
WinSet, Redraw,, ahk_id %hw_LV_Sample%
}
WM_NOTIFY( p_w, p_l, p_m ) {
global hw_LV_Sample
if ( DecodeInteger( "uint4", p_l, 0 ) = hw_LV_Sample ) {
if ( DecodeInteger( "int4", p_l, 8 ) = -12 ) { ; NM_CUSTOMDRAW
draw_stage := DecodeInteger( "uint4", p_l, 12 )
if ( draw_stage = 1 ) ; CDDS_PREPAINT
return, 0x20 ; CDRF_NOTIFYITEMDRAW
else if ( draw_stage = 0x10000|1 ){ ; CDDS_ITEM
Current_Line := DecodeInteger( "uint4", p_l, 36 )+1
LV_GetText(Index, Current_Line)
If (Line_Color_%Index%_Text != ""){
EncodeInteger( Line_Color_%Index%_Text, 4, p_l, 48 ) ; foreground
EncodeInteger( Line_Color_%Index%_Back, 4, p_l, 52 ) ; background
}
}
}
}
}
DecodeInteger( p_type, p_address, p_offset, p_hex=true ){
old_FormatInteger := A_FormatInteger
ifEqual, p_hex, 1, SetFormat, Integer, hex
else, SetFormat, Integer, dec
StringRight, size, p_type, 1
loop, %size%
value += *( ( p_address+p_offset )+( A_Index-1 ) ) << ( 8*( A_Index-1 ) )
if ( size <= 4 and InStr( p_type, "u" ) != 1 and *( p_address+p_offset+( size-1 ) ) & 0x80 )
value := -( ( ~value+1 ) & ( ( 2**( 8*size ) )-1 ) )
SetFormat, Integer, %old_FormatInteger%
return, value
}
EncodeInteger( p_value, p_size, p_address, p_offset ){
loop, %p_size%
DllCall( "RtlFillMemory", "uint", p_address+p_offset+A_Index-1, "uint", 1, "uchar", p_value >> ( 8*( A_Index-1 ) ) )
}
|
So far so goooood!
Ciao,
Dra'Gon _________________
For a good laugh {hopefully} >> megamatts.50megs.com
My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/ |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|