Automation 自动热键切换脚本
我只想使用相同的键映射(Ctrl+I)切换命令:Automation 自动热键切换脚本,automation,autohotkey,Automation,Autohotkey,我只想使用相同的键映射(Ctrl+I)切换命令: 如果我按Ctrl+I,它会键入blabla(当然),我想让它以一定的间隔(180秒)重复,我想切换它。怎么做?您将要使用 我不知道你为什么要使用这两个指令,它们对脚本没有任何用处 但是关于使用计时器: SetTimer,TimerCallback,180000 这将创建一个计时器,该计时器每隔180000毫秒(180秒)触发函数(或标签)TimerCallback。 当然,我们还需要定义函数TimerCallback,所以现在就让我们这样做: T
如果我按Ctrl+I,它会键入blabla(当然),我想让它以一定的间隔(180秒)重复,我想切换它。怎么做?您将要使用 我不知道你为什么要使用这两个指令,它们对脚本没有任何用处 但是关于使用计时器:
SetTimer,TimerCallback,180000
这将创建一个计时器,该计时器每隔180000毫秒(180秒)触发函数(或标签)
TimerCallback
。当然,我们还需要定义函数
TimerCallback
,所以现在就让我们这样做:
TimerCallback()
{
Tooltip, hi
}
然后通过热键打开/关闭计时器:
^i::
toggle := !toggle ;a convenient way to toggle a variable in AHK, see below of explanation
if (toggle) ;if true
{
SetTimer, TimerCallback, 180000 ;turn on timer
;the function will only run for the first timer after
;those 180 secs, if you want it to run once immediately
;call the function here directly:
TimerCallback()
}
else
SetTimer, TimerCallback, Off ;turn off timer
return
切换的说明:=!切换
变量状态切换可以从我以前的答案中找到。还包括一个甜美的1线性定时器切换热键示例
下面是完整的示例脚本:
^i::
toggle := !toggle ;a convenient way to toggle a variable in AHK, see below of explanation
if (toggle) ;if true
{
SetTimer, TimerCallback, 180000 ;turn on timer
;the function will only run for the first timer after
;those 180 secs, if you want it to run once immediately
;call the function here directly:
TimerCallback()
}
else
SetTimer, TimerCallback, Off ;turn off timer
return
TimerCallback()
{
Tooltip, hi
}
这很有帮助,但现在我必须这样做:首先
send,blablabla
然后在180秒后,send,asdfghjkl
如何做?
^i::
toggle := !toggle ;a convenient way to toggle a variable in AHK, see below of explanation
if (toggle) ;if true
{
SetTimer, TimerCallback, 180000 ;turn on timer
;the function will only run for the first timer after
;those 180 secs, if you want it to run once immediately
;call the function here directly:
TimerCallback()
}
else
SetTimer, TimerCallback, Off ;turn off timer
return
TimerCallback()
{
Tooltip, hi
}