Get the lotsize number on oneclick window in mt4

 
Have anyone here used the FindWindowA function yet, I passed the class name and window name parameters but couldn't get the hwnd from this window, someone help me please
//--
#import "user32.dll"
  int FindWindowExA(int hwndParent, int hwndChildAfter,char &lpszClass[],char &lpszWindow[]);
  int FindWindowExW(int hwndParent, int hwndChildAfter,string lpszClass,string lpszWindow);
  int GetActiveWindow();
#import
 
#define HWND_MESSAGE -3
#include <WinUser32.mqh>

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{

    //--
    return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{ 
    ObjectsDeleteAll();
}  
//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick()
{
    GetLotValueFromOneClick(); 
    //Print(GetActiveWindow());
} 
//------------------------------------------------------- Method 04 -- (Hàm để lấy giá trị số lot từ OneClick)
double GetLotValueFromOneClick()
{
    double lotSize = 0;
    string lotString;
    char buffer[256], classname[256], windowname[256];
    StringToCharArray("Edit",classname);
    StringToCharArray(NULL,windowname);
    //--------------------------------------------------------- 4.1 -- (Tìm cửa sổ OneClick, MT4 build 1380, 24/3/2023) 0x000F0796
    int hwnd = FindWindowA(classname,windowname); // int hwnd = 0x000F0796;
    if (hwnd == 0)
    {
        Print("No founed OneClick window in MT4");
        return(0);
    }
    //--------------------------------------------------------- 4.2 -- (Lấy dữ liệu từ cửa số OneClick)
    int result = GetWindowTextA(hwnd, buffer, 256);
    if (result > 0)
    {
        
        lotString = CharArrayToString(buffer);
        lotSize = StrToDouble(lotString);
    }
    else Print("Failed to get lot value from OneClick window");
    return(lotSize);
}
//+------------------------------------------------------------------+
       
 

Please don't post randomly in any section. Your question is not related to the section you posted.

MT4/mql4 has it's own section on the forum.

Your topic has been moved, please don't create another topic.

Reason: