Jump to content
Sign in to follow this  

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))
DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", $SND_RESOURCE)
return 1

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

Share this post

Link to post
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?


$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:



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



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

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By asiawatcher
      hi below i got one script i made which runs audacity starts a recording and ends it at specific times
      when i run the script even if it isn't the time to start audacity and sits idle on taskbar the pc fan gets very loud, when i close the script it comes back to normal 
      why this happens ? anything wrong with my code ?? cheers
      #include <INet.au3> #include <Array.au3> #include <WinAPIFiles.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <string.au3> #include <FTPEx.au3> #include <ClipBoard.au3> #include <date.au3> #include <ProgressConstants.au3> #include <IE.au3> #Include <Constants.au3> #Include <INET.au3> #include <SendMessage.au3> #include <File.au3> #include <String.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Misc.au3> #include <FileConstants.au3> #include <WinAPI.au3> while 1 if @HOUR = '11' And @MIN = '00' Then  Run("C:\Program Files (x86)\Audacity\audacity.exe", "", @SW_MAXIMIZE) SLEEP(2000) if ProcessExists("audacity.exe") Then winactivate("Audacity") EndIf      Send("r") ;;KREVATI Sleep(1000 * 60) endif if @HOUR = '23' And @MIN = '00' Then  if ProcessExists("audacity.exe") Then winactivate("Audacity") EndIf Send("s") Sleep(1000 * 60) EndIf wend  
    • By nacerbaaziz
      good morning autoit team
      please i need your help
      am trying to make an program that work with hotkeys
      it function is to change the volume to the current application
      e.g when i select the vlc window by using this hotkey i will be able to change the vlc volume with out changing the system volume.
       am able to get the process handle and the process name of the window
      but when am trying to get or set the volume i does not succeded
      i tried to search in this forums but no result.
      can you please guide me to do that.
      am waiting for your answers
      thanks in advanced
    • By v120
      Original posted by CoePSX
    • By Skeletor
      Hi All,
      It has been bugging me for a while now. 
      Can you view the AutoIt code from within a compiled exe. Like how you can with most .Net exe's by using a certain program.
      If this is possible, how then can I secure my program (if this method exists).
    • By ademon
      Hi. I can open the editor with out problems but I can not compile because it is placed on another partition diferent from C.
      Can you provide an update of this bug?

  • Create New...