I have it as a function in my EA, here is the beginning of the code
this is the function itself
The rest of the EA works fine, the variables that are in the function are not used anywhere else in the code. Terminal crashes on lineSetClipboardData( CF_UNICODETEXT, hMem );// Passing memory with string to the buffer
void OutClipboard()
{
uint hwnd = (uint)ChartGetInteger( 0, CHART_WINDOW_HANDLE );
int strSize = StringLen( text ) * 2 + 2; // Получаем размер строки в байтахif( OpenClipboard( hwnd ) ) // Открываем буфер
{
EmptyClipboard(); // Очищаем буферuint hMem = GlobalAlloc( GHND, strSize ); // Выделяем памятьuint pMem = GlobalLock( hMem ); // Получаем адрес выделенной памяти
memcpy( pMem, text, strSize ); // Копируем строку в память
GlobalUnlock( hMem );
SetClipboardData( CF_UNICODETEXT, hMem ); // Передаём память со строкой в буфер
CloseClipboard(); // Закрываем буфер
}
}
The rest of the EA works fine, the variables that are in the function are not used anywhere else in the code. Terminal crashes on lineSetClipboardData( CF_UNICODETEXT, hMem );// Passing memory with string to the buffer
//+------------------------------------------------------------------+//| Clipboard.mq4 |//| ПавелИванович(api) |//| p231970@hotmail.com |//| Перенос на MQL5 и доработка unicode - Сергеев Алексей (sergeev) |//| profy.mql@gmail.com |//+------------------------------------------------------------------+#property version"1.00"#property description"Getting contents of the clipboard"#import "user32.dll"bool OpenClipboard(int hwnd);
int GetClipboardData(int uFormat);
bool CloseClipboard();
int GetAncestor(long hWnd,int gaFlags);
int GetAncestor(int hWnd,int gaFlags);
#import "kernel32.dll"int GlobalLock(int hMem);
bool GlobalUnlock(int hMem);
string lstrcatW(int dst,string src);
#import
//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+intOnStart()
{
int hMain;
string clip="";
//---if(_IsX64)
hMain=GetAncestor(ChartGetInteger(ChartID(),CHART_WINDOW_HANDLE),2);
else
hMain=GetAncestor((int)ChartGetInteger(ChartID(),CHART_WINDOW_HANDLE),2);
//---if(OpenClipboard(hMain))
{
int hglb=GetClipboardData(1/*CF_TEXT*/);
if(hglb!=0)
{
int lptstr=GlobalLock(hglb);
if(lptstr!=0) { clip=lstrcatW(lptstr,""); GlobalUnlock(hglb); }
}
CloseClipboard();
}
// translate ANSI to UNICODEushort chW; uchar chA; string rez;
for(int i=0; i<StringLen(clip); i++)
{
chW=StringGetCharacter(clip, i);
chA=uchar(chW&255); rez=rez+CharToString(chA);
chA=uchar(chW>>8&255); rez=rez+CharToString(chA);
}
MessageBox("Clipboard: \n"+rez,"Clipboard");
return(0);
}
//+------------------------------------------------------------------+
I found this script, which supposedly reads the buffer and outputs the value in the terminal window - it doesn't work either.
Although it doesn't kill terminal, it doesn't output anything in the window either. It's a mystery with buffer, I'll limit outputting data to Alert for now, I can copy data from it with ctrl+c, though I wanted to avoid "manual" actions.
That example was for MT4, so it didn't take into account digit capacity.
Here is one for all platforms:
I got suspicious about capacity, especially when I looked at the second script reading the buffer. That's the only way to fix it, I would have figured out at least a month later)). Thank you very much, you saved me a lot of time).
'OrderType' - function not defined KamikadzeStatistics.mqh 259 60
'OrderCloseTime' - function not defined KamikadzeStatistics.mqh 261 19
'OrderProfit' - function not defined KamikadzeStatistics.mqh 265 42
What is this? I am not a good judge of MQL4. If you tell me what I need, I will be able to write everything in MQL5. Is it something to do with history profit/loss calculation?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thank you.
Just registered, don't know how the forum functions yet.
I don't understand WinAPI, what's wrong here?
let me see your efforts in the form of a script
I have it as a function in my EA, here is the beginning of the code
this is the function itself
The rest of the EA works fine, the variables that are in the function are not used anywhere else in the code.
Terminal crashes on lineSetClipboardData( CF_UNICODETEXT, hMem );// Passing memory with string to the buffer
I get it, I stand corrected.)
let me see your efforts as a script
I have it as a function in my EA, here is the beginning of the code
this is the function itself
The rest of the EA works fine, the variables that are in the function are not used anywhere else in the code.
Terminal crashes on lineSetClipboardData( CF_UNICODETEXT, hMem );// Passing memory with string to the buffer
I found this script, which supposedly reads the buffer and outputs the value in the terminal window - it doesn't work either.
Although it doesn't kill terminal, it doesn't output anything in the window either.
It's a mystery with buffer, I'll limit outputting data to Alert for now, I can copy data from it with ctrl+c, though I wanted to avoid "manual" actions.
That example was for MT4, so it didn't take into account digit capacity.
Here is one for all platforms:
That example was for MT4, so it didn't take into account digit capacity.
Here is one for all platforms:
I got suspicious about capacity, especially when I looked at the second script reading the buffer.
That's the only way to fix it, I would have figured out at least a month later)).
Thank you very much, you saved me a lot of time).
Immediately integrate it into EA)
Please help me to rewrite code on MT5 - I am not good at orders :(
When compiling the code errors:
'SELECT_BY_POS' - undeclared identifier KamikadzeStatistics.mqh 257 33
'MODE_HISTORY' - undeclared identifier KamikadzeStatistics.mqh 257 47
'OrderSelect' - wrong parameters count KamikadzeStatistics.mqh 257 13
'OrderType' - function not defined KamikadzeStatistics.mqh 259 60
'OrderCloseTime' - function not defined KamikadzeStatistics.mqh 261 19
'OrderProfit' - function not defined KamikadzeStatistics.mqh 265 42
Please help me to rewrite code on MT5 - I am not good at orders :(
When compiling the code errors:
'SELECT_BY_POS' - undeclared identifier KamikadzeStatistics.mqh 257 33
'MODE_HISTORY' - undeclared identifier KamikadzeStatistics.mqh 257 47
'OrderSelect' - wrong parameters count KamikadzeStatistics.mqh 257 13
'OrderType' - function not defined KamikadzeStatistics.mqh 259 60
'OrderCloseTime' - function not defined KamikadzeStatistics.mqh 261 19
'OrderProfit' - function not defined KamikadzeStatistics.mqh 265 42
What is this? I am not a good judge of MQL4. If you tell me what I need, I will be able to write everything in MQL5.
Is it something to do with history profit/loss calculation?