<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Цвета в Popup меню]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=18615&amp;type=atom" />
	<updated>2026-08-03T22:34:00Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=18615</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Цвета в Popup меню]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=163479#p163479" />
			<content type="html"><![CDATA[<p>Примерно так:<br /></p><div class="codebox"><pre><code>#Requires AutoHotkey v2.0

COLORS := [&quot;EAF4FF&quot;, &quot;E7F8EC&quot;, &quot;FFF4DE&quot;, &quot;FDE9E9&quot;, &quot;F0EAFB&quot;,
           &quot;E4F7F7&quot;, &quot;FFE9F3&quot;, &quot;F2F2F2&quot;, &quot;FFFFFF&quot;, &quot;EDF3D8&quot;]

SM_CXSMICON := 49
SWATCH_SIZE := DllCall(&quot;GetSystemMetrics&quot;, &quot;Int&quot;, SM_CXSMICON)
SWATCH_BMPS := []

PALETTE := Menu()
for hex in COLORS
    PALETTE.Add(&quot;#&quot; hex, OnPickColor)
AttachSwatches(PALETTE, COLORS)

PALETTE.Show()

OnExit(Cleanup)

OnPickColor(itemName, itemPos, mnu) {
    A_Clipboard := itemName
    ToolTip itemName &quot; скопирован&quot;
    SetTimer () =&gt; ToolTip(), -1200
}

AttachSwatches(mnu, colors) {
    static MIIM_BITMAP := 0x0080
    hMenu   := mnu.Handle
    miiSize := (A_PtrSize = 8) ? 80 : 48
    ofsBmp  := (A_PtrSize = 8) ? 72 : 44

    mii := Buffer(miiSize, 0)
    NumPut(&quot;UInt&quot;, miiSize, mii, 0)
    NumPut(&quot;UInt&quot;, MIIM_BITMAP, mii, 4)

    for i, hex in colors {
        hbm := MakeSwatch(Integer(&quot;0x&quot; hex), SWATCH_SIZE)
        SWATCH_BMPS.Push(hbm)
        NumPut(&quot;Ptr&quot;, hbm, mii, ofsBmp)
        DllCall(&quot;SetMenuItemInfoW&quot;, &quot;Ptr&quot;, hMenu, &quot;UInt&quot;, i - 1, &quot;Int&quot;, true, &quot;Ptr&quot;, mii)
    }
}

MakeSwatch(rgb, size, border := 0xB0B0B0) {
    bi := Buffer(40, 0)                ; BITMAPINFOHEADER
    NumPut(&quot;UInt&quot;,   40, bi,  0)       ; biSize
    NumPut(&quot;Int&quot;,  size, bi,  4)       ; biWidth
    NumPut(&quot;Int&quot;, -size, bi,  8)       ; biHeight &lt; 0 -&gt; top-down rows
    NumPut(&quot;UShort&quot;,  1, bi, 12)       ; biPlanes
    NumPut(&quot;UShort&quot;, 32, bi, 14)       ; biBitCount
    NumPut(&quot;UInt&quot;,    0, bi, 16)       ; biCompression = BI_RGB

    hbm := DllCall(&quot;CreateDIBSection&quot;, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, bi, &quot;UInt&quot;, 0    ; DIB_RGB_COLORS
                 , &quot;Ptr*&quot;, &amp;bits := 0, &quot;Ptr&quot;, 0, &quot;UInt&quot;, 0, &quot;Ptr&quot;)
    if (!hbm)
        throw OSError(&quot;CreateDIBSection failed&quot;)

    fill := 0xFF000000 | rgb
    edge := 0xFF000000 | border
    last := size - 1
    loop size {
        y := A_Index - 1
        loop size {
            x := A_Index - 1
            onEdge := (x = 0 || y = 0 || x = last || y = last)
            NumPut(&quot;UInt&quot;, onEdge ? edge : fill, bits, (y * size + x) * 4)
        }
    }
    return hbm
}

Cleanup(*) {
    for hbm in SWATCH_BMPS
        DllCall(&quot;DeleteObject&quot;, &quot;Ptr&quot;, hbm)
    return 0
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2026-08-03T22:34:00Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=163479#p163479</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Цвета в Popup меню]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=163478#p163478" />
			<content type="html"><![CDATA[<p>Чтобы черные квадраты в пунктах воспроизводили коды цветов. ИИ не справляются, хотел им показать пример реализации.</p>]]></content>
			<author>
				<name><![CDATA[1srafel]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=43566</uri>
			</author>
			<updated>2026-08-03T17:51:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=163478#p163478</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Цвета в Popup меню]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=163477#p163477" />
			<content type="html"><![CDATA[<p>А чего именно вы хотите добиться?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2026-08-03T11:12:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=163477#p163477</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Цвета в Popup меню]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=163474#p163474" />
			<content type="html"><![CDATA[<p>Не знает ли кто примера использования цвета в таком меню? -</p><p><a href="https://s1.hostingkartinok.com/uploads/images/2026/08/17202f2a2b53d64f34327f6c9a2cf2ac.jpg"><span class="postimg"><img src="https://s1.hostingkartinok.com/uploads/thumbs/2026/08/17202f2a2b53d64f34327f6c9a2cf2ac.png" alt="https://s1.hostingkartinok.com/uploads/thumbs/2026/08/17202f2a2b53d64f34327f6c9a2cf2ac.png" /></span></a></p>]]></content>
			<author>
				<name><![CDATA[1srafel]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=43566</uri>
			</author>
			<updated>2026-08-02T22:18:21Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=163474#p163474</id>
		</entry>
</feed>
