Jump to content

Request a clarification in a function to play audio files from the compiled script


Recommended Posts

Hello all
I found this function in the Internet
It is to play audio files from  the compiled script
I did not understand just one thing on this function

func play($name, $wait = 0)
local Const $SND_RESOURCE = 0x00040004
local Const $SND_ASYNC = 1
; Play the file - the script will pause as it sounds
if $wait = 0 then
DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", BitOR($SND_RESOURCE, $SND_ASYNC))
else
DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", $SND_RESOURCE)
endIf
return 1
endFunc

What I did not understand was this variable

local Const $SND_RESOURCE = 0x00040004

I know that this variable is contains the resource name
But what if I want to change the name of the resource what i'll do?
can i do that?
Thanks in advance

 

Edited by nacerbaaziz
Link to comment
Share on other sites

4 hours ago, nacerbaaziz said:

I know that this variable is contains the resource name
But what if I want to change the name of the resource what i'll do?
can i do that?

@nacerbaaziz

$SND_RESOURCE does not contain the resource name.  It is a named, magic number, constant that tells the PlaySound function that the value identifying the sound is a resource ID as opposed to an alias or a file name.  Your questions don't seem to be related to AutoIt.  If you want to know more about the Win32 API PlaySound() function, you can start here:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd743680(v=vs.85).aspx

Or

Below is link to the help file for AutoIt's _WinAPI_PlaySound() function, which is a wrapper for the Win32 API PlaySound function.

https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_PlaySound.htm

 

If I'm wrong and your question is related to AutoIt, then please explain what it is, that relates to AutoIt, that you are having trouble understanding.

 

Edited by TheXman
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...