<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>SetControlDelay</h1> <p>设置每个控件改动函数后将发生的延迟.</p> <pre class="Syntax"><span class="func">SetControlDelay</span> Delay</pre> <h2 id="Parameters">参数</h2> <dl> <dt>Delay</dt> <dd> <p>类型: <a href="../Concepts.htm#numbers">整数</a></p> <p>时间(单位为毫秒). 指定 -1 表示无延时, 或 0 表示最小延时.</p> </dd> </dl> <h2 id="Return_Value">返回值</h2> <p>整数: <a href="../Concepts.htm#numbers">整数</a></p> <p>函数返回以前的设置.</p> <h2 id="Remarks">备注</h2> <p>如果没有使用 SetControlDelay, 默认的延迟为 20.</p> <p>在每个变更控件的函数之后, 都会自动进行短暂的延时(休眠). 这样做提高了脚本的可靠性, 因为控件在被这些函数之一更改后有时需要一段 "休息" 时间, 这允许它更新自身并响应脚本可能尝试发送给它的下一个函数.</p> <p>具体来说, SetControlDelay 影响以下函数: <a href="ControlAddItem.htm">ControlAddItem</a>, <a href="ControlChooseIndex.htm">ControlChooseIndex</a>, <a href="ControlChooseString.htm">ControlChooseString</a>, <a href="ControlClick.htm">ControlClick</a>, <a href="ControlDeleteItem.htm">ControlDeleteItem</a>, <a href="EditPaste.htm">EditPaste</a>, <a href="ControlFindItem.htm">ControlFindItem</a>, <a href="ControlFocus.htm">ControlFocus</a>, <a href="ControlHide.htm">ControlHide</a>, <a href="ControlHideDropDown.htm">ControlHideDropDown</a>, <a href="ControlMove.htm">ControlMove</a>, <a href="ControlSetChecked.htm">ControlSetChecked</a>, <a href="ControlSetEnabled.htm">ControlSetEnabled</a>, <a href="ControlSetText.htm">ControlSetText</a>, <a href="ControlShow.htm">ControlShow</a>, <a href="ControlShowDropDown.htm">ControlShowDropDown</a>.</p> <p><a href="ControlSend.htm">ControlSend</a> 不受影响; 它使用 <a href="SetKeyDelay.htm">SetKeyDelay</a>.</p> <p>虽然允许使用 -1(完全无延时), 但建议至少使用 0, 以增强即使在 CPU 处于负载状态下脚本也能正确运行的几率.</p> <p>延时为 0 时实际内部会执行 Sleep(0), 这会将脚本时间片段的剩余部分提供给可能需要它的任何其他进程. 如果没有其他进程需要, 则 Sleep(0) 相当于完全没有延时.</p> <p>如果 CPU 比较慢或在负载下, 或启用了窗口动画, 那么可能需要较高的延迟值.</p> <p>内置变量 <strong>A_ControlDelay</strong> 包含了当前设置, 也可以为其赋予新的值, 而不用调用 SetControlDelay.</p> <p>每个新运行的<a href="../misc/Threads.htm">线程</a>(如 <a href="../Hotkeys.htm">热键</a>, <a href="Menu.htm">自定义菜单项</a>或<a href="SetTimer.htm">定时</a>子程序) 都会以此函数的默认设置开始. 这个默认设置可以通过在<a href="../Scripts.htm#auto">脚本启动</a>中使用此函数来改变.</p> <h2 id="Related">相关</h2> <p><a href="Control.htm">控件函数</a>, <a href="SetWinDelay.htm">SetWinDelay</a>, <a href="SetKeyDelay.htm">SetKeyDelay</a>, <a href="SetMouseDelay.htm">SetMouseDelay</a></p> <h2 id="Examples">示例</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> 在每次控件修改命令后产生尽可能小的延迟.</p> <pre>SetControlDelay 0</pre> </div> <a href="https://dftg.net">dftg</a><!-- Cloudflare Pages Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "d5a9c4fcb9b6482fa53ce820d892f969"}'></script><!-- Cloudflare Pages Analytics --><script defer src="https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon='{"rayId":"92d95ca25b8aeafd","version":"2025.3.0","r":1,"serverTiming":{"name":{"cfExtPri":true,"cfL4":true,"cfSpeedBrain":true,"cfCacheStatus":true}},"token":"51750bb5dc4f40cc91a5ec55c63bbc01","b":1}' crossorigin="anonymous"></script> </body> </html>