我有这个很酷的小程序,但是我不能使用hotstrings。如何在不搞砸整个程序的情况下让热字串工作? 这个节目是为了对我朋友的恶作剧,他一直吹嘘他的打字速度。对于您输入的每封信,您的信件将有10%的可能性被翻倍,而且您的信件被删除的可能性为10%。
::test::success
$a::
rand := Random(0,100)
if( rand > 10 )
send, a
if( rand > 90 )
send, a
return
$b::
rand := Random(0,100)
if( rand > 10 )
send, b
if( rand > 90 )
send, b
return
$c::
rand := Random(0,100)
if( rand > 10 )
send, c
if( rand > 90 )
send, c
return
$d::
rand := Random(0,100)
if( rand > 10 )
send, d
if( rand > 90 )
send, d
return
$e::
rand := Random(0,100)
if( rand > 10 )
send, e
if( rand > 90 )
send, e
return
$f::
rand := Random(0,100)
if( rand > 10 )
send, f
if( rand > 90 )
send, f
return
$g::
rand := Random(0,100)
if( rand > 10 )
send, g
if( rand > 90 )
send, g
return
$h::
rand := Random(0,100)
if( rand > 10 )
send, h
if( rand > 90 )
send, h
return
$i::
rand := Random(0,100)
if( rand > 10 )
send, i
if( rand > 90 )
send, i
return
$j::
rand := Random(0,100)
if( rand > 10 )
send, j
if( rand > 90 )
send, j
return
$k::
rand := Random(0,100)
if( rand > 10 )
send, k
if( rand > 90 )
send, k
return
$l::
rand := Random(0,100)
if( rand > 10 )
send, l
if( rand > 90 )
send, l
return
$m::
rand := Random(0,100)
if( rand > 10 )
send, m
if( rand > 90 )
send, m
return
$n::
rand := Random(0,100)
if( rand > 10 )
send, n
if( rand > 90 )
send, n
return
$o::
rand := Random(0,100)
if( rand > 10 )
send, o
if( rand > 90 )
send, o
return
$p::
rand := Random(0,100)
if( rand > 10 )
send, p
if( rand > 90 )
send, p
return
$q::
rand := Random(0,100)
if( rand > 10 )
send, q
if( rand > 90 )
send, q
return
$r::
rand := Random(0,100)
if( rand > 10 )
send, r
if( rand > 90 )
send, r
return
$s::
rand := Random(0,100)
if( rand > 10 )
send, s
if( rand > 90 )
send, s
return
$t::
rand := Random(0,100)
if( rand > 10 )
send, t
if( rand > 90 )
send, t
return
$u::
rand := Random(0,100)
if( rand > 10 )
send, u
if( rand > 90 )
send, u
return
$v::
rand := Random(0,100)
if( rand > 10 )
send, v
if( rand > 90 )
send, v
return
$w::
rand := Random(0,100)
if( rand > 10 )
send, w
if( rand > 90 )
send, w
return
$x::
rand := Random(0,100)
if( rand > 10 )
send, x
if( rand > 90 )
send, x
return
$y::
rand := Random(0,100)
if( rand > 10 )
send, y
if( rand > 90 )
send, y
return
$z::
rand := Random(0,100)
if( rand > 10 )
send, z
if( rand > 90 )
send, z
return
Random(min,max)
{
Random, random, %min%, %max%
return random
}
答案 0 :(得分:1)
只是想加入并指出一个可能更好的解决方案。
有一个名为Input的命令会读取按下的每个键,并允许您对其进行操作。使用你对“恶作剧”的描述,我想出了这个小脚本:
Loop {
; Add any Key in {Key} format followed by Period . that you want to act as an EndKey.
Input, Key, L1 M, {space}.{esc}.{shift}.{enter}
.{tab}.{backspace}.{alt}.{home}
.{delete}.{pgup}.{pgdn}.{end}
.{up}.{down}.{left}.{right}
If (Key <> "") {
rand := Random(0,100)
If (Rand > 90) {
Send, %key%
}
Send, %key%
}
If InStr(ErrorLevel, "EndKey:")
Send % "{" . StrReplace(ErrorLevel, "EndKey:") . "}"
}
;Took me a second to figure out why your Random Function wasn't working as AHK only has a Random Command ;)
Random(Min := "", Max := "") {
Random, OutputVar, %Min%, %Max%
Return OutputVar
}
答案 1 :(得分:0)
默认情况下,hook hotkeys和hotstrings会忽略任何AutoHotkey脚本生成的键盘和鼠标事件。
在某些情况下,覆盖此行为可能很有用;例如,允许重新映射的密钥用于触发其他热键。 SendLevel和#InputLevel提供了实现此目标的方法。