Nice, its a very good program, but I see a little bug: When I cklick somewhere in the chart, outside of the button!! and then I draw the mousepointer on the button (without click! on the button) then is triggered the message "right away!" Thats wrong! The message should appear only after click on the button! Where is the solution that this message appears only! after click the button!?
Nice day!
traderdoc
Hello.. thanks to the Author: Russell
i've been looking for this function for so long
i've try to modify the code.. this is a simple EA that i create.
but there is 1 problem.. the button still executed even the MT4 window is in background.
as example..when i browsing.. suddenly the button is working if i click the right cordinates
//+------------------------------------------------------------------+ //| mousetest.mq4 | //| Copyright © 2008, Berkers Trading | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, Berkers Trading" #property link "http://www.metaquotes.net" #include <WinUser32.mqh> //adjusted!! #include <cfunctions_v1.0.1.mqh> #import "user32.dll" #define VK_LBUTTON 0x01 //Left mouse button #define VK_RBUTTON 0x02 //Right mouse button int init(){ start(); return(0); } int deinit(){ ObjectDelete("t"); return(0); } int start() { int iCoords[2], iCoordsPrevious[2],hWin,liKS; static double ldBid, ldPollTime; int liTC, liCompareTime; bool clicked=0; bool ok; Print("Start Polling Mouse"); while(true) { Comment(" x = "+iCoords[0] +" \n y ="+iCoords[1] ); ObjectCreate("t", OBJ_LABEL, 0, 0,0); ObjectSet("t", OBJPROP_CORNER,4); ObjectSet("t", OBJPROP_XDISTANCE ,200); ObjectSet("t", OBJPROP_YDISTANCE ,60); ObjectSet("t", OBJPROP_BACK ,0); ObjectSetText("t","g" ,10,"Webdings",Red); hWin = WindowHandle( Symbol(), Period()); MT4_ScreenToClient(hWin, iCoords); ok=0; string sym=""; if ( !clicked && iCoords[0] > 200 && iCoords[0] < 215 && iCoords[1] > 60 && iCoords[1] < 75 ) {ok=1; sym=Symbol(); ObjectSetText("t","g" ,10,"Webdings",Yellow); } if(ok &&GetAsyncKeyState(VK_RBUTTON)>0||GetAsyncKeyState(VK_LBUTTON)>0) {PlaySound("ok.wav"); Sleep (100); Alert(sym); } if( GetAsyncKeyState(VK_RBUTTON)>0||GetAsyncKeyState(VK_LBUTTON)>0) clicked=1; else clicked=0; Sleep(100); } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Capture MouseEvents on Chart:
Author: Russell