Download MetaTrader 5
To add comments, please log in or register
Do you often publish source codes? Find out how to do that correctly!
c0ntr0x
81
c0ntr0x 2014.11.28 22:00 

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
Carl Schreiber
5962
Carl Schreiber 2014.11.28 22:33  

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,....
Alain Verleyen
Moderator
28672
Alain Verleyen 2014.11.28 23:19  
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 ?

c0ntr0x
81
c0ntr0x 2014.11.29 09:55  
Why do you need to run a script from an EA ?

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

Alain Verleyen
Moderator
28672
Alain Verleyen 2014.11.29 09:58  
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 ?
c0ntr0x
81
c0ntr0x 2014.11.29 10:49  
i allready fixxed it , i had import problems ^^ but ty guys
/
To add comments, please log in or register