SetFocus / SendMessage Error when clicked taskbar.

 

I made an indicator that can automatically put ea to chart.

If i click windows taskbar (bottom), the indicator loses focus and the setfocus,key_event cannot work anymore.


Is there any function that can setfocus over the taskbar?

I tried SetForegroundWindow and ShowWindow BringWindowToTop ..etc. no one works.


I imagine an indicator / ea that can change chart's ea freely.

This source cannot work when I clicked taskbar.


///////////////////////////////////////


int t_handle=GetAncestor(WindowHandle(Symbol(),Period()),2);

   Print("Focus : ",SetFocus(t_handle)," ",t_handle);   


//  The EA's hotkey is Ctri+1

      keybd_event(VK_CONTROL,0,0,0);

      keybd_event(VK_1,0,0,0);


      keybd_event(VK_1,0,KEYEVENTF_KEYUP,0);

      keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);

BringWindowToTop function (Windows)
  • msdn.microsoft.com
Brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated. Syntax Parameters hWnd [in] A handle to the window to bring to the top of the Z order. Return value Type: If the function...
Reason: