我已经阅读了自动热键的文档,但对于编写脚本还是新手。我不断收到错误。
我想要一个非常简单的脚本 - 所以当我使用热键 CTRL-ALT-N - Autohotkey 会创建一个随机数:
3 位数字 - 十进制 - 8 位数字
第一组的第一个数字在 1 到 4 之间。
其余的可以完全随机。
在示例脚本之外,我尝试编辑一个已发布的脚本 - 但我做错了。如果有人可以提供帮助,我们将不胜感激!
输出应如下所示:314.99382028 第一个数字始终在 1 到 4 之间,其余数字是随机的,小数始终是第 4 个字符。
然后,它应该只是将号码粘贴到您当前在窗口中的任何位置 - 而不是弹出显示。
感谢任何可以快速浏览并提供帮助的人。
火箭
^!n:: ;<-- change this if you want a diff hotkey
Chars1 = 1234
Chars2 = 1234567890
Chars3 = .
str =
clipboard =
UpperRange = 3 ;<-- use all 3 character strings
len = 12 ;<-- number of characters in the number
; generate a new number
loop, %len%
{ random,x,1,%UpperRange% ;<-- selects the Character string
random,y,1,26 ;<-- selects the character in the string
if (x = 12) ; if numeric there are only 10 digits
}
{ random,y,1,10
StringMid,z,Chars%x%,1 ;<-- grab the selected letter
str = %str%%z% ;<-- and add it to the number string
}
clipboard = %str% ;<-- put the completed string on the clipboard
Clipwait ;<-- wait for the clipboard to accept the string`
然后粘贴到我的光标所在的位置 - 不知道该怎么做。
非常感谢您的帮助!
火箭
最佳答案
如果我理解正确的话,这应该可以完成工作:
^!n::
SendInput, % "{LButton}" . RandomString(1,"1234") . RandomString(2) . "." . RandomString(8)
Return
RandomString(length,chars:="0123456789") {
charsCount := StrLen(chars)
Loop % length {
Random, num, 1, % StrLen(chars)
string .= SubStr(chars,num,1)
}
Return string
}
关于random - 需要帮助 - 使用 Autohotkey 脚本的简单随机数生成器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26564804/