Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; <COMPILER: v1.0.47.6>
- Media_Open(File, Alias=""){
- Static SoundNumber = 0
- IfNotExist, %File%
- {
- ErrorLevel = -2
- Return 0
- }
- If Alias =
- {
- SoundNumber ++
- Alias = AutoHotkey%SoundNumber%
- }
- ErrorLevel := _mciExecute("open """ File """ alias " Alias)
- Return Alias
- }
- Media_Close(MediaHandle){
- Return _mciExecute("close " MediaHandle)
- }
- Media_Play(MediaHandle, Wait=0){
- If(Wait <> 0 AND Wait <> 1)
- Return -2
- If Wait = 1
- Return _mciExecute("play " MediaHandle " wait")
- Else
- Return _mciExecute("play " MediaHandle)
- }
- Media_Stop(MediaHandle){
- ret := _mciExecute("seek " MediaHandle " to start")
- ret := ret && _mciExecute("stop " MediaHandle)
- Return ret
- }
- Media_Pause(MediaHandle){
- Return _mciExecute("pause " MediaHandle)
- }
- Media_Resume(MediaHandle){
- Return _mciExecute("resume " MediaHandle)
- }
- Media_Length(MediaHandle){
- rc := _mciSendString("set time format milliseconds", dummy)
- If !rc
- Return -rc
- _mciSendString("status " MediaHandle " length", ret)
- Return ret
- }
- Media_Seek(MediaHandle, Position, Relative=0){
- rc := _mciSendString("set time format milliseconds", dummy)
- _mciSendString("status " MediaHandle " mode", stat)
- If stat = playing
- _mciExecute("pause " MediaHandle)
- If !rc
- Return -rc
- _mciSendString("status " MediaHandle " position", cpos)
- _mciSendString("status " MediaHandle " length", length)
- If Relative = 1
- cpos += Position
- Else
- cpos := Position
- If cpos > %length%
- cpos = %length%
- If cpos < 0
- cpos = 0
- ret := _mciExecute("seek " MediaHandle " to " cpos)
- If stat = playing
- _mciExecute("play " MediaHandle)
- Return ret
- }
- Media_Status(MediaHandle){
- _mciSendString("status " MediaHandle " mode", ret)
- Return ret
- }
- Media_Position(MediaHandle){
- rc := _mciSendString("set time format milliseconds", dummy)
- If !rc
- Return -rc
- _mciSendString("status " MediaHandle " position", ret)
- Return ret
- }
- Media_ToMilliseconds(Hour, Min, Sec){
- milli := Sec * 1000
- milli += (Min * 60) * 1000
- milli += (Hour * 3600) * 1000
- Return milli
- }
- Media_ToHHMMSS(milliseconds, ByRef Hour, ByRef Min, ByRef Sec){
- milliseconds //= 1000
- Sec := Mod(milliseconds, 60)
- milliseconds //= 60
- Min := Mod(milliseconds, 60)
- milliseconds //= 60
- Hour := Mod(milliseconds, 60)
- }
- _mciExecute(string){
- Return DllCall("winmm.dll\mciExecute", "str", string, "Cdecl Int")
- }
- _mciSendString(string, ByRef output, handle=0){
- VarSetCapacity(output, 36, 0)
- ret := DllCall("winmm.dll\mciSendStringA", "str", string, "str", output, "int", 36, "uint", 0, "Cdecl Int")
- If ErrorLevel
- Return -ErrorLevel
- Return ret
- }
- #Persistent
- #SingleInstance force
- SetBatchLines, 10ms
- CoordMode, ToolTip
- IfNotExist, QuickSound.ini
- {
- Playcount = 0
- atrue=t
- IniWrite, %PlayCount%, Quicksound.ini, Playlist, Playcount
- IniWrite, %atrue%, Quicksound.ini, PlayRandom, PlayRandom
- Gui, Add, Text, x6 y0 w450 h130 ,
- (
- I see you are a First time user of QuickSound!`n`nTo use simply press F1`, type in your song and hit Enter and the song will load.
- You will need to`nset your File path of music First though.
- )
- Gui, Add, Text, x6 y170 w440 h100 ,
- (
- If ToolTip Mode is set to 0 no ToolTip will appear.`n If set to 1 will display song `nIf set to 2 will display song and path directory
- `nIf set to 3 will display song with your static ToolXY coordinates`n If set to 4 will display song and
- path directory with your stationery ToolXY coordinates
- )
- Guide =
- (
- F1
- Type in part of a song name, it will play when you press enter (first match)
- F2
- Opens music list
- F3
- Type in where in the song you want to seek to
- F4
- Update music list
- F5
- Next random song
- F6
- Set ToolTip area
- F7
- Open current songs directory
- F8
- Open QuickSound.ini (you will understand later if you don't know :P)
- F9
- Opens programs directory
- F10
- Add song to playlist
- F11
- Play song from Playlist (random if playlist mode is already on)
- After pressing OK this text will save itself to a help document.
- )
- Gui, Add, Text, x456 y0 w470 h380 , %Guide%
- Gui, Add, Radio, vToolMode x25 y319 w100 h30 , 0
- Gui, Add, Radio, checked x25 y349 w100 h30 , 1
- Gui, Add, Radio, x25 y379 w100 h30 , 2
- Gui, Add, Text, x195 y469 w250 h30 , Set Music path
- Gui, Add, Edit, vPath x195 y499 w140 h30 , C:\Music
- Gui, Add, Edit, vToolX x150 y364 w140 h30 , ToolX(numbers)
- Gui, Add, Edit, vToolY x150 y404 w140 h30 , ToolY(numbers)
- Gui, Add, Button, gOk x506 y430 w340 h120 , OK
- Gui, Show, x131 y91 h605 w928, QuickSound
- FileDelete, Guide.txt
- FileAppend, %Guide%, Guide.txt
- Return
- }
- IfExist, QuickSound.ini
- {
- IniRead, Path, QuickSound.ini, Path, Path
- }
- Gosub, UpdateMusic
- Gosub, RandomSong
- Return
- F1::
- PlayMusic:
- Exit = true
- ;Gosub, ToolTipMp3
- Input, UserInput, T30,{Enter}{ins}
- IfEqual,userInput,, Return
- endkey=%Errorlevel%
- Loop, read, mp3s.txt
- {
- mp3 = %A_LoopReadline%
- Found = Yes
- Loop, Parse, UserInput, %a_Space%
- IfNotInString, mp3, %A_LoopField%, SetEnv, Found, No
- IfEqual, Found, Yes
- {
- If hSound {
- Media_Close(hSound)
- }
- hSound := Media_Open(mp3, "myfile")
- Found = No
- Break
- }
- }
- Gosub, MyPause
- Goto, ToolTipMP3
- Return
- Pause::
- MyPause:
- Status := Media_Status(hSound)
- If(Status = "stopped" OR Status = "Paused")
- {
- If Status = stopped
- Media_Play(hSound)
- Else
- Media_Resume(hSound)
- playing = 1
- }Else{
- Media_Pause(hSound)
- playing = 0
- }
- Return
- F2::
- Run mp3s.txt
- Return
- F3::
- Input, Seek,,{Enter}
- StringLen, Length, Seek
- If Length = 4
- {
- StringLeft, MinS, Seek, 2
- StringRight, SecS, Seek, 2
- }
- Else If Length = 3
- {
- StringLeft, MinS, Seek, 1
- StringRight, SecS, Seek, 2
- }
- Else If Length = 2
- StringRight, SecS, Seek, 2
- Else If Length = 1
- StringRight, SecS, Seek, 1
- Seek := SecS * 1000
- Seek += (MinS * 60) * 1000
- Media_Seek(hSound, Seek)
- Return
- RandomSong:
- IniRead, Count, QuickSound.ini, Count, Count
- If hSound {
- Media_Stop(hSound)
- Media_Close(hSound)
- }
- IniRead, PlayRandom, Quicksound.ini, PlayRandom, PlayRandom
- if (PlayRandom = "t")
- {
- Random, Rand, 1, %Count%
- FileReadLine, Mp3, mp3s.txt, %Rand%
- }
- else if (PlayRandom ="f")
- {
- IniRead, Playcount, Quicksound.ini, Playlist, Playcount
- Playcount++
- IniWrite, %Playcount%, Quicksound.ini, Playlist, Playcount
- IniRead, PlayListSize, Quicksound.ini, Playlist, PlayListSize
- if (Playcount>PlayListSize) {
- Playcount = 1
- Iniwrite, %Playcount%, Quicksound.ini, Playlist, Playcount
- }
- FileReadLine, Mp3, playlist1.txt, %Playcount%
- }
- hSound := Media_Open(Mp3, "myfile")
- Gosub, MyPause
- Gosub, ToolTipMP3
- Gosub, RandomSong
- Return
- F4::
- UpdateMusic:
- Count = 0
- FileDelete, mp3s.txt
- Fileappend, , mp3s.txt
- Loop, %path%, 0,1
- {
- mp3 := A_loopfilename
- Splitpath, mp3,,,Extension
- if (Extension != "mp3" && Extension != "wma")
- Continue
- else
- {
- FileAppend, %a_loopfilefullpath%`n, mp3s.txt
- Count++
- }
- }
- Count -= 1
- IniWrite, %Count%, QuickSound.ini, Count, Count
- Tooltip, Ready%a_tab%%a_tab%%a_tab%`n`n`n`n%a_space%
- Sleep 1000
- Tooltip
- Return
- F5::
- Next:
- Media_Seek(hSound, Media_Length(hSound))
- Return
- ExitSub:
- If hSound {
- Media_Close(hSound)
- }
- ExitApp
- Return
- Return
- ToolTipMP3:
- if (Exit = true)
- Exit
- Exit = false
- Gosub, sNameTrim
- len := Media_Length(hSound)
- Loop {
- IniRead, ToolMode, QuickSound.ini, ToolMode, ToolMode
- IniRead, ToolX, QuickSound.ini, ToolX, ToolX
- IniRead, ToolY, QuickSound.ini, ToolY, ToolY
- Sleep 100
- pos := Media_Position(hSound)
- If(pos >= len){
- Break
- }
- Media_ToHHMMSS(pos, hh, mm, ss)
- Media_ToHHMMSS(len, hh, lm, ls)
- If (ToolMode = 0)
- ToolTip
- Else If (ToolMode = 1)
- ToolTip, %sName%`n%mm%:%ss% / Length %lm%:%ls%, %ToolX%, %ToolY%
- Else If (ToolMode = 2)
- ToolTip, %sName%`n%mm%:%ss% / Length %lm%:%ls%`n%mp3%, %ToolX%, %ToolY%
- }
- IniWrite, %mp3%, QuickSound.ini, Mp3Playing, Mp3Playing
- Return
- Ok:
- Gui, Submit
- Path = %Path%\*.*
- IniWrite, %Path%, QuickSound.ini, Path, Path
- IniWrite, %ToolX%, QuickSound.ini, ToolX, ToolX
- IniWrite, %ToolY%, QuickSound.ini, ToolY, ToolY
- IniWrite, %ToolMode%, QuickSound.ini, ToolMode, Toolmode
- Gosub, UpdateMusic
- Gosub, RandomSong
- Return
- F6::
- MouseGetPos, ToolX, ToolY
- IniWrite, %ToolX%, QuickSound.ini, ToolX, ToolX
- IniWrite, %ToolY%, QuickSound.ini, ToolY, ToolY
- Return
- F7::
- Splitpath, Mp3, , Mp3Dir
- Run %Mp3Dir%
- Return
- f8::
- Run QuickSound.ini
- return
- f9::
- Run %a_scriptdir%
- return
- F10::
- FileRead, NoDoubles, playlist1.txt
- IfNotInString, NoDoubles, %mp3%
- {
- Fileappend, %mp3%`n, playlist1.txt
- IniRead, PlayListSize, Quicksound.ini, Playlist, PlaylistSize
- PlayListSize++
- IniWrite, %PlayListSize%, Quicksound.ini, Playlist, PlaylistSize
- }
- Return
- PgUp::
- Gosub, ListReadWrite
- Gosub, PlayfromList
- Return
- PgDn::
- Pagedown:
- Gosub, ListReadWrite
- Gosub, PlayfromList
- Return
- PlayfromList: ;() {
- FileReadLine, Mp3, playlist1.txt, %Playcount%
- If hSound {
- Media_Close(hSound)
- }
- hSound := Media_Open(Mp3, "myfile")
- Media_Play(hSound)
- Gosub, sNameTrim
- len := Media_Length(hSound)
- Media_ToHHMMSS(pos, hh, mm, ss)
- Media_ToHHMMSS(len, hh, lm, ls)
- Return ;}
- ListReadWrite: ;() {
- IniRead, PlayListSize, Quicksound.ini, Playlist, PlaylistSize
- IniRead, Playcount, Quicksound.ini, Playlist, Playcount
- if (A_ThisHotkey="PgUp")
- Playcount-=1
- if (A_ThisHotkey="PgDn")
- Playcount+=1
- if (Playcount=0)
- Playcount := PlayListSize
- if (Playcount>PlayListSize)
- Playcount = 1
- IniWrite, %Playcount%, Quicksound.ini, Playlist, Playcount
- Return ;}
- sNameTrim:
- StringLen, sLength, mp3
- StringGetPos, cTrim, mp3, \, R1
- cTrim += 2
- fName := (sLength+1) - cTrim
- StringMid, sName, mp3, %cTrim%, %fName%
- Return
Advertisement
Add Comment
Please, Sign In to add comment