Adomb |
Отправлено: 10 Августа, 2020 - 14:27:55
|
Мастер
Покинул форум
Сообщений всего: 185
Дата рег-ции: Июль 2015
Репутация: 1
|
Сейчас выложу.
(Добавление)
код (Отобразить)CODE:external(INT, "MultiByteToWideChar", "MultiByteToWideChar", "Kernel32.dll"); external(INT, "GetStdHandle", "GetStdHandle", "Kernel32.dll"); external(INT, "SetConsoleCP", "SetConsoleCP", "Kernel32.dll"); external(INT, "SetConsoleOutputCP", "SetConsoleOutputCP", "Kernel32.dll");
external(INT, "SetConsoleTextAttribute", "SetConsoleTextAttribute", "Kernel32.dll"); external(INT, "WriteConsole", "WriteConsoleA", "Kernel32.dll"); external(INT, "GetConsoleWindow", "GetConsoleWindow", "Kernel32.dll"); external(INT, "AllocConsole", "AllocConsole", "Kernel32.dll");
external(INT, "FreeConsole", "FreeConsole", "Kernel32.dll"); external(INT, "SetConsoleTitle", "SetConsoleTitleA", "Kernel32.dll"); external(INT, "SetCurrentConsoleFontEx", "SetCurrentConsoleFontEx", "Kernel32.dll"); external(INT, "MoveWindow", "MoveWindow", "User32.dll");
#define STD_OUTPUT_HANDLE -11 #define windows_1251 1251 #define BLUE 1 #define GREEN 2 #define RED 4 #define FOREGROUND_INTENSITY 8 #define CYAN 3 #define MAGENTA 5 #define YELLOW 6 #define WHITE 7 #define CP_ACP 0
int h_console=console_create(), unnp; console_setfont(13); console_pos(930, 350, 440, 380); console_setcolor(BLUE);
external(INT, "SetWindowText", "SetWindowTextA", "User32.dll"); external(INT, "CreateWindow", "CreateWindowExA", "User32.dll"); external(INT, "SendMessage", "SendMessageA", "User32.dll");
////////////////////////////////////////////////////////////////////////////
int gx, gy, col; getdisplay(col, gx, gy);
int btn2d2, flbtn2d2=0;
Dialog25();
loop(){beep(400,400); Pst(0.7, "Скрипт");}
function getmessage(2, WM_COMMAND)
{if(message.lparam==btn2d2)
{if(flbtn2d2){flbtn2d2=0;} else{flbtn2d2=1;}
if(flbtn2d2==0){SetWindowText(btn2d2, "Пауза"); c_w("2, WM_COMMAND Пауза"); Pst(1,"Пауза"); return;}
if(flbtn2d2==1)
{SetWindowText(btn2d2, "Отменить паузу"); c_w("2, WM_COMMAND Отменить паузу"); Pst(7200,"Отменить паузу"); if(flbtn2d2==1){goto global exit;}
}
}
}
function getmessage(2, WM_CREATE)
{string b="Пауза";
btn2d2=CreateWindow(2,"BUTTON",b,1342177280, 18,20,160,25,gethwnd(2),0,0,0);
}
function Dialog25()
{createdialog(2); showdialog(2,"test",gx/2,gy/2,200,100,2,0);
}
function Pst(double q, string test)
{c_w("Pst - "+test); int p=q*1000; looptime(p){sleep(100);} return 1;
}
function console_create()
{FreeConsole(); AllocConsole(); SetConsoleTitle("log"); SetConsoleCP(windows_1251); SetConsoleOutputCP(windows_1251); return GetStdHandle(STD_OUTPUT_HANDLE);
}
function console_pos(int X,int Y,int nWidth,int nHeight)
{MoveWindow(GetConsoleWindow(), X, Y, nWidth, nHeight, 1);
}
function c_w(string text)
{char buffer[99999]; int written; strcpy(#buffer[0], text+"^r^n"); WriteConsole(h_console, address(#buffer[0]), size(#buffer[0]), address(#written), 0);
}
function console_close()
{FreeConsole();
}
function console_setcolor(int text_color)
{SetConsoleTextAttribute(h_console, text_color + FOREGROUND_INTENSITY);
}
function console_setfont(int height_font)
{string font_name = "Lucida Console"; int width_font = height_font/1.5; char console_font_info[84];
initialarray(#console_font_info[0], 0); writeaddress(84, address(#console_font_info[0])); writeaddress(0, address(#console_font_info[4])); writeaddress(width_font, address(#console_font_info[8]));
writeaddress(height_font, address(#console_font_info[10])); MultiByteToWideChar(CP_ACP, 0, font_name, size(font_name), address(#console_font_info[20]), 64);
SetCurrentConsoleFontEx(h_console, 0, address(#console_font_info[0]));
}
exit:
Добавил в функцию строку, чтобы понять откуда вызывается Pst.
Работает как "захочет". Кнопку туда сюда - может так выполнить может подругому.(Отредактировано автором: 10 Августа, 2020 - 14:43:09) |
|
|
Kibor |
Отправлено: 10 Августа, 2020 - 16:00:26
|
Эксперт
Покинул форум
Сообщений всего: 8218
Дата рег-ции: Март 2013
Откуда: Одесса
Репутация: 357
|
А как вы хотите что бы это выполнялось?
Сделайте нормальный алгоритм паузы.
(Добавление)
CODE:external(INT, "MultiByteToWideChar", "MultiByteToWideChar", "Kernel32.dll"); external(INT, "GetStdHandle", "GetStdHandle", "Kernel32.dll"); external(INT, "SetConsoleCP", "SetConsoleCP", "Kernel32.dll"); external(INT, "SetConsoleOutputCP", "SetConsoleOutputCP", "Kernel32.dll");
external(INT, "SetConsoleTextAttribute", "SetConsoleTextAttribute", "Kernel32.dll"); external(INT, "WriteConsole", "WriteConsoleA", "Kernel32.dll"); external(INT, "GetConsoleWindow", "GetConsoleWindow", "Kernel32.dll"); external(INT, "AllocConsole", "AllocConsole", "Kernel32.dll");
external(INT, "FreeConsole", "FreeConsole", "Kernel32.dll"); external(INT, "SetConsoleTitle", "SetConsoleTitleA", "Kernel32.dll"); external(INT, "SetCurrentConsoleFontEx", "SetCurrentConsoleFontEx", "Kernel32.dll"); external(INT, "MoveWindow", "MoveWindow", "User32.dll");
#define STD_OUTPUT_HANDLE -11 #define windows_1251 1251 #define BLUE 1 #define GREEN 2 #define RED 4 #define FOREGROUND_INTENSITY 8 #define CYAN 3 #define MAGENTA 5 #define YELLOW 6 #define WHITE 7 #define CP_ACP 0
int h_console=console_create(), unnp; console_setfont(13); console_pos(930, 350, 440, 380); console_setcolor(BLUE);
external(INT, "SetWindowText", "SetWindowTextA", "User32.dll"); external(INT, "CreateWindow", "CreateWindowExA", "User32.dll"); external(INT, "SendMessage", "SendMessageA", "User32.dll");
////////////////////////////////////////////////////////////////////////////
int gx, gy, col; getdisplay(col, gx, gy);
int btn2d2, flbtn2d2=0;
Dialog25();
loop(){beep(400,400); c_w("Pst - Скрипт"); }
function getmessage(2, WM_COMMAND)
{
if(message.lparam==btn2d2)
{
if(flbtn2d2) flbtn2d2=0;
else flbtn2d2=1;
if(flbtn2d2==0)
{
SetWindowText(btn2d2, "Пауза"); c_w("2, WM_COMMAND Пауза");
return;
}
else
{
SetWindowText(btn2d2, "Отменить паузу"); c_w("2, WM_COMMAND Отменить паузу");
Pst();
}
}
}
function getmessage(2, WM_CREATE)
{string b="Пауза";
btn2d2=CreateWindow(2,"BUTTON",b,1342177280, 18,20,160,25,gethwnd(2),0,0,0);
}
function Dialog25()
{createdialog(2); showdialog(2,"test",gx/2,gy/2,200,100,2,0);
}
function Pst()
{
loop()
{
c_w("Pst - Пауза ");
if (flbtn2d2==0) return;
sleep(100);
}
return;
}
function console_create()
{FreeConsole(); AllocConsole(); SetConsoleTitle("log"); SetConsoleCP(windows_1251); SetConsoleOutputCP(windows_1251); return GetStdHandle(STD_OUTPUT_HANDLE);
}
function console_pos(int X,int Y,int nWidth,int nHeight)
{MoveWindow(GetConsoleWindow(), X, Y, nWidth, nHeight, 1);
}
function c_w(string text)
{char buffer[99999]; int written; strcpy(#buffer[0], text+"^r^n"); WriteConsole(h_console, address(#buffer[0]), size(#buffer[0]), address(#written), 0);
}
function console_close()
{FreeConsole();
}
function console_setcolor(int text_color)
{SetConsoleTextAttribute(h_console, text_color + FOREGROUND_INTENSITY);
}
function console_setfont(int height_font)
{string font_name = "Lucida Console"; int width_font = height_font/1.5; char console_font_info[84];
initialarray(#console_font_info[0], 0); writeaddress(84, address(#console_font_info[0])); writeaddress(0, address(#console_font_info[4])); writeaddress(width_font, address(#console_font_info[8]));
writeaddress(height_font, address(#console_font_info[10])); MultiByteToWideChar(CP_ACP, 0, font_name, size(font_name), address(#console_font_info[20]), 64);
SetCurrentConsoleFontEx(h_console, 0, address(#console_font_info[0]));
}
exit: |
|
|
Kibor |
Отправлено: 10 Августа, 2020 - 16:21:57
|
Эксперт
Покинул форум
Сообщений всего: 8218
Дата рег-ции: Март 2013
Откуда: Одесса
Репутация: 357
|
Adomb пишет: И полтора года так работало
И вылетало.
Adomb пишет: И как сделать постановку скрипта на паузу теперь? Чтобы после снятия с него он возвращался к тому же месту откуда его остановили?
Так как я написал выше.
Вот код с проверкой где остановился и где продолжил.
Если остановить после низкого сигнала - продолжит с высокого. Если остановить после высокого - продолжит с низкого. Короче продолжит дальше.
CODE:external(INT, "MultiByteToWideChar", "MultiByteToWideChar", "Kernel32.dll"); external(INT, "GetStdHandle", "GetStdHandle", "Kernel32.dll"); external(INT, "SetConsoleCP", "SetConsoleCP", "Kernel32.dll"); external(INT, "SetConsoleOutputCP", "SetConsoleOutputCP", "Kernel32.dll");
external(INT, "SetConsoleTextAttribute", "SetConsoleTextAttribute", "Kernel32.dll"); external(INT, "WriteConsole", "WriteConsoleA", "Kernel32.dll"); external(INT, "GetConsoleWindow", "GetConsoleWindow", "Kernel32.dll"); external(INT, "AllocConsole", "AllocConsole", "Kernel32.dll");
external(INT, "FreeConsole", "FreeConsole", "Kernel32.dll"); external(INT, "SetConsoleTitle", "SetConsoleTitleA", "Kernel32.dll"); external(INT, "SetCurrentConsoleFontEx", "SetCurrentConsoleFontEx", "Kernel32.dll"); external(INT, "MoveWindow", "MoveWindow", "User32.dll");
#define STD_OUTPUT_HANDLE -11 #define windows_1251 1251 #define BLUE 1 #define GREEN 2 #define RED 4 #define FOREGROUND_INTENSITY 8 #define CYAN 3 #define MAGENTA 5 #define YELLOW 6 #define WHITE 7 #define CP_ACP 0
int h_console=console_create(), unnp; console_setfont(13); console_pos(930, 350, 440, 380); console_setcolor(BLUE);
external(INT, "SetWindowText", "SetWindowTextA", "User32.dll"); external(INT, "CreateWindow", "CreateWindowExA", "User32.dll"); external(INT, "SendMessage", "SendMessageA", "User32.dll");
////////////////////////////////////////////////////////////////////////////
int gx, gy, col; getdisplay(col, gx, gy);
int btn2d2, flbtn2d2=0;
Dialog25();
loop(){beep(400,700); beep(1400,700); c_w("Pst - Скрипт");}
function getmessage(2, WM_COMMAND)
{
if(message.lparam==btn2d2)
{
if(flbtn2d2) flbtn2d2=0;
else flbtn2d2=1;
if(flbtn2d2==0)
{
SetWindowText(btn2d2, "Пауза"); c_w("2, WM_COMMAND Пауза");
return;
}
else
{
SetWindowText(btn2d2, "Отменить паузу"); c_w("2, WM_COMMAND Отменить паузу");
Pst();
}
}
}
function getmessage(2, WM_CREATE)
{string b="Пауза";
btn2d2=CreateWindow(2,"BUTTON",b,1342177280, 18,20,160,25,gethwnd(2),0,0,0);
}
function Dialog25()
{createdialog(2); showdialog(2,"test",gx/2,gy/2,200,100,2,0);
}
function Pst()
{
loop()
{
c_w("Pst - Пауза ");
if (flbtn2d2==0) return;
sleep(100);
}
return;
}
function console_create()
{FreeConsole(); AllocConsole(); SetConsoleTitle("log"); SetConsoleCP(windows_1251); SetConsoleOutputCP(windows_1251); return GetStdHandle(STD_OUTPUT_HANDLE);
}
function console_pos(int X,int Y,int nWidth,int nHeight)
{MoveWindow(GetConsoleWindow(), X, Y, nWidth, nHeight, 1);
}
function c_w(string text)
{char buffer[99999]; int written; strcpy(#buffer[0], text+"^r^n"); WriteConsole(h_console, address(#buffer[0]), size(#buffer[0]), address(#written), 0);
}
function console_close()
{FreeConsole();
}
function console_setcolor(int text_color)
{SetConsoleTextAttribute(h_console, text_color + FOREGROUND_INTENSITY);
}
function console_setfont(int height_font)
{string font_name = "Lucida Console"; int width_font = height_font/1.5; char console_font_info[84];
initialarray(#console_font_info[0], 0); writeaddress(84, address(#console_font_info[0])); writeaddress(0, address(#console_font_info[4])); writeaddress(width_font, address(#console_font_info[8]));
writeaddress(height_font, address(#console_font_info[10])); MultiByteToWideChar(CP_ACP, 0, font_name, size(font_name), address(#console_font_info[20]), 64);
SetCurrentConsoleFontEx(h_console, 0, address(#console_font_info[0]));
}
exit: |
|
|
|