Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Help! Cycling through a list of options with one hotkey.


  • Please log in to reply
9 replies to this topic
Tony Baloney
  • Guests
  • Last active:
  • Joined: --
I am trying to figure out a way (in a game) to have one button cycle through skills in order, one per key press.

For example:

Button A is my hotkey. I press A once it loads skill x, I press it again and it loads skill y, I press once again and it loads skill z.

Is this possible?

Thank you!

Tony Baloney
  • Guests
  • Last active:
  • Joined: --
I forgot to mention, each of the individual skills will be bound to a different button ingame.

RaptorX
  • Members
  • 751 posts
  • Last active: Feb 19 2015 02:47 AM
  • Joined: 19 Feb 2010
Is very simple...

lets say you have 3 skills and the keys for each are X,Y,Z...

something like this might work:

a::
 key++                         ; this will help cycling through the keys depending on its value
 if key = 1
    Send, x
 else if key = 2
    Send, y
 else if key = 3
 {
    Send, z
    key = 0                    ; return to the original state... do this on the last hotkey you would like to send
 }
return

If the code doesnt work on the game, try using SendInput, or SendPlay or playing with SetKeyDelay.

Modify the script to your needs. (I suggest making that script specific for the game with #IfWinActive)

Hope this helps

Tony Baloney
  • Guests
  • Last active:
  • Joined: --
PERFECT! Thank you so much, I got it working with no modifications!!

corey
  • Members
  • 8 posts
  • Last active: Aug 12 2010 05:45 AM
  • Joined: 30 Jul 2010
Here's a quick application of the above mentioned script that you can run on your desktop to test/learn the logics in the cycle.

v::
{
key++                        
 if key = 1
    Sendinput, b
 else if key = 2
    Sendinput, n
 else if key = 3
    Sendinput, m
}
return

b::MsgBox You pressed B!!

n::MsgBox You pressed N!!

m::
{
MsgBox You pressed M!!
Key = 0
MsgBox Cycle Reset!!
}
return

Pressing "V" repeatedly will trigger the MSGBOX's for "B", "N", and "M" sequentially and then reset so the 4th press of "V" triggers "B" again and so forth.

None
  • Members
  • 3199 posts
  • Last active: Nov 05 2015 09:55 PM
  • Joined: 28 Nov 2009
List=bnm

v:: 

key++                        

Sendinput, % SubStr(List,Mod(Key,3),1) ;if you use Mod you don't need to reset the Var

return 



b::

n::

m::

MsgBox You pressed %A_ThisHotkey%!! 

Return


corey
  • Members
  • 8 posts
  • Last active: Aug 12 2010 05:45 AM
  • Joined: 30 Jul 2010

List=bnm
v:: 
key++                        
Sendinput, % SubStr(List,Mod(Key,3),1) ;if you use Mod you don't need to reset the Var
return 

b::
n::
m::
MsgBox You pressed %A_ThisHotkey%!! 
Return


I copy pasted thsi code and didnt get any functionality for keypress "v" triggering list b, n, m hotkeys... it jsut didnt work... not sure why because i dont know the theory of the command "Mod"

corey
  • Members
  • 8 posts
  • Last active: Aug 12 2010 05:45 AM
  • Joined: 30 Jul 2010
Also what i posted first there with the bnm keys on the desctop works fine, but in practice something is breaking the cycle reset and im not sure why.??? Here is the code in game (using alt hotkeys due to keyboard space issues (game has alot of hotkeys).

;;;;;;;;;;;;;;;;;;;;;;Chain (cast a cycle of differnt abilities)
rbutton & lbutton::
keywait lbutton 
{key++             
 if key = 1
    Sendinput {altdown}{y}{altUP}
 else if key = 2
    Sendinput {altdown}{u}{altUP}
 else if key = 3
    Sendinput {altdown}{i}{altUP}
 else if key = 4
    Sendinput {altdown}{o}{altUP}
 else if key = 5
    Sendinput {altdown}{p}{altUP}
}
return

!p::key = 0

The chain triggers perfectly of course, depress both mouse buttons and then letup on lbutton, triggers y, keep holding rbutton and press and release lbutton again, triggers u, etc... but after triggering p nothing happens and the cycle is stuck.

Any help would be greatly appreciated

None
  • Members
  • 3199 posts
  • Last active: Nov 05 2015 09:55 PM
  • Joined: 28 Nov 2009
The easiest way to fix your is to...
;;;;;;;;;;;;;;;;;;;;;;Chain (cast a cycle of differnt abilities)
rbutton & lbutton::
keywait lbutton 
{key++             
 if key = 1
    Sendinput {altdown}{y}{altUP}
 else if key = 2
    Sendinput {altdown}{u}{altUP}
 else if key = 3
    Sendinput {altdown}{i}{altUP}
 else if key = 4
    Sendinput {altdown}{o}{altUP}
 else if key = 5
   {
    Sendinput {altdown}{p}{altUP}
    key=0 ;reset key here
    }
}
return
I don't know why mine didn't work for you it works here :?

corey
  • Members
  • 8 posts
  • Last active: Aug 12 2010 05:45 AM
  • Joined: 30 Jul 2010
@None Thanks for the quick response and the help. It works fine now... It always seems so simple after you're shown how to do it.

Great job!