Help make random string script with random length (in probably specified range, something like from 8 to 24 characters),
something like based on this thread:
https://www.autohotkey.com/boards/viewtopic.php?t=76052
ATM I have such script:
^SC039:: ; Ctrl+Space as
s := (s := "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z, ") "," s "," s
Sort, s, Random D,
i := SubStr(StrReplace(s, ","), 2, 23)
Send, % i
Random string script with random length Topic is solved
Re: Random string script with random length Topic is solved
What does your script actually do?
What should it do instead?
What is your example?
What should it do instead?
What is your example?
Code: Select all
#Requires AutoHotkey v1.1.33
^Space::
str := ""
Random n, 8, 24
Loop % n {
Random c, 33, 126
str .= Chr(c)
}
SendInput % "{Text}" str
Return
Code: Select all
#Requires AutoHotkey v1.1.33
^Space::
s := "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"
Random n, 8, 24
Sort s, Random D,
SendInput % SubStr(StrReplace(s, ","), 1, n)
Return
Re: Random string script with random length
mikeyww,
I often improvise in DAW (digital audio workstation),
and sometimes I want to quickly save new project,
so, I prefer to give random name to it
(anyway it will be in list of recent projects);
so, I searched for way to make (enter) random name (string):
let's say after pressing Ctrl+Space
which at first sends Ctrl+S or Ctrl+Alt+Shift+S
and then enters random name (string).
Thanks, your answer helped me.
I often improvise in DAW (digital audio workstation),
and sometimes I want to quickly save new project,
so, I prefer to give random name to it
(anyway it will be in list of recent projects);
so, I searched for way to make (enter) random name (string):
let's say after pressing Ctrl+Space
which at first sends Ctrl+S or Ctrl+Alt+Shift+S
and then enters random name (string).
Thanks, your answer helped me.
Re: Random string script with random length
hi, ARKaine and mikeyww
I think mikeyww's first script fails because it adds characters that are not accepted when creating a file/directory name in Windows directives, like \ or @. The second is better.
I think mikeyww's first script fails because it adds characters that are not accepted when creating a file/directory name in Windows directives, like \ or @. The second is better.
Re: Random string script with random length
Yes; the need was originally unclear.
A simpler approach may be using a simple numeric file suffix. One can check to see whether the file already exists, and then increment the numeric suffix until the file is not found. This may be more reliable and easier than selecting a random number.
A simpler approach may be using a simple numeric file suffix. One can check to see whether the file already exists, and then increment the numeric suffix until the file is not found. This may be more reliable and easier than selecting a random number.
Re: Random string script with random length
For fun:
Because https://biga-ahk.github.io/biga.ahk/#/?id=samplesize will not sample the same element twice, this will always produce strings with no repeat characters
Code: Select all
A := new biga() ; requires https://github.com/biga-ahk/biga.ahk
inputArray := StrSplit("0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z", ",")
msgbox, % A.join(A.sampleSize(inputArray, A.random(8, 24)), "")
; => "vcap6lwi24sy59gnoxefm1u7"