PlaySound and Alert

 
I'm trying to produce some alerting mechanisms in my EA and ran across some funny behavior. When I use the Alert function and the PlaySound function together, then the Alert function seems to supercede the PlaySound function, which doesn't kick off. So, as an example, if I have the following 3 functions all enabled:

Alert();
PlaySound();
SendMail();

The Alert and SendMail functions work, but not PlaySound. If I disable the Alert() function, then PlaySound works fine. It also works fine with MessageBox(), though, I prefer the Alert function.

1. Is there a way to get these functions to work together? I am referencing a different WAV file in PlaySound() then the one used by Alert().
2. Is there a way to get the Alert() function to use a different WAV file?
3. Is it possible to use an MP3 file with the PlaySound function?

Thanks.

stockwet
 
Hello. I was just wondering whether this is an unanswerable question, or just a dumb question? I searched to see if it had already been asked, but, never found anything similar. Does anyone have ideas regarding the functionality of the Alert() vs PlaySound() and why they would, seemingly, conflict?
 
Hello,

I am looking also for the same answer, but I have an idea about this, and it is that the commands are triggered too fast to allow both sounds to play in sequence. .. there should be some delay time to add for the playsound, like 10 seconds which seems to be the usual minimum as per the Alert tab in the terminal.

The only way to have a different file playing as "alert" would be to rename it to alert.wav as I'm afraid the code is set up like that.

Only *.wav files work with the Playsound, but anyway those would be short-time files so the *.wav length of file is not that heavy.

Have you tried Playsound twice instead? Just thought this could work, I am going to try it.

Hope it helps.

P.S. Thinking of it... both might work but won't activate the alert window :(

.
 
stockwet:
2. Is there a way to get the Alert() function to use a different WAV file?

Thanks.

stockwet
Found this: 'Secrets of MetaTrader 4 Client Terminal: Alerting System'
 
try this method

Alert();
Sleep(500); // waiting a half second
PlaySound();
SendMail();
 
Thank you very much, I will try it as soon as markets open :)
 
Use script and you no need waiting of markets opening.
 
Thank you!

I read about the "sleep" function and it says it won't work in an indicator. .. is there any other way to place Alert and Playsound to play one after the other in an indicator?

Thanks in advance.
 
Hi guys,

I am just unable to send an e-mail during int start (). Is there any thing I am missing? I thought that just this function call SendMail ("MT4 START", " Looking for HELP"+DoubleToStr(Ask,Digits)); would send me an e-mail, but....

Detail: if I use this call SendMail("MT4 START", " Looking for HELP"+DoubleToStr(Ask, Digits)); at int init(), I do receive an-email every time that my EA starts.

Thanks a lot.
 
Ok,

Let me be clearer: If I look at this small program bellow, I would guess that I should receive two e-mails. However, I am receiving just one e-mail from the initialization part of the program. Moreover, the sound "alert.wav" doesn't play at all. So please, could someone help me here. Thank you a lot.

Cheers,

__________________________
int init()
{
PlaySound ("phone.wav");
SendMail("Init", "Yes Ok");
return(0);
}

int start()
{
PlaySound ("alert.wav");
SendMail("Start", "No Ok");
return (0);
}
__________________________
 
brspMA:
Ok,

Let me be clearer: If I look at this small program bellow, I would guess that I should receive two e-mails. However, I am receiving just one e-mail from the initialization part of the program. Moreover, the sound "alert.wav" doesn't play at all. So please, could someone help me here. Thank you a lot.



Your whole program runs in about one millionth of a second, so probably phone.wav is still playing, when you want to play alert.wav and it seems the sounds are not cacheing. This is may be the same with the emails. Use it as an EA instead of script and wait for a new tick.
Reason: