Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Cycle Keys with one button


  • Please log in to reply
9 replies to this topic
Asdaw
  • Guests
  • Last active:
  • Joined: --
Hey, I have searched, tested and looked for hours, now I give up and hope you guys can help me.

I wonder how I can cycle my keys with one button.

Pressing Numpad1 to get:

F1,F2,F3,altF4 or like altQ, W,E,O,M

Not all in one place like first F1 then F2 and so on.

I have tried with counter and stuffs but I dont seem to get it to work. :/

Thanks in advance.

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
Don't forget -- all sends in this routine will go to the active window. Also, it only cycles through the keys one time for each press of the Numpad1 or NumpadEnd key.

s = 200   ;200 ms sleep between key sends
keyList = {F1},{F2},{F3},!{F4},!Q,W,E,O,M
StringSplit, KeyAry, KeyList, `,,%A_Space%
Return


*$NumPad1::
*$NumPadEnd::
SendAgain:
loop %KeyAry0%
{    Send, KeyAry%A_Index%
     Sleep, %s%
}
Return

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
Almost:

s = 200   ;200 ms sleep between key sends
keyList = {F1},{F2},{F3},!{F4},!Q,W,E,O,M
StringSplit, KeyAry, KeyList, `,,%A_Space%
Return


*$NumPad1::
*$NumPadEnd::
SendAgain:
loop %KeyAry0%
{
	Send [color=red]%[/color]	KeyAry%A_Index%
	Sleep, %s%
}
Return


MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Very related: Cycle()

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Actually, for my text-with-numberpad script (another alernative to one handed typing - soon to come) I needed to write something along those lines.
keys = a,b,{F5},c
counter = 0
StringSplit array, Keys,`,
a::
    counter := (counter<array0) ? (counter+1) : (1)
    Send % array%counter%
return
As I am recalling this from memory while typing on my phone, I sincerely apologize if the StringSplit command has mismatched or wrong parameters. That being said, even if it is wrong you should get the gist of it.

asdaw
  • Guests
  • Last active:
  • Joined: --
Thanks for all answers, this is how far I have gotten and Im stuck here,
It keeps getting stuck and stop works, other codes still work but the codes with cycle stop.

*NumpadEnd::Send, {Blind}{Numpad1}
key++                       
 if key = 1
 Sendinput, !{F1}
 else if key = 2
    Sendinput, !{F2}
 else if key = 3
   { Sendinput, !{F3}
key = 0
}
return
numpad1::
key++                       
 if key = 1
 Sendinput, !{F1}
 else if key = 2
    Sendinput, !{F2}
 else if key = 3
   { Sendinput, !{F3}
key = 0
}
return

Not sure if it is because I have same lines under but with different hotkeys. But all I know is that it get stuck.

Thanks for anyhelp I can get. :)

None
  • Members
  • 3199 posts
  • Last active: Nov 05 2015 09:55 PM
  • Joined: 28 Nov 2009
*NumpadEnd:: ;nothing here unless it is a one line hotkey

Send, {Blind}{Numpad1} 

key++                        

 if key = 1 

...


girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
loopCounter = 2 ; this is the number of loops to send when alt-r is pressed

s = 200   ;200 ms sleep between key sends

; set the key list to whatever keys you want to sequence

; can be used for any keys you want to send in a sequence

;keyList = !{F1},!{F2},!{F3}

keylist = 1,2,3

StringSplit, KeyAry, KeyList, `,,%A_Space%

Return

;--------------------



;--------------------

; alt-r resends the sequence %LoopCounter% times

!r::

loop, %LoopCounter%

{  gosub SendAgain

   Sleep, %s%

}

Return



;--------------------

; this sends the key sequence one time

*$NumPadEnd::

; the label SendAgain is there simply to allow you to call the sequence

; as a subroutine

SendAgain:

loop %KeyAry0%

{     key := KeyAry%A_Index%

     Send, %key%

     Sleep, %s%

}

Return


The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Did you even check my Cycle() function?

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
The Definitive autofire thread has a concise example you may be interested in