Gui,1:Add, Text, hwndhText1 w150 center, Первый текст
Gui,1:Add, Text, hwndhText2 wp center, Второй текст
Gui,1:Show,x500 y400,1
SetColorToStatic(hText1, 0xFF0000, 0x0000FF)
SetColorToStatic(hText2, 0x0000FF, 0xFFFFFF)
sleep,1
Gui,2:Add, Text, hwndhText3 w150 center, Третий текст
Gui,2:Add, Text, hwndhText4 wp center, Четвёртый текст
Gui,2:Show,x800 y420,2
SetColorToStatic(hText3, 0xFF6666, 0x6666FF)
SetColorToStatic(hText4, 0x6666FF, 0x888888)
Return
F11::
Random,fon1,555555,16777215
Random,fon2,555555,16777215
Random,fon3,555555,16777215
Random,fon4,555555,16777215
SetColorToStatic(hText1, fon1, 16777215)
SetColorToStatic(hText2, fon2, 0xFF0000)
SetColorToStatic(hText3, fon3, 16777215)
SetColorToStatic(hText4, fon4, 0xFF0000)
Return
SetColorToStatic(hwnd, bg_color, fg_color = 0)
{
static arr := [], WM_CTLCOLORSTATIC := 0x138
(arr.HasKey(hwnd) && OnMessage(WM_CTLCOLORSTATIC, arr[hwnd], 0))
arr[hwnd] := Func("WM_CTLCOLOR").Bind(hwnd, Rgb2Bgr(bg_color), Rgb2Bgr(fg_color))
OnMessage(WM_CTLCOLORSTATIC, arr[hwnd])
WinSet, Redraw,, ahk_id %hwnd%
}
WM_CTLCOLOR(hStatic, bg_color, fg_color, wp, lp)
{
if (lp = hStatic) {
DllCall("SetBkColor", Ptr, wp, UInt, bg_color)
DllCall("SetTextColor", Ptr, wp, UInt, fg_color)
Return DllCall("CreateSolidBrush", UInt, bg_color, Ptr)
}
}
Rgb2Bgr(color)
{
Return (color & 0xff) << 16 | ((color >> 8) & 0xff) << 8 | color >> 16
}
Без паузы первый не красится при старте.