Jump to content


Photo

Hold down key, key gets repeated always in even numbers.


  • Please log in to reply
4 replies to this topic

#1 elemenopea

elemenopea
  • Members
  • 2 posts

Posted 15 July 2012 - 06:19 PM

Hey there. New user here.

I have managed to get (through searching here :D) how to make a key repeat but I am having trouble getting the key to stop repeating always at an even number.

So I was wondering if anyone could help me? Essentially I think it would be something like

Repeat x
If x = OddNumber
+1

Many thanks! If anyone can help I will buy a virtual beer!

#2 None

None
  • Members
  • 3199 posts

Posted 15 July 2012 - 07:16 PM

Depending on what you need it could be this simple
$a::

while GetKeyState("a","P")

{

  Send a

  Sleep 100

  send a ;send the key an even number of times on each loop

  Sleep 100

}

Return


#3 elemenopea

elemenopea
  • Members
  • 2 posts

Posted 15 July 2012 - 07:18 PM

Hi there. Thanks for the reply!

I essentially want this code but instead of LControl I want the key V to be repeating the 1 pkey but always end on an even number of presses
$LControl:: 
send {LControl} 
sleep 610 
Loop 
{ 
GetKeyState, state, LControl, P 
if state = U 
break 
Sleep 150 
send 1 
} 
return


#4 None

None
  • Members
  • 3199 posts

Posted 15 July 2012 - 07:24 PM

$LControl:: 
send {LControl} 
sleep 610 
Loop 
{ 
GetKeyState, state, LControl, P 
if state = U 
break 
Sleep 150 
send 1 
Sleep 150 
send 1 
} 
return
If you put the send twice the loop will always end on a even number

#5 girlgamer

girlgamer
  • Moderators
  • 2039 posts

Posted 15 July 2012 - 07:35 PM

You can also use the Mod() function on the A_Index value in a loop to check if the loop count is odd or even as well. If the index is even, you simply break if it's odd you do one more send and break. If it's just a hold-down-this-key-spammer, then you have to do the counting for each send and Mod() that counter instead of A_Index.