<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1632085368384154" crossorigin="anonymous"></script><script src="https://autohotkey.top/gtag.js"></script></head> <body> <h1>SendLevel <span class="ver">[v1.1.06+]</span></h1> <p>控制热键和热字串是否忽略模拟的键盘和鼠标事件.</p> <pre class="Syntax"><span class="func">SendLevel</span>, Level</pre> <h2 id="Parameters">参数</h2> <dl> <dt>Level</dt> <dd><p>介于 0 和 100 之间的整数, 可以为<a href="../Variables.htm#Expressions">表达式</a>.</p></dd> </dl> <h2>一般说明</h2> <p>默认情况下, <a href="_UseHook.htm">钩子</a><a href="../Hotkeys.htm">热键</a>和<a href="Hotstrings.htm">热字串</a>会忽略由任何 AutoHotkey 脚本生成的键盘和鼠标事件. 在某些情况下它可用于覆盖默认行为; 例如, 可使用重映射键来触发其他热键. SendLevel 和 <a href="_InputLevel.htm">#InputLevel</a> 提供了实现此目的的方法.</p> <p>SendLevel 设置由当前<a href="../misc/Threads.htm">脚本线程</a>生成的事件级别, 而 #InputLevel 设置它下面所有热键或热字串的级别. 要让脚本生成的事件触发钩子热键或热字串, 则此事件的发送级别必须高于热键或热字串的输入级别.</p> <p>兼容性:</p> <ul> <li><a href="Send.htm#SendPlayDetail">SendPlay</a> 不受 SendLevel 影响.</li> <li><a href="Send.htm#SendInputDetail">SendInput</a> 会受 SendLevel 的影响, 但在 SendInput 执行时其所在脚本中的钩子热键无法激活, 因为这个命令会让钩子暂时失效. 但是, 当 Send 或 SendInput <a href="Send.htm#SendInputUnavail">恢复为 SendEvent</a> 时, 它可以激活脚本自己的热键.</li> <li>使用 <a href="ListHotkeys.htm">"reg"</a> 方法实现的热键不能区分物理和模拟输入, 所以不会受 SendLevel 的影响. 然而, 级别高于 0 的热键总是使用了键盘或鼠标钩子.</li> <li><a href="../Hotstrings.htm">热字串</a>仅使用 #InputLevel 来确定最后一个键入的字符是否应该触发热字串. 例如, 无论 #InputLevel 是什么, 都可以通过级别为 1 或更高级别的发送 <code>btw</code> 和物理输入<a href="../Hotstrings.htm#EndChars">结束字符</a>来触发热字串 <code>::btw::</code>. 这是因为热字串识别的工作原理是将除 0 级以外的所有级别的输入收集到单个全局缓冲区中.</li> <li>自动替换型<a href="Hotstrings.htm">热字串</a>生成事件的级别总是为 0, 因为通常在替换文本时不希望触发其他热字串或热键. 要变通解决此问题, 请使用非自动替换型热字串和 SendEvent 命令.</li> <li>即使使用 SendLevel, 通过 <a href="Send.htm#asc">ASC (Alt+nnnnn)</a> 的方法发送字符也不能触发热字串.</li> <li>通过 SendEvent 的 <a href="Send.htm#SendText">{Text}</a> 模式发送字符, <a href="Send.htm#Unicode">{U+nnnn}</a> 或 <a href="Send.htm#characters">Unicode fallback method</a> 可以触发热字串.</li> </ul> <p><span class="ver">[v1.1.23+]:</span> 内置变量 <strong>A_SendLevel</strong> 包含当前设置.</p> <p>每个新运行的热键或热字串<a href="../misc/Threads.htm">线程</a>初始的发送级别等于此热键或热字串的<a href="_InputLevel.htm">输入级别</a>. 每个新运行的其他线程(例如 <a href="Menu.htm">自定义菜单项</a>或<a href="SetTimer.htm">定时</a>子程序) 都会以默认设置开始, 一般为 0, 不过可以在<a href="../Scripts.htm#auto">自动执行段</a>中使用此命令进行改变.</p> <p>如果在<a href="../Scripts.htm#auto">自动执行段</a>中使用 SendLevel, 它还会影响<a href="misc/Remap.htm">键盘和鼠标重映射</a>.</p> <p>早于 <span class="ver">[v1.1.06]</span> 的 AutoHotkey 版本会表现的就像 <code>#InputLevel 0</code> 和 <code>SendLevel 0</code> 那样.</p> <h2 id="Related">相关</h2> <p><a href="_InputLevel.htm">#InputLevel</a>, <a href="Send.htm">Send</a>, <a href="Click.htm">Click</a>, <a href="MouseClick.htm">MouseClick</a>, <a href="MouseClickDrag.htm">MouseClickDrag</a></p> <h2 id="Examples">示例</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> SendLevel 允许触发另一个脚本的热键和热字符串, 而通常情况下是不会的.</p> <pre> SendLevel 1 Send btw{Space} <em>; 生成 "by the way ".</em> <em>; 这可以在其他脚本中定义:</em> ::btw::by the way </pre> </div> <a href="https://dftg.net">dftg</a></body> </html>