How to disable repeating numbers?
This is the code
$Xbutton2::
Random, rand, 7, 9
send %rand%
return
Thanks! Help ASAP!
How to disable repeat? Topic is solved
How to disable repeat?
Last edited by mitz0029 on 22 Apr 2018, 12:22, edited 1 time in total.
Re: How to disable repeat?
Mice buttons do not repeat when held, so no need for repeat suppression with mouse buttons.
For keyboard keys though, you need to use a variable. You can do repeat suppression with a KeyWait command, but it has side-effects if you do it with more than one key at once, so I advise against following any examples that use KeyWait or GetKeyState loops to achieve this.
For keyboard keys though, you need to use a variable. You can do repeat suppression with a KeyWait command, but it has side-effects if you do it with more than one key at once, so I advise against following any examples that use KeyWait or GetKeyState loops to achieve this.
Code: Select all
a_state:= 0
return
a::
if (a_state)
return
a_state := 1
; [Your code here]
return
a up::
a_state := 0
return
Re: How to disable repeat?
Turns out he wanted non-repeating random numbers.
Solution:
[Edit] Fixed typos
Solution:
Code: Select all
rand := RandomButNotLastNumber(7, 9)
Send % rand
return
RandomButNotLastNumber(min, max){
static last := ""
rand := last
while (rand == last){
Random, rand, % min, % max
}
last := rand
return rand
}
Last edited by evilC on 23 Apr 2018, 06:00, edited 1 time in total.
Re: How to disable repeat? Topic is solved
Turns out someone just asked me similar thing, apparently with the code above. I modified it for the answer before getting here though:
Just a different approach for the same thing, with a test included.
EDIT: Provided further assistance via Discord.
Code: Select all
values := []
Loop 10
values.Push(RandomButNotLastNumber(1, 2))
output := ""
for key, val in values
output .= key " = " val "`n"
MsgBox % output
RandomButNotLastNumber(min, max)
{
static last := ""
loop
{
Random, rand, %min%, %max%
if (rand != last)
break
}
last := rand
return rand
}
EDIT: Provided further assistance via Discord.
Use
Code: Select all
[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
Who is online
Users browsing this forum: No registered users and 379 guests