CODE:#define LBS_NOSEL 16384
#define WS_BORDER 8388608
#define WS_HSCROLL 1048576
#define WS_VSCROLL 2097152
#define WS_CHILD 1073741824
#define WS_VISIBLE 268435456
#define LBS_DISABLENOSCROLL 4096
#define LB_SETHORIZONTALEXTENT 404
#define LB_ADDSTRING 384
#define LB_GETCOUNT 395
#define LB_GETTEXT 393
#define LB_DELETESTRING 386
external(INT, "CreateWindow", "CreateWindowExA", "User32.dll" );
external(INT, "GetTextExtentPoint32", "GetTextExtentPoint32A", "Gdi32.dll" );
external(INT, "GetDC", "GetDC", "User32.dll" );
external(INT, "GetPrivateProfileString", "GetPrivateProfileStringA", "kernel32.dll");
external(INT, "WritePrivateProfileString", "WritePrivateProfileStringA", "kernel32.dll");
external(INT, "Strftime", "Strftime", pathfolder()+"Time.dll" );
external(INT, "SendMessage", "SendMessageA", "User32.dll" );
string date = "19.05.2019";
string path = "C:\Users\Home\AppData\Local\Temp\K2019Bot_Log.ini";
int Year, Month, DayOfWeek, Day, Hour, Minute, Second, Milliseconds;
int list, b1, hdc, max_length = 0;
char Time[100];
char Date[100];
char Text_Listbox1[255];
int a = 0;
string temp_fold = tempfolder();
string path_fold = pathfolder();
//-----------------------------------------------------------------------------------------------------------------------------------------------------
createdialog(0);
showdialog(0, "Диалог",100, 100, 300, 300, 1, 1);
//-----------------------------------------------------------------------------------------------------------------------------------------------------
loop()
{
sleep(10);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
function getmessage(0, WM_COMMAND)
{
if (message.lparam == b1)
{
add_list("Бот запущен.", 1, 1);
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
function getmessage(0, WM_CREATE)
{
list = CreateWindow(0, "LISTBOX", "", LBS_NOSEL | WS_BORDER | WS_HSCROLL | WS_VSCROLL | LBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE, 10, 10, 200, 200, gethwnd(0), 0, 0, 0);
b1=CreateWindow(0, "BUTTON", "Запустить", WS_CHILD | WS_VISIBLE, 10, 220, 120, 30, gethwnd(0), 0, 0, 0);
hdc=GetDC(list);
ini_read();
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
function add_list(string s, int save, int choose)
{
getlocaltime(Year, Month, DayOfWeek, Day, Hour, Minute, Second, Milliseconds);
Strftime(address(#Time[0]), sizearray(Time), "%X", Hour, Minute, Second, Day, Month, Year);
Strftime(address(#Date[0]), sizearray(Date), "%d.%m.%Y", Hour, Minute, Second, Day, Month, Year);
string Text = s;
if (choose == 1)
{
s="["+format(#Time[0])+"] - "+s;
}
int SIZE[2];
new char c[size(s)+1];
strcpy(#c[0], s);
GetTextExtentPoint32(hdc, address(#c[0]), sizearray(c), address(#SIZE[0]));
if(max_length<SIZE[0])
{
max_length=SIZE[0];
sendmessage(LB_SETHORIZONTALEXTENT, SIZE[0], 0, formatiw(list));
}
sendmessage(LB_ADDSTRING, 0, address(#c[0]), formatiw(list));
if (save == 1)//если нужно сохранить в файл.
{
WritePrivateProfileString (date, format(#Time[0])+":"+format(Milliseconds), Text, temp_fold+"K2019Bot_Log.ini");
}
delete c;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
function ini_read()
{
int length;
char key_ini[99999], value[999];
if(fopen(path, "rb"))
{
fclose();
int x = GetPrivateProfileString (date, 0, 0, address (#key_ini[0]), sizearray(key_ini), path);
if(x)
{
add_list("["+date+"]", 0, 0);
length=0;
for(int i=0; length<=x; i++)
{
if(GetPrivateProfileString (date, format(#key_ini[length]), 0, address (#value[0]), sizearray(value), path))
{
string s=format(#key_ini[length]);
regexreplace(1, #s, s, ":\d+", "", RIGHTTOLEFT);
add_list(+"["+s+"] - "+format(#value[0]), 0, 0);
}
length=length+size(#key_ini[length])+1;
}
}
else
{
messagebox("секция даты не найдена");
WritePrivateProfileString(date, "", "", path);
ini_read();
}
}
else
{
//если файл не найден.
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------