Hello
I don't see any mouseclick events in the wiki. Any one is using it?
Is Mouse click events only for MC.Net?
I want to test for,
- Grab price of a given bar
- Set a variable that will enable an indicator to be restart... 1' line of code being test the variable value
Martin
Mouseclick events
Re: Mouseclick events
Hello
Did try
My understanding is that If left mouseclick and CTRL key is press, the condition should be true and the Playsound should be activated.
No event triggerd
Do we need to enable the event?
Can we cancel event lookout?
Martin
Did try
Code: Select all
if MouseClickCtrlPressed then PlaySound ("C:\Users\Utilisateur\Documents\Bourse\Sound\Going Short.wav")
No event triggerd
Do we need to enable the event?
Can we cancel event lookout?
Martin
Re: Mouseclick events
You need [ProcessMouseEvents = True]; at the begin of the code.
Posted an example how to use here :
viewtopic.php?f=5&t=10067
and one here (sef file without source code)
viewtopic.php?f=5&t=9984
Posted an example how to use here :
viewtopic.php?f=5&t=10067
and one here (sef file without source code)
viewtopic.php?f=5&t=9984
Re: Mouseclick events
Thank youYou need [ProcessMouseEvents = True]; at the begin of the code.
Posted an example how to use here :
viewtopic.php?f=5&t=10067
and one here (sef file without source code)
viewtopic.php?f=5&t=9984
I did test the code with
Code: Select all
[ProcessMouseEvents = True];
if MouseClickCtrlPressed then begin
[ProcessMouseEvents = false];
PlaySound ("C:\Users\Utilisateur\Documents\Bourse\Sound\Going Short.wav");
[ProcessMouseEvents = true];
end;
Any idea how to avoid that?
Martin
Re: Mouseclick events
Use a intrabarpersist vars to play the sound only once. To recalculate your study take a look a ReCalcPersist and ReCalculate.
Code: Select all
[ProcessMouseEvents = True];
variables:
intrabarpersist Sound(false),ReCalcPersist recalc_once(True);
Once begin
Sound = True;
end;
if MouseClickCtrlPressed and LastBarOnChart_s and Sound = true then
begin
PlaySound ("C:\Users\Utilisateur\Documents\Bourse\Sound\Going Short.wav");
Sound = false;
If recalc_once Then
Begin
Print ("Recalculate study!");
recalc_once = False ;
ReCalculate;
End;
end;
Re: Mouseclick events
Hello and thanksUse a intrabarpersist vars to play the sound only once. To recalculate your study take a look a ReCalcPersist and ReCalculate.
Code: Select all
[ProcessMouseEvents = True];
variables:
intrabarpersist Sound(false),ReCalcPersist recalc_once(True);
Once begin
Sound = True;
end;
if MouseClickCtrlPressed and LastBarOnChart_s and Sound = true then
begin
PlaySound ("C:\Users\Utilisateur\Documents\Bourse\Sound\Going Short.wav");
Sound = false;
If recalc_once Then
Begin
Print ("Recalculate study!");
recalc_once = False ;
ReCalculate;
End;
end;
What is the the usage of ReCalcPersist recalc_once(True); doing in it
I did look in the the Powerlanguage help, but I don't catch it
Martin
Re: Mouseclick events
Negative, same problem. I did try to add the [ProcessMouseEvents = False]; before Playsound and re-enabled it after, but no changeUse a intrabarpersist vars to play the sound only once. To recalculate your study take a look a ReCalcPersist and ReCalculate.
Code: Select all
[ProcessMouseEvents = True];
variables:
intrabarpersist Sound(false),ReCalcPersist recalc_once(True);
Once begin
Sound = True;
end;
if MouseClickCtrlPressed and LastBarOnChart_s and Sound = true then
begin
PlaySound ("C:\Users\Utilisateur\Documents\Bourse\Sound\Going Short.wav");
Sound = false;
If recalc_once Then
Begin
Print ("Recalculate study!");
recalc_once = False ;
ReCalculate;
End;
end;
It seem like the only way to cancel The Clickevent is to leftclick without clicking on the CTRL key. Otherwise, message is played for X amount of time
In electronic, we called that a re bounce on a switch. The PC is to fast and a lecture is done and record a multiple of time during the pressing down CTRL event.
Ways to compensate or resolve this problem is to add a capacitor + resistance to create an integrator.... but not applicable here. Or add a delay using code to allow only one lecture in a given time like 20 ms. Once click, no other reading of the keyboard should be allowed before the elapse of the delay. The delay should not be visible to the user and not slow down the code. This coding should be done at MC level. This would resolve the problem I think.
Martin
Re: Mouseclick events
I dont understand why you want to set [ProcessMouseEvents = False]; ?
If you want to reset the sound to be ready for one of the next click, add one more line
If MouseClickShiftPressed then Sound = true;
So if you press MouseClickCtrlPressed the sound appears one time, then use MouseClickShiftPressed to reset and if you press MouseClickCtrlPressed the sound plays one more time (and only one beep, not 3 ) and so on. Keep in mind to click on the chart, not on the subchart.
or for the next bar without MouseClick
if barstatus ( 1 ) = 2 then Sound = true;
If you want to reset the sound to be ready for one of the next click, add one more line
If MouseClickShiftPressed then Sound = true;
So if you press MouseClickCtrlPressed the sound appears one time, then use MouseClickShiftPressed to reset and if you press MouseClickCtrlPressed the sound plays one more time (and only one beep, not 3 ) and so on. Keep in mind to click on the chart, not on the subchart.
or for the next bar without MouseClick
if barstatus ( 1 ) = 2 then Sound = true;
Re: Mouseclick events
That was only for a test to see if the event was canceling while other procedure was taking place. I use this kind of canceling event in Excel VBA and in Micro- controler cpu chips at the start or a procedure to make sure that a new event won't disturb in anyway what I'm actually doing at the moment, but it look like MC does not response in the same manners.I dont understand why you want to set [ProcessMouseEvents = False]; ?
If you want to reset the sound to be ready for one of the next click, add one more line
If MouseClickShiftPressed then Sound = true;
So if you press MouseClickCtrlPressed the sound appears one time, then use MouseClickShiftPressed to reset and if you press MouseClickCtrlPressed the sound plays one more time (and only one beep, not 3 ) and so on. Keep in mind to click on the chart, not on the subchart.
or for the next bar without MouseClick
if barstatus ( 1 ) = 2 then Sound = true;
Martin