Run Script from Ea

 

Hello Guys, i found the function StartScript to excute scrips over ea events

this is the function : 

#import "user32.dll"

   int RegisterWindowMessageA(string MessageName);

   int PostMessageA(int hwnd, int msg, int wparam, string Name);

   void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo);

#import

void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = true) // AutomaticallyAcceptDefaults i changed into true
{

   int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message");

   PostMessageA(hWnd, MessageNumber, 16, ScriptName);

   if (AutomaticallyAcceptDefaults) ClearConfigDialog();

}



void ClearConfigDialog()

{
   Sleep(100);
   keybd_event(13, 0, 0, 0);

}

i run the function like this : 

StartScript(0,"Exel Script");  // Dont Work, i dont know why, is the hWnd parameter right ? 
accept .dll from unkrown source or as it called is checked (so import isnt the problem)
when i debugg nothing happen on event ^^  

Ty for coming help
 

1) This is  not working anymore (ASCII to ANSI):

int RegisterWindowMessageA(string MessageName);
int PostMessageA(int hwnd, int msg, int wparam, string Name);

use (in general) the ...W(..)-functions instead:

int RegisterWindowMessageW(string MessageName);
int PostMessageW(int hwnd, int msg, int wparam, string Name);

But check whether they exist!

2) Do you have the handle of the window of the function?

void StartScript(int hWnd,....
 
c0ntr0x:

Hello Guys, i found the function StartScript to excute scrips over ea events

this is the function : 

As stated by gooly your hWnd is not good. 0 is not a valid hWnd.

Why do you need to run a script from an EA ?

 
Why do you need to run a script from an EA ?

Button click event on chart, but that is not my problem :)

 
c0ntr0x:

 

Button click event on chart, but that is not my problem :)

 

It's mine. Why don't you place the code inside your EA ?
 
i allready fixxed it , i had import problems ^^ but ty guys
 
c0ntr0x:
i allready fixxed it , i had import problems ^^ but ty guys

Hello c0ntr0x,

what did you do to tackle these import problems? I want to create a kind of script I would put in the Marketplace of Metatrader... Then the script would be available from an EA or an indicator.

Reason: