<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=18575</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18575&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)».]]></description>
		<lastBuildDate>Sun, 22 Mar 2026 11:02:37 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163233#p163233</link>
			<description><![CDATA[<p>А если Ctrl + 1 или Ctrl + 2 нажать?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 22 Mar 2026 11:02:37 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163233#p163233</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163232#p163232</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Попробуйте такой:</p></blockquote></div><p>Ещё раз спасибо, но этот совсем не работает, просто висит в фоне.<br /></p><div class="codebox"><pre><code>Script lines most recently executed (oldest first).  Press [F5] to refresh.  The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0).  The bottommost line&#039;s elapsed time is the number of seconds since it executed.

---- C:\Users\NS\Documents\AutoHotkey\led3.ahk
003: led := KeyboardLED(7)
010: KeyboardLED.SCROLL_LOCK := 0x0001
011: KeyboardLED.NUM_LOCK := 0x0002
012: KeyboardLED.CAPS_LOCK := 0x0004
014: KeyboardLED.LED_MASK := 0x0007
015: KeyboardLED.kip_size := 4
000: }
019: this.hDevice := KeyboardLED.CreateFile(&#039;\\.\GLOBALROOT\Device\KeyboardClass&#039; . kbdIndex)
097: Static shareFlag := (FILE_SHARE_READ  := 0x1) | (FILE_SHARE_WRITE := 0x2)
097: Static OPEN_EXISTING := 3
097: Static INVALID_HANDLE_VALUE := -1
101: res := DllCall(&#039;CreateFile&#039;, &#039;Str&#039;, devPath, &#039;UInt&#039;, 0, &#039;UInt&#039;, shareFlag, &#039;Ptr&#039;, 0 , &#039;UInt&#039;, OPEN_EXISTING, &#039;UInt&#039;, 0, &#039;UInt&#039;, 0, &#039;Ptr&#039;)
103: If (res = INVALID_HANDLE_VALUE)
105: Return res
020: }
005: {
006: {
008: KeyboardLED
008: {
018: {
022: {
026: {
027: {
031: {
032: {
036: {
037: {
040: {
042: {
044: {
049: {
054: {
059: {
061: {
072: {
083: {
090: {
096: {
108: Exit (27.55)

Press [F5] to refresh.</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (21nordson)]]></author>
			<pubDate>Sun, 22 Mar 2026 09:31:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163232#p163232</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163228#p163228</link>
			<description><![CDATA[<p>Попробуйте такой:<br /></p><div class="codebox"><pre><code>#Requires AutoHotkey v2

led := KeyboardLED(7) ; ваш индекс клавиатуры

^1:: led.CapsLock := 1 ; включение
^2:: led.CapsLock := 0 ; отключение

class KeyboardLED
{
    static SCROLL_LOCK := 0x0001
    static NUM_LOCK    := 0x0002
    static CAPS_LOCK   := 0x0004

    static LED_MASK := 0x0007
    static kip_size := 4 ; KEYBOARD_INDICATOR_PARAMETERS_SIZE

    ; kbdIndex — index of keyboard (probably 0 or 2)
    __New(kbdIndex := 0) {
        this.hDevice := KeyboardLED.CreateFile(&#039;\\.\GLOBALROOT\Device\KeyboardClass&#039; . kbdIndex)
    }

    __Delete() =&gt; DllCall(&#039;CloseHandle&#039;, &#039;Ptr&#039;, this.hDevice)

    ; setters accept &#039;on&#039;, &#039;off&#039;, &#039;switch&#039; or 1, 0, -1
    NumLock {
        get =&gt; KeyboardLED.GetKey(this.hDevice, KeyboardLED.NUM_LOCK)
        set =&gt; KeyboardLED.SetKey(this.hDevice, KeyboardLED.NUM_LOCK, value)
    }

    CapsLock {
        get =&gt; KeyboardLED.GetKey(this.hDevice, KeyboardLED.CAPS_LOCK)
        set =&gt; KeyboardLED.SetKey(this.hDevice, KeyboardLED.CAPS_LOCK, value)
    }

    ScrollLock {
        get =&gt; KeyboardLED.GetKey(this.hDevice, KeyboardLED.SCROLL_LOCK)
        set =&gt; KeyboardLED.SetKey(this.hDevice, KeyboardLED.SCROLL_LOCK, value)
    }

    GetAll() =&gt; KeyboardLED.QueryIndicators(this.hDevice)

    SetAll(ledFlags) =&gt; KeyboardLED.SetIndicators(this.hDevice, ledFlags)

    Set(ledMask) {
        currentLeds := KeyboardLED.QueryIndicators(this.hDevice)
        return KeyboardLED.SetIndicators(this.hDevice, currentLeds | ledMask)
    }

    Clear(ledMask) {
        currentLeds := KeyboardLED.QueryIndicators(this.hDevice)
        return KeyboardLED.SetIndicators(this.hDevice, currentLeds &amp; (ledMask ^ KeyboardLED.LED_MASK))
    }

    Toggle(ledMask) {
        currentLeds := KeyboardLED.QueryIndicators(this.hDevice)
        return KeyboardLED.SetIndicators(this.hDevice, currentLeds ^ ledMask)
    }

    static GetKey(hDevice, key) =&gt; !!(this.QueryIndicators(hDevice) &amp; key)

    static SetKey(hDevice, key, cmd) {
        currentLeds := this.QueryIndicators(hDevice)
        switch cmd, false {
            case &#039;switch&#039;, -1 : keyLed := currentLeds ^ key
            case &#039;on&#039;    ,  1 : keyLed := currentLeds | key
            case &#039;off&#039;   ,  0 : keyLed := currentLeds &amp; (key ^ this.LED_MASK)
            default           : throw Error(&#039;Incorrect cmd&#039;)
        }
        return this.SetIndicators(hDevice, keyLed)
    }

    static QueryIndicators(hDevice) {
        ioctlQuery := this.CTL_CODE(0x10) ; KBD_QUERY_FUNCTION
        inBuf  := Buffer(this.kip_size, 0)
        outBuf := Buffer(this.kip_size, 0)
        DllCall(&#039;DeviceIoControl&#039;, &#039;Ptr&#039;, hDevice, &#039;UInt&#039;, ioctlQuery,
                                   &#039;Ptr&#039;,  inBuf, &#039;UInt&#039;, this.kip_size,
                                   &#039;Ptr&#039;, outBuf, &#039;UInt&#039;, this.kip_size,
                                   &#039;UInt*&#039;, &amp;ret := 0, &#039;Ptr&#039;, 0)
        return NumGet(outBuf, 2, &#039;UShort&#039;)
    }

    static SetIndicators(hDevice, ledFlags) {
        ioctlSet := this.CTL_CODE(0x2) ; KBD_SET_FUNCTION
        return DllCall(&#039;DeviceIoControl&#039;, &#039;Ptr&#039;, hDevice, &#039;UInt&#039;, ioctlSet,
                                          &#039;Int*&#039;, ledFlags &lt;&lt; 16, &#039;UInt&#039;, this.kip_size,
                                          &#039;Ptr&#039;, 0, &#039;UInt&#039;, 0, &#039;UInt*&#039;, &amp;ret := 0, &#039;Ptr&#039;, 0)
    }

    static CTL_CODE(function) {
        static FILE_DEVICE_KEYBOARD := 0x0b, FILE_ANY_ACCESS := 0, METHOD_BUFFERED := 0
             , opt := (FILE_DEVICE_KEYBOARD &lt;&lt; 16) | (FILE_ANY_ACCESS &lt;&lt; 14) | METHOD_BUFFERED
        return opt | (function &lt;&lt; 2)
    }

    static CreateFile(devPath) {
        static shareFlag := (FILE_SHARE_READ  := 0x1)
                          | (FILE_SHARE_WRITE := 0x2)
             , OPEN_EXISTING := 3, INVALID_HANDLE_VALUE := -1

        res := DllCall(&#039;CreateFile&#039;, &#039;Str&#039;, devPath, &#039;UInt&#039;, 0, &#039;UInt&#039;, shareFlag, &#039;Ptr&#039;, 0
                                   , &#039;UInt&#039;, OPEN_EXISTING, &#039;UInt&#039;, 0, &#039;UInt&#039;, 0, &#039;Ptr&#039;)
        if (res = INVALID_HANDLE_VALUE)
            throw Error(&#039;CreateFile failed. Error: INVALID_HANDLE_VALUE&#039;)
        return res
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 21 Mar 2026 19:37:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163228#p163228</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163227#p163227</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Скрипт должен переключать состояние CapsLock. У меня работает.</p></blockquote></div><p>Большое спасибо за помощь. Перебирая kbdIndex на цифре 7 заработало включение. Но не выключение. Если светодиод выключен то включается, но если включён, то скриптом не выключается.</p>]]></description>
			<author><![CDATA[null@example.com (21nordson)]]></author>
			<pubDate>Sat, 21 Mar 2026 19:06:28 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163227#p163227</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163209#p163209</link>
			<description><![CDATA[<div class="codebox"><pre><code>/*

    Keyboard LED control for AutoHotkey_L
        http://www.autohotkey.com/forum/viewtopic.php?p=468000#468000

    KeyboardLED(LEDvalue, &#039;Cmd&#039;, Kbd)
        LEDvalue  - ScrollLock=1, NumLock=2, CapsLock=4
        Cmd       - on/off/switch
        Kbd       - index of keyboard (probably 0 or 2)

*/
#Requires AutoHotkey v2

KeyboardLED(4, &quot;switch&quot;)

KeyboardLED(ledValue, cmd, kbdIndex := 0) {

    ; KEYBOARD_INDICATOR_PARAMETERS LED bit flags (kbdmou.h)
    static SCROLL_LOCK_LED := 0x0001
         , NUM_LOCK_LED    := 0x0002
         , CAPS_LOCK_LED   := 0x0004
         , LED_MASK        := 0x0007  ; SCROLL_LOCK_LED | NUM_LOCK_LED | CAPS_LOCK_LED

    ; NtCreateFile: DesiredAccess flags (ntioapi.h)
         , FILE_READ_ATTRIBUTES  := 0x00000080
         , FILE_WRITE_ATTRIBUTES := 0x00000100
         , SYNCHRONIZE           := 0x00100000

    ; NtCreateFile: ShareAccess
         , FILE_SHARE_READ := 0x00000001

    ; NtCreateFile: CreateDisposition
         , FILE_OPEN := 0x00000001

    ; NtCreateFile: CreateOptions
         , FILE_NON_DIRECTORY_FILE      := 0x00000020
         , FILE_SYNCHRONOUS_IO_NONALERT := 0x00000040

    ; sizeof(KEYBOARD_INDICATOR_PARAMETERS): USHORT UnitId + USHORT LedFlags
         , KEYBOARD_INDICATOR_PARAMETERS_SIZE := 4

    ; CTL_CODE arguments for IOCTL_KEYBOARD_QUERY_INDICATORS (ntddkbd.h)
         , KBD_DEVICE_TYPE    := 0x0b  ; FILE_DEVICE_KEYBOARD
         , KBD_QUERY_FUNCTION := 0x10  ; query indicators
         , KBD_SET_FUNCTION   := 0x02  ; set indicators
         , KBD_METHOD         := 0x00  ; METHOD_BUFFERED
         , KBD_ACCESS         := 0x00  ; FILE_ANY_ACCESS

    hDevice := NtCreateFile(
        &quot;\Device\KeyBoardClass&quot; kbdIndex,
        FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
        FILE_SHARE_READ,
        FILE_OPEN,
        FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
        0   ; FileAttributes: ignored when opening an existing file
    )

    ; Read actual LED state directly from the device
    ioctlQuery := CTL_CODE(KBD_DEVICE_TYPE, KBD_QUERY_FUNCTION, KBD_METHOD, KBD_ACCESS)
    inBuf  := Buffer(KEYBOARD_INDICATOR_PARAMETERS_SIZE, 0)
    outBuf := Buffer(KEYBOARD_INDICATOR_PARAMETERS_SIZE, 0)
    DllCall(&quot;DeviceIoControl&quot;,
        &quot;ptr&quot;,   hDevice,
        &quot;uint&quot;,  ioctlQuery,
        &quot;ptr&quot;,   inBuf,
        &quot;uint&quot;,  KEYBOARD_INDICATOR_PARAMETERS_SIZE,
        &quot;ptr&quot;,   outBuf,
        &quot;uint&quot;,  KEYBOARD_INDICATOR_PARAMETERS_SIZE,
        &quot;uint*&quot;, &amp;bytesReturned := 0,
        &quot;ptr&quot;,   0)
    currentLeds := NumGet(outBuf, 2, &quot;ushort&quot;)

    if (cmd = &quot;switch&quot;)
        keyLed := currentLeds ^ ledValue
    else if (cmd = &quot;on&quot;)
        keyLed := currentLeds | ledValue
    else if (cmd = &quot;off&quot;)
        keyLed := currentLeds &amp; (ledValue ^ LED_MASK)
    
    indicatorParams := keyLed &lt;&lt; 16

    ioctlSet := CTL_CODE(KBD_DEVICE_TYPE, KBD_SET_FUNCTION, KBD_METHOD, KBD_ACCESS)
    success := DllCall(&quot;DeviceIoControl&quot;,
        &quot;ptr&quot;,   hDevice,
        &quot;uint&quot;,  ioctlSet,
        &quot;int*&quot;,  indicatorParams,
        &quot;uint&quot;,  KEYBOARD_INDICATOR_PARAMETERS_SIZE,
        &quot;ptr&quot;,   0,
        &quot;uint&quot;,  0,
        &quot;uint*&quot;, &amp;bytesReturned,
        &quot;ptr&quot;,   0)

    NtCloseFile(hDevice)
    return success
}

CTL_CODE(deviceType, function, method, access) {
    return (deviceType &lt;&lt; 16) | (access &lt;&lt; 14) | (function &lt;&lt; 2) | method
}

NtCreateFile(filename, desiredAccess, shareMode, createDisposition, createOptions, fileAttributes) {

    pathBuf := Buffer(2 * StrPut(filename, &quot;UTF-16&quot;))
    StrPut(filename, pathBuf, &quot;UTF-16&quot;)

    uniStr    := Buffer(2 * A_PtrSize, 0)
    objAttrib := Buffer(6 * A_PtrSize, 0)
    ioStatus  := Buffer(2 * A_PtrSize, 0)

    DllCall(&quot;ntdll\RtlInitUnicodeString&quot;, &quot;ptr&quot;, uniStr, &quot;ptr&quot;, pathBuf)

    NumPut(&quot;uint&quot;, 6 * A_PtrSize, objAttrib, 0)             ; Length
    NumPut(&quot;ptr&quot;,  uniStr.Ptr,    objAttrib, 2 * A_PtrSize) ; ObjectName

    DllCall(&quot;ntdll\ZwCreateFile&quot;,
        &quot;ptr*&quot;, &amp;hFile := 0,
        &quot;uint&quot;, desiredAccess,
        &quot;ptr&quot;,  objAttrib,
        &quot;ptr&quot;,  ioStatus,
        &quot;ptr&quot;,  0,
        &quot;uint&quot;, fileAttributes,
        &quot;uint&quot;, shareMode,
        &quot;uint&quot;, createDisposition,
        &quot;uint&quot;, createOptions,
        &quot;ptr&quot;,  0,
        &quot;uint&quot;, 0,
        &quot;uint&quot;)

    return hFile
}

NtCloseFile(handle) {
    return DllCall(&quot;ntdll\ZwClose&quot;, &quot;ptr&quot;, handle)
}</code></pre></div><p>Скрипт должен переключать состояние CapsLock. У меня работает.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 20 Mar 2026 19:22:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163209#p163209</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163206#p163206</link>
			<description><![CDATA[<div class="quotebox"><cite>__Михаил__ пишет:</cite><blockquote><p>Вроде как невозможно отвязать системную индикацию на клавиатуре. Предлагаю вместо этого использовать другой индикатор.</p></blockquote></div><p>К сожалению это единственный индикатор на моей клавиатуре. Да и проблему я решил более странным способом, создав в microsoft keyboard layout creator раскладку, где на капсе английские символы, а без капса - русские. Просто вспомнил, что ещё лет 20 или 25 назад видел программу которая управляет всеми светодиодами на клавиатуре. Да и скрипт в AHK нашёл.</p>]]></description>
			<author><![CDATA[null@example.com (21nordson)]]></author>
			<pubDate>Fri, 20 Mar 2026 19:00:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163206#p163206</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163205#p163205</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>у вас скрипт работает?</p></blockquote></div><p>Нет, пишет что скрипт написан для&nbsp; AHK версии 1.</p>]]></description>
			<author><![CDATA[null@example.com (21nordson)]]></author>
			<pubDate>Fri, 20 Mar 2026 18:57:31 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163205#p163205</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163204#p163204</link>
			<description><![CDATA[<p>Скрипт по ссылке у меня работает. Там одна проблема: если мы установили состояние индикатора программно, то его уже нельзя получить через GetKeyState. Но для данной задачи это и не нужно.<br /><strong>21nordson</strong>, у вас скрипт работает?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 20 Mar 2026 18:55:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163204#p163204</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163203#p163203</link>
			<description><![CDATA[<p>Вроде как невозможно отвязать системную индикацию на клавиатуре. Предлагаю вместо этого использовать другой индикатор.</p>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Fri, 20 Mar 2026 17:31:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163203#p163203</guid>
		</item>
		<item>
			<title><![CDATA[AHK: AHK V2 управление светодиодом caps lock (индикация раскладки)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=163201#p163201</link>
			<description><![CDATA[<p>Очень прошу помощи. Нашёл в интернете скрипт смены раскладки при нажатии capslock, но беда в том, что при работе этого скрипта светодиод кнопки не работает. А хотелось бы, что бы на английской раскладке светодиод капслока горел, а при переключении на русскую - не горел. Есть какая-то возможность управления светодиодном во второй версии программы? Гуглом нашёл только скрипт (библиотеку?) для старой версии autohotkey_L. <a href="http://www.autohotkey.com/board/topic/9587-keyboard-led-control-capslocknumlockscrolllock-lights/?p=446105">www.autohotkey.com/board/topic/9587-key … /?p=446105</a><br />Сам скрипт смены раскладки по нажатию капслока<br /></p><div class="codebox"><pre><code>#Requires AutoHotkey v2.0

SetCapsLockState(&quot;AlwaysOff&quot;)
+CapsLock::{
    if (GetKeyState(&quot;CapsLock&quot;, &quot;T&quot;)) {
        SetCapsLockState(&#039;Off&#039;)
    } else {
        SetCapsLockState(&#039;On&#039;)
    }
}
CapsLock::Send(&quot;{Ctrl down}{Shift down}{Shift up}{Ctrl up}&quot;)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (21nordson)]]></author>
			<pubDate>Fri, 20 Mar 2026 17:14:46 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=163201#p163201</guid>
		</item>
	</channel>
</rss>
