Helo. I have problems with resume sound
Code:
;
; AutoHotkey Version: 1.0.47.00
; Language: Anyone
; Author: Fincs <fernandoincs@hotmail.com>
;
; Script Function:
; Functions to handle multimedia files
;
;===============================================================================
;
; Function Name: Sound_Open
; Description:: Opens a sound file for use with other sound functions
; Parameter(s): File - The sound file
; Alias [optional] - A name such as sound1, if you do not
; specify one it is automatically generated
; Return Value(s): The sound handle or a 0 to indicate failure
; ErrorLevel value: 0 - No Error
; 1 - Open failed
; 2 - File doesn't exist
;
;===============================================================================
Sound_Open(File, Alias=""){
Static SoundNumber = 0
IfNotExist, %File%
{
ErrorLevel = 2
Return 0
}
If Alias =
{
SoundNumber ++
Alias = AutoHotkey%SoundNumber%
}
Loop, %File%
File_Short = %A_LoopFileShortPath%
r := Sound_SendString("open " File_Short " alias " Alias)
If r
{
ErrorLevel = 1
Return 0
}Else{
ErrorLevel = 0
Return %Alias%
}
}
;===============================================================================
;
; Function Name: Sound_Close
; Description:: Closes a sound
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Return Value(s): 1 - Success, 0 - Failure
;
;===============================================================================
Sound_Close(SoundHandle){
r := Sound_SendString("close " SoundHandle)
Return NOT r
}
;===============================================================================
;
; Function Name: Sound_Play
; Description:: Plays a sound from the current position (beginning is the default)
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Wait - If set to 1 the script will wait for the sound to finish before continuing
; - If set to 0 the script will continue while the sound is playing
; Return Value(s): 1 - Success, 0 - Failure
;
;===============================================================================
Sound_Play(SoundHandle, Wait=0){
If(Wait <> 0 AND Wait <> 1)
Return 0
If Wait
r := Sound_SendString("play " SoundHandle " wait")
Else
r := Sound_SendString("play " SoundHandle)
Return NOT r
}
;===============================================================================
;
; Function Name: Sound_Stop
; Description:: Stops the sound
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Return Value(s): 1 - Success, 0 - Failure
;
;===============================================================================
Sound_Stop(SoundHandle){
r := Sound_SendString("seek " SoundHandle " to start")
r2 := Sound_SendString("stop " SoundHandle)
If(r AND r2)
{
Return 0
}Else{
Return 1
}
}
;===============================================================================
;
; Function Name: Sound_Pause
; Description:: Pauses the sound
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Return Value(s): 1 - Success, 0 - Failure
;
;===============================================================================
Sound_Pause(SoundHandle){
r := Sound_SendString("pause " SoundHandle)
Return NOT r
}
;===============================================================================
;
; Function Name: Sound_Resume
; Description:: Resumes the sound after being paused
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Return Value(s): 1 - Success, 0 - Failure
;
;===============================================================================
Sound_Resume(SoundHandle){
r := Sound_SendString("resume " SoundHandle)
Return NOT r
}
;===============================================================================
;
; Function Name: Sound_Length
; Description:: Returns the length of the sound
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Return Value(s): Length of the sound - Success
;
;===============================================================================
Sound_Length(SoundHandle){
r := Sound_SendString("set time format miliseconds", 1)
If r
Return 0
r := Sound_SendString("status " SoundHandle " length", 1, 1)
Return %r%
}
;===============================================================================
;
; Function Name: Sound_Seek
; Description:: Seeks the sound to a specified time
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Hour, Min, Sec - Time to seek to
; Return Value(s): 1 - Success, 0 - Failure,
;
;===============================================================================
Sound_Seek(SoundHandle, Hour, Min, Sec){
milli := 0
r := Sound_SendString("set time format milliseconds", 1)
If r
Return 0
milli += Sec * 1000
milli += Min * 1000 * 60
milli += Hour * 1000 * 60 * 60
r := Sound_SendString("seek " SoundHandle " to " milli)
Return NOT r
}
;===============================================================================
;
; Function Name: Sound_Status
; Description:: All devices can return the "not ready", "paused", "playing", and "stopped" values.
; Some devices can return the additional "open", "parked", "recording", and "seeking" values.(MSDN)
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Return Value(s): Sound Status
;
;===============================================================================
Sound_Status(SoundHandle){
Return Sound_SendString("status " SoundHandle " mode", 1, 1)
}
;===============================================================================
;
; Function Name: Sound_Pos
; Description:: Returns the current position of the song
; Parameter(s): SoundHandle - Sound handle returned by Sound_Open
; Return Value(s): Current Position - Success, 0 - Failure
;
;===============================================================================
Sound_Pos(SoundHandle){
r := Sound_SendString("set time format miliseconds", 1)
If r
Return 0
r := Sound_SendString("status " SoundHandle " position", 1, 1)
Return %r%
}
;===============================================================================
Sound_SendString(string, UseSend=0, ReturnTemp=0){
If UseSend
{
VarSetCapacity(stat1, 32, 32)
DllCall("winmm.dll\mciSendStringA", "UInt", &string, "UInt", &stat1, "Int", 32, "Int", 0)
}Else{
DllCall("winmm.dll\mciExecute", "str", string)
}
If(UseSend And ReturnTemp)
Return stat1
Else
Return %ErrorLevel%
}
ScriptName = Free blind player
Version=1.0
menu, tray, tip,Free blind player...
menu,tray,nostandard
menu,tray,add,go to player window,show
menu,tray,add,stop,mh4
menu,tray,add,exit,mh2
menu,tray,default,go to player window
Gui, -Sysmenu
#SingleInstance force
ifnotexist, %A_ScriptDir%\keys.txt
fileinstall, keys.txt, %A_ScriptDir%\keys.txt, 1
show:
Gui, Show, x200 y200 w200 h200,%scriptname%
menu,snd,add,vyhledat všechny mp3 soubory na disku c...,search
menu,snd,add,zvuky ve windows ...,sndwin
menu volby,add,zesílit o 5 procent,zes
menu, volby,add,zeslabit o 5 procent,zesl
Menu volby,add,přidat basy,ba
Menu volby, add,ubrat basy,baa
Menu,přehrávač1,add,složku...,ps
Menu,url,add,url,url
Menu,url,add,soubory,urlfiles
Menu,url,add,smazat soubory,urldelete
;
Menu,přehrávač1,add,URL,:url
menu,přehrávač1,Add,soubor...,MH1
Menu,Přehrávač1,add,znovu,snd1
Menu,Přehrávač1,Add,Stop,MH4
Menu,soubor,add,reset programu,res
Menu,soubor, Add
menu,soubor,Add,&konec,MH2
menu,okno,add,minimalizovat,min
Menu,obli,add,oblíbené...,obl2
Menu,obli,add,Přidat...,obl
Menu,obli,add,smazat,vyp
Menu,nastroje,add,velikost souboru...,vel
Menu,nastroje,add,hodiny...,hod
Menu,Nápověda3,Add,O aplikaci...,mh3
menu,nápověda3,add,Klávesové skratky,keys
menu,mymenu, add
menu,mymenu,add,Soubor,:soubor
menu,mymenu,add,zobrazit,:okno
menu,mymenu,Add,přehrát,:přehrávač1
Menu,mymenu,add,oblíbené,:obli
Menu,mymenu,add,nástroje,:nastroje
Menu, mymenu, Add, nastavení,:volby
menu,mymenu,add,doplňky,:snd
menu,myMenu,Add,nápověda,:nápověda3
menu,mymenu, add
return
sounds:
ps:
$^f::
IfWinNotActive, %ScriptName%
{
Send, ^f
Return
}
SoundPlay, Nonexistent.
FileSelectFolder SelectedFolder, , 3, (*.wav)
If SelectedFolder =
return
Else
{
Loop %SelectedFolder%\*.*,0,1
Soundplay %A_LoopFileFullPath%, WAIT
return
}
Return
MH1:
$^o::
IfWinNotActive, %ScriptName%
{
Send, ^o
Return
}
SoundPlay, Nonexistent.
FileSelectFile, SelectedFile, 2, , Otevři zvukový soubor, zvuky (*.WAV; *.mp3; *.rmi; *.mp1; *.mid; *.dat; *.m3u; *.amr; *.wmv; *.OGG; *.flac; *.wma; *.mp2; *.MPG)
if SelectedFile =
return
else
{
sleep, 2000
hSound := Sound_Open(selectedfile, "myfile")
Sound_Play(hSound)
playing = 1
}
Return
space::
status := Sound_Status(hSound)
If(status = "paused")
{
Sound_Resume(hSound)
playing = 1
}
Else
Sound_Pause(hSound)
playing = 0
Return
MH4:
$^s::
ifwinnotactive, %scriptname%
{
send, ^s
return
}
soundplay, nonexistent
tooltip,přehrávání,zastaveno,2
Return
SND1:
#include %A_ScriptDir%\inc\snd1.ahk
return
ba:
SoundSet, +5, Master, bass
; Increase bass level by 20%.
if ErrorLevel
MsgBox, 16, Chyba., Je mi líto,, ale váš zvukový ovladač nepodporuje změnu nastavení basů.
Return
baa:
SoundSet, -5, Master, bass
; Increase bass level by 20%.
if ErrorLevel
MsgBox, 16, chyba., Je mi líto,, ale váš zvukový ovladač nepodporuje změnu nastavení basů.
Return
;-= Quit =-
MH2:
exitApp
Return
^!r::Reload
; Assign Ctrl-Alt-R as a hotkey to restart the script.
Return
hod:
FormatTime, TimeString,, LongDate
FormatTime, TimeString, T12, Time
MsgBox, 64, čas., Je %TimeString%.
Return
vel:
Unit = M ; k
FileGetSize, Size, %selectedfile%, %Unit%
IFnotexist %SelectedFile%
MSGBOX, 64, info., Nevybrali jste žádný soubor.
else
MsgBox, 64, Info, Velikost přehrávaného souboru je: %Size% (%Unit%b)
Return
obl:
#include %A_ScriptDir%\inc\fav1.ahk
return
vyp:
#include %A_ScriptDir%\inc\del1.ahk
Return
res:
reload
Return
obl2:
#include %A_ScriptDir%\inc\fav2.ahk
return
URL:
#include %A_ScriptDir%\inc\url.ahk
return
zes:
SoundSet, +5 ; Win+Cursor up: master volume up
return
zesl:
SoundSet, -5 master volume up
Return
urlfiles:
Gui, 8:+owner1
; Make the main window (Gui #1) the owner of the "about box" (Gui #2).
Gui +Disabled
; Disable main window.
suspend
Gui, 8:-sysmenu
Loop %A_ScriptDir%\url\*.*
{
mp3List .= A_LoopFilename . "|"
}
StringTrimRight mp3List, mp3List, 1
Gui 8:Add, Listbox, w200 h300 vmp3Choice, %mp3List%
Gui 8:Add, Button, w100 xm+50 g8Play Default, hrej
Gui, 8:Add, button, w1, Návrat
Gui, 8:Show, w65, soubory z internetu
Return
8play:
Gui, 8:Submit, NoHide
If (mp3Choice = "")
{
MsgBox 16, chyba, nebyl vybrán žádný soubor!
}
Else
{
SoundPlay, %A_ScriptDir%\url\%mp3Choice%
}
return
8buttonnávrat:
8GuiClose:
8GuiEscape:
Gui, 1:-Disabled
Gui Destroy
suspend
Return
urldelete:
#include %A_ScriptDir%\inc\urldel.ahk
Return
#include %A_ScriptDir%\files.ahk
return
GuicontextMenu: ; Right click popup menu
Menu mymenu, Show ; Show context menu
return
int:
run, http://dsprogramy.ic.cz
Return
search:
Msgbox, 52, info., Chystáte se vyhledat všechny soubory na disku c. Pokud máte větší kapacitu disku bude program vyhledávat déle. Pokračovat?
IfMsgbox, yes
{
Gui, 4:+owner1
; Make the main window (Gui #1) the owner of the "about box" (Gui #2).
Gui +Disabled
; Disable main window.
suspend
Gui, 4:-sysmenu
AllDrives=C ; or just the drives to search.
FileList = ; Initialize to be blank.
Loop, Parse, AllDrives
{
Drive := A_LoopField
Loop, %Drive%:\*.mp3,0,1
{
FileList = %FileList%%A_LoopFileName%|
FileListWithPath = %FileListWithPath%%A_LoopFileFullPath%|
}
}
StringTrimRight, FileList, FileList, 1
StringTrimRight, FileListWithPath, FileListWithPath, 1
StringSplit, SongNum, FileListWithPath, |
Gui, 4:Add, ListBox, vselectedsong altsubmit, %FileList%
Gui 4:Add, Button, w100 vbut xm+50 gPlay Default, hrej
Gui, 4:Show,, My MP3's
Return
play:
Gui, 4:Submit, Nohide
SoundPlay, % (SongNum%SelectedSong%)
return
4GuiClose:
4GuiEscape:
Gui, 1:-Disabled
Gui Destroy
soundplay, nonexistent
suspend
Return
}
IfMsgbox, no
Return
return
sndwin:
gui, 6:-sysmenu
suspend
Loop %windir%\media\*.wav
{
mp3List .= A_LoopFileName . "|"
}
StringTrimRight mp3List, mp3List, 1
Gui 6:Add, ListBox, w200 h300 vmp3Choice, %mp3List%
Gui 6:Add, Button, w100 xm+50 g6Go Default, hrej
Gui 6:Show,, Zvuky ve windows
Return
6Go:
Gui 6:Submit, NoHide
If (mp3Choice = "")
{
MsgBox 16, chyba, Není vybrán zvuk.
}
Else
{
soundplay, %A_Windir%\media\%mp3Choice%
}
Return
6GuiClose:
6GuiEscape:
Gui, 1:-Disabled
Gui Destroy
soundplay, nonexistent
suspend
Return
min:
$#h::
ifwinnotactive, %scriptname%
{
send, #h
return
}
gui, hide
Return
plnh:
soundset, 100
soundset, 100
Return
$^up::
ifwinnotactive, %ScriptName%
{
send, {^up}
return
}
SoundSet +10
return
$^down::
ifwinnotactive, %ScriptName%
{
send, {^down}
return
}
SoundSet -10
Return
mh3:
Msgbox, 64, O programu., Free blind Player verze %version%. Vytvořil Vlček Pavel.
Return
keys:
$^k::
ifwinnotactive, %scriptname%
{
send, ^k
return
}
run, %A_ScriptDir%\keys.txt
Return
Problem is in mh3 and space.