Scripts: Get message of Popup Alert MT4 using

 

Get message of Popup Alert MT4 using:

this Script will get content message from Popup Alert dialog

Author: Nguyen Quoc Hung

 
Thanks for posting, this has been very helpful.  Would you happen to know if there's a way to also extract the alert time?
 
NS97 #:
Thanks for posting, this has been very helpful.  Would you happen to know if there's a way to also extract the alert time?
To extract the alert time you have to get content of msg from listbox instead of textbox
 
bro I tried getting the time a lot but I am not achieving any success. when I use the list box which has the class name SysListView32, the string saves list1. not its contents. please kindly help me how to get the exact alert time. 
 
Ohammad Shajidul Sheikh Shajid #:
bro I tried getting the time a lot but I am not achieving any success. when I use the list box which has the class name SysListView32, the string saves list1. not its contents. please kindly help me how to get the exact alert time. 
show your code
 
Nguyen Quoc Hung #:
show your code

#define WM_GETTEXTLENGTH 0xE

#define WM_GETTEXT 0xD


#import "user32.dll"


int FindWindowW(string lpClassName, string lpWindowName);

int FindWindowExW(int hWnd1, int hWnd2, string lpsz1, string lpsz2);

int SendMessageA(int hwnd, int wMsg, int wParam, int lParam);

int SendMessageA(int hwnd, int wMsg, int wParam, char &lParam[]);


void GetAndSaveAlertMsgContent()

{

    int Hwnd = 0;  // handle of parent window

    int CHwnd = 0; // handle of textbox


    Hwnd = FindWindowW("#32770", "Alert");

    Print(FUNCTION, "--> Parent handle = " + (string)Hwnd);


    CHwnd = FindWindowExW(Hwnd, 0, "SysListView32", NULL);

    Print(FUNCTION, "--> Child handle = " + (string)CHwnd);


    int textLength = SendMessageA(CHwnd, WM_GETTEXTLENGTH, 0, 0);

    Print(FUNCTION, "--> Text Length = " + (string)textLength);


    char ch[512];  // Ensure enough capacity for the retrieved text

    ArrayInitialize(ch, 0x000);


    int length = SendMessageA(CHwnd, WM_GETTEXT, textLength + 1, ch);


    string contentMsg = "";

    for (int j = 0; j < length; j++)

        contentMsg += CharToString(ch[j]);


    Print(FUNCTION, "--> Content Message = " + contentMsg);


    datetime currentTime = TimeCurrent();

    string currentTimeString = TimeToStr(currentTime, TIME_DATE | TIME_MINUTES);


    string msgwithtime = currentTimeString + " " + contentMsg;



}


 
Ohammad Shajidul Sheikh Shajid #:

#define WM_GETTEXTLENGTH 0xE

#define WM_GETTEXT 0xD


#import "user32.dll"


int FindWindowW(string lpClassName, string lpWindowName);

int FindWindowExW(int hWnd1, int hWnd2, string lpsz1, string lpsz2);

int SendMessageA(int hwnd, int wMsg, int wParam, int lParam);

int SendMessageA(int hwnd, int wMsg, int wParam, char &lParam[]);


void GetAndSaveAlertMsgContent()

{

    int Hwnd = 0;  // handle of parent window

    int CHwnd = 0; // handle of textbox


    Hwnd = FindWindowW("#32770", "Alert");

    Print(FUNCTION, "--> Parent handle = " + (string)Hwnd);


    CHwnd = FindWindowExW(Hwnd, 0, "SysListView32", NULL);

    Print(FUNCTION, "--> Child handle = " + (string)CHwnd);


    int textLength = SendMessageA(CHwnd, WM_GETTEXTLENGTH, 0, 0);

    Print(FUNCTION, "--> Text Length = " + (string)textLength);


    char ch[512];  // Ensure enough capacity for the retrieved text

    ArrayInitialize(ch, 0x000);


    int length = SendMessageA(CHwnd, WM_GETTEXT, textLength + 1, ch);


    string contentMsg = "";

    for (int j = 0; j < length; j++)

        contentMsg += CharToString(ch[j]);


    Print(FUNCTION, "--> Content Message = " + contentMsg);


    datetime currentTime = TimeCurrent();

    string currentTimeString = TimeToStr(currentTime, TIME_DATE | TIME_MINUTES);


    string msgwithtime = currentTimeString + " " + contentMsg;



}


what do want to get data from listview for ? 
Reason: