Список разделов › foobar2000 › Секреты foobar2000
У меня практически стандартный интерфейс, наверное это DUI ?kgena_ua:CUI или DUI ?
Тоже самое наблюдаю у себя. На двух компах следующее:MC Web:решил протестировать скрипт WSH properties (в прикрепляемой панели своей сборки) - ужасные тормоза, загрузка ЦП = 50%, анализаторы в сборке еле ползают. Закрываю панель - все просыпается. А как у Вас?
// ==PREPROCESSOR==
// @name "WSH Timer & Alarm clock"
// @author "kgena_ua"
// ==/PREPROCESSOR==
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",12,1);
var ww,wh;
//ColorTypeCUI = { background: 3,};
//var bgcolor = window.GetColorCUI(ColorTypeCUI.background);
var bgcolor = RGB(20,20,20);
var on_mouse = false;
var play_color = RGB(128,255,128);
var stop_color = RGB(255,175,89);
var m_off_color = RGB(180,180,180);
var m_on_color = RGB(255,255,220);
var txt_color;
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
var s_date;
var clock_txt = sec2time(s_date);
var txt = "";
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
gr.FillSolidRect (0, 0, ww, wh, bgcolor);
gr.GdiDrawText(clock_txt, font, on_mouse ? m_on_color : m_off_color, 0, 0, ww, wh - 15, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
txt_color = window.GetProperty("on_off") == "play" ? play_color : stop_color;
/* h_color = h == 0 ? m_off_color : timer_started ? txt_color : m_off_color;
m_color = m == 0 && h == 0 ? m_off_color : timer_started ? txt_color : m_off_color;
s_color = s == 0 && m == 0 && h == 0 ? m_off_color : timer_started ? txt_color : m_off_color;
h_width = gr.CalcTextWidth(h + " : ", font);
m_width = gr.CalcTextWidth(m + " : ", font);
s_width = gr.CalcTextWidth(s, font);
if (blinking == 1 && timer_started) {
gr.GdiDrawText(h + " : " , font, h_color, 0, 10, ww - m_width - s_width, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
gr.GdiDrawText(m + " : " , font, m_color, h_width, 10, ww - m_width - s_width, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
gr.GdiDrawText(s + " " , font, s_color, h_width + m_width, 10, ww - m_width - s_width, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
} else {
gr.GdiDrawText(txt, font, txt_color, 0, 10, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
} */
if (blinking == 1 && timer_started) {
gr.GdiDrawText(sec2time(set_timer), font, txt_color, 0, 10, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
} else {
gr.GdiDrawText(txt, font, txt_color, 0, 10, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}
}
var set_timer = 0;
var timer_started = false;
var stop_timer = false;
window.GetProperty("on_off", "play");
window.GetProperty("ti_ac", "clock");
var check_ti_ac = window.GetProperty("ti_ac") == "timer" ? 0 : 1;
var smh = ["hour","minute","seconds",];
window.GetProperty("smh","hour");
var m3f, m3l;
choice_s_m_h();
function choice_s_m_h() {
var m3 = [];
for (var i = 0; i < smh.length; i++) {
if(smh[i] != window.GetProperty("smh")) m3.push(smh[i]);
}
m3f = m3[0];
m3l = m3[1];
}
var step1, step_2;
set_step();
function set_step() { // if ShiftDown pressed
if (window.GetProperty("smh") == "seconds") {step1 = 1; step2 = 10};
if (window.GetProperty("smh") == "minute") {step1 = 60; step2 = 600};
if (window.GetProperty("smh") == "hour") {step1 = 3600; step2 = 3600};
}
function sec2time(sec) {
var h, m, s;
h = Math.floor(sec / 3600);
m = Math.floor((sec - h * 3600) / 60);
s = sec - h * 3600 - m * 60;
if ( h < 10 ) h = "0" + h;
if ( m < 10 ) m = "0" + m;
if ( s < 10 ) s = "0" + s;
return h + " : " + m + " : " + s;
}
var h = "00", m = "00", s = "00";
function sec2time_2(sec) {
h = Math.floor(sec / 3600);
m = Math.floor((sec - h * 3600) / 60);
s = sec - h * 3600 - m * 60;
if ( h < 10 ) h = "0" + h;
if ( m < 10 ) m = "0" + m;
if ( s < 10 ) s = "0" + s;
}
function on_mouse_lbtn_up (x, y){
set_step();
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_CHECKED = 0x00000008;
var _menu = window.CreatePopupMenu();
var i = 1;
MF_STATE1 = timer_started ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(MF_ENABLED, i++, timer_started ? "timer ..." : sec2time(set_timer));
MF_STATE2 = timer_started ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("smh") + " +"); // 2
_menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("smh") + " -"); // 3
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_STATE2, i++, m3f); // 4
_menu.AppendMenuItem(MF_STATE2, i++, m3l); // 5
_menu.AppendMenuItem(0x00000800, 0, 0);
MF_STATE3 = !timer_started ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_STATE3, i++, window.GetProperty("on_off")); // 6
_menu.AppendMenuItem(0x00000800, 0, 0);
MF_STATE4 = check_ti_ac == 0 && !timer_started ? MF_CHECKED : !timer_started ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_STATE4, i++, "timer"); // 7
MF_STATE5 = check_ti_ac == 1 && !timer_started ? MF_CHECKED : !timer_started ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_STATE5, i++, "alarm clock"); // 8
if (timer_started) {
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, i++, "clear timer"); // 9
}
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
set_timer = window.GetProperty("ti_ac") == "timer" && set_timer == 0 ? 86400 : set_timer;
timer_started = true;
text_blinking();
break;
case 2:
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
set_timer = set_timer + (ShiftDown ? step2 : step1);
set_timer = set_timer > 86400 ? set_timer - 86400 : set_timer;
on_mouse_lbtn_up (x, y);
break;
case 3:
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
set_timer = set_timer - (ShiftDown ? step2 : step1);
set_timer = set_timer < 0 ? Math.abs(set_timer + 86400) : set_timer;
on_mouse_lbtn_up(x,y);
break;
case 4:
window.SetProperty("smh",m3f);
choice_s_m_h();
on_mouse_lbtn_up(x,y);
break;
case 5:
window.SetProperty("smh",m3l);
choice_s_m_h();
on_mouse_lbtn_up(x,y);
break;
case 6:
// if (window.GetProperty("ti_ac") == "clock") {
window.GetProperty("on_off") == "play" ? window.SetProperty("on_off","stop") : window.SetProperty("on_off","play");
// }
on_mouse_lbtn_up(x,y);
break;
case 7:
window.SetProperty("ti_ac","timer");
check_ti_ac = 0;
set_timer = 0;
on_mouse_lbtn_up(x,y);
break;
case 8:
window.SetProperty("ti_ac","clock");
check_ti_ac = 1;
set_timer = 0;
on_mouse_lbtn_up(x,y);
break;
case 9: // clear timer
set_timer = 0;
sec2time_2(set_timer);
timer_started = false;
window.Repaint();
break;
}
_menu.Dispose();
if (!timer_started) {set_timer = 0; n_s = 0};
window.SetProperty("smh","hour");
choice_s_m_h();
}
function on_mouse_move(x, y) {
on_mouse = true;
window.SetCursor(32649);
window.Repaint();
}
function on_mouse_leave() {
on_mouse = false;
window.SetCursor(32512);
window.Repaint();
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
var blinking = 1;
var ms = 0;
function text_blinking() {
window.ClearInterval(timer2);
var timer2 = window.SetInterval(function() {
ms = new Date().getMilliseconds();
var ch = window.GetProperty("ti_ac") == "timer"? set_timer <= 10 : Math.abs(set_timer - s_date) <= 10;
if (ch) {
if (ms <= 900) {blinking = 1}
if (ms > 900 && ms <= 1000) {blinking = 0}
if (ms >= 1000) {ms = 0}
}
if (!timer_started) {
blinking = 1;
window.ClearInterval(timer2);
}
window.Repaint();
}, 1 )
}
var v_on_off = 0;
var v_state = fb.Volume;
var v_flag = 0;
function Vol(v_on_off) {
var v_timer = window.SetInterval(function(){
if (v_on_off == 1) {
if (v_flag == 0) {txt = "PLAY"};
fb.Volume++;
if (fb.Volume >= v_state ) {
window.ClearInterval(v_timer);
v_flag = 0;
txt = "";
};
window.Repaint();
}
if (v_on_off == 0) {
v_flag = 1;
txt = "STOP";
fb.Volume--;
if (fb.Volume <= -100 ) {
fb.Stop();
window.ClearInterval(v_timer);
Vol(1);
txt = "";
};
window.Repaint();
}
},30);
}
var clock_timer = window.SetInterval(on_timer, 1000);
function on_timer(id) {
d = new Date();
s_date = (d.getHours() * 3600) + (d.getMinutes() * 60) + d.getSeconds();
clock_txt = sec2time(s_date);
if (timer_started) {
if (window.GetProperty("ti_ac") == "timer") {
set_timer = set_timer - 1;
}
sec2time_2(set_timer);
var ch = window.GetProperty("ti_ac") == "timer"? set_timer <= 0 : Math.abs(set_timer - s_date) <= 0;
if (ch) {
if (window.GetProperty("on_off") == "play" && !fb.IsPlaying) {
v_state = fb.Volume;
fb.Volume = -100;
fb.Play();
Vol(1);
} else {
set_timer = 0; timer_started = false;
}
if (window.GetProperty("on_off") == "stop" && fb.IsPlaying) {
v_state = fb.Volume;
Vol(0);
} else {
set_timer = 0; timer_started = false;
}
set_timer = 0; timer_started = false;
}
}
window.Repaint()
}
Я пробовал такой вариант в самую первую очередь... в Properties получаю такую белеберду...duzzy,
var t_color = window.GetProperty("Text_Color",RGB(100,100,100));
и в Properties - Clear и Apply.
Зато работаетduzzy:в Properties получаю такую белеберду...
duzzy,duzzy:чтоб скрипт брал значение цвета из Properties
var t_color = window.GetProperty("Text_Color","100-100-100");
var t_color = CustomColour(t_color);
function CustomColour(colour){
tempc = colour.split("-");
return (0xff000000 | (tempc[0]<<16) | (tempc[1]<<8) | (tempc[2]));
}
MC Web, будет. Наверное добавлю меню по пр.кл. - вывод в одну, в две строки.MC Web:по аналогии, как в скрипте
Вернуться в Секреты foobar2000