Jump to content

Recommended Posts

Posted

Simple example:

$dir = StringTrimRight(@AutoItExe, 8)
FileChangeDir($dir)
FileInstall("chimes.wav", "chimes_sound.wav")
SoundPlay("chimes_sound.wav")
Sleep(6000)
FileDelete("chimes_sound.wav")
For some reason, it won't delete 'chimes_sound.wav'. Why?

(Chimes.wav can of course be found in C:\Windows\Media)

iPod + Online calendars = iPodCALsync

Posted

This works for me.

Const $AUTOITDIR = _AutoItDir()

If FileChangeDir($AUTOITDIR) Then
    FileInstall('chimes.wav', 'chimes_sound.wav')
    SoundPlay('chimes_sound.wav')
    Sleep(6000)
    SoundPlay('')
    If FileDelete('chimes_sound.wav') Then
        MsgBox(0, @ScriptName, 'FileDelete Successful')
    EndIf
EndIf

Exit

Func _AutoItDir()
    Return StringLeft(@AutoItExe, StringInStr(@AutoItExe, '\', 0, -1)-1)
EndFunc

Seems like your perhaps leaving a handle open on the wav file which locks it, so the FileDelete() fails. Calling SoundPlay() again with a empty string parameter tends to close the handle and FileDelete() succeeds.

If you do set the optional wait parameter to 1 for SoundPlay(), then it seems to close the handle upon return of the function call so FileDelete() succeeds.

:P

Posted

HI,

problem is your SoundPlay() the the flag to wait until the sound is done.

The first line is also ... :nuke::P ...

Have a look

$dir = StringTrimRight(@AutoItExe, 8)
MsgBox(0,"",$dir)
ConsoleWrite("FCD: " & FileChangeDir($dir)) ; 1 success
ConsoleWrite("FI: " & FileInstall(@WindowsDir & "\Media\chimes.wav", @ScriptDir & "\chimes_sound.wav", 1)) ; 1 success
SoundPlay("chimes_sound.wav", 1)
If FileExists(@ScriptDir & "\chimes_sound.wav") Then ConsoleWrite("FD: " & FileDelete(@ScriptDir & "\chimes_sound.wav")) ; 1 succes

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted

Fixed.

I declare my program hereby for finished! :P

Kudos! Share it :-)

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...