did you find the solution?
I have the same problem
thanks
Not quite sure what you want to do,
But here are code for useing Windows API user32.dll and shell32 to get an messagebox and execute external application / notepad...
// Import the MessageBoxW function from user32.dll #import "user32.dll" int MessageBoxW(int hWnd, string lpText, string lpCaption, int uType); #import // Import the ShellExecuteW function from shell32.dll (Unicode version) #import "shell32.dll" int ShellExecuteW(int hWnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd); #import // Windows API constants for button types and return values #define MB_YESNO 4 // Displays Yes and No buttons. #define IDYES 6 // Returned if the user clicks Yes. #define IDNO 7 // Returned if the user clicks No. //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { // Create a message to display string msg = "Do you want to launch Notepad?"; // Call the MessageBoxW function with MB_YESNO to display Yes/No buttons. int result = MessageBoxW(0, msg, "Launch Notepad", MB_YESNO); // Check the return value to see which button was clicked if(result == IDYES) { // Launch Notepad.exe using ShellExecuteW int execResult = ShellExecuteW(0, "open", "notepad.exe", "", "", 1); if(execResult > 32) Print("Notepad opened successfully."); else Print("Failed to open Notepad. Error code: ", execResult); } else if(result == IDNO) { Print("User chose not to launch Notepad."); } else { Print("Unexpected return value: ", result); } }
and an URL, Remember to add to to trusted site in settings in MQL5.
// Import the MessageBoxW function from user32.dll #import "user32.dll" int MessageBoxW(int hWnd, string lpText, string lpCaption, int uType); #import // Import the ShellExecuteW function from shell32.dll (Unicode version) #import "shell32.dll" int ShellExecuteW(int hWnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd); #import // Windows API constants for button types and return values #define MB_YESNO 4 // Displays Yes and No buttons. #define IDYES 6 // Returned if the user clicks Yes. #define IDNO 7 // Returned if the user clicks No. //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { // Create a message to display string msg = "Do you want to run the external command?"; // Call the MessageBoxW function with MB_YESNO to display Yes/No buttons. int result = MessageBoxW(0, msg, "Execute External Program", MB_YESNO); // Check the return value to see which button was clicked if(result == IDYES) { // Use ShellExecuteW to open the URL with Unicode strings int execResult = ShellExecuteW(0, "open", "https://www.mql5.com", "", "", 1); if(execResult > 32) Print("URL opened successfully."); else Print("Failed to open URL. Error code: ", execResult); } else if(result == IDNO) { Print("User clicked NO. Stop trading."); } else { Print("Unexpected return value: ", result); } }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
This code used to work in MT4 and it was working in MT5 but not anymore.
It's the code that execute another program ex:Script from the code.
Is there anyone who know how to make it work in MQL5?