So I changed it (at the bottom) so it should be easy to add the hotkey under the section where you want your weapon0 and weapon1 keys to go. Obviously change the hotkeys/swap the 0 and 1 if they are backwards for what you consider weapon0 and weapon1.
You stated:
Not 100% sure what you mean here. I took it to mean: when you press t, it will inverse the state; so that you can manually press t and the function still tracks the correct state. I've added that. Let me know if I interpreted that incorrectly.
I'm also not sure what you mean by the rest. I'm going to use the following example you gave and explain what I think you mean.
I think what you want, is when you press r, if any (or all) of the keys being sent are hotkeys you set up, you also want those hotkeys to fire the code associated with them. If so, this can easily be achieve with the #InputLevel directive. I'll give a simple example to show how it works:
Anyway, here is the updated code so far.
You stated:
I'd like to integrate t into the function as needed.
Not 100% sure what you mean here. I took it to mean: when you press t, it will inverse the state; so that you can manually press t and the function still tracks the correct state. I've added that. Let me know if I interpreted that incorrectly.
I'm also not sure what you mean by the rest. I'm going to use the following example you gave and explain what I think you mean.
CODE:
$r:: Send "{h}{a}{r}{l}{9}{0}"
I think what you want, is when you press r, if any (or all) of the keys being sent are hotkeys you set up, you also want those hotkeys to fire the code associated with them. If so, this can easily be achieve with the #InputLevel directive. I'll give a simple example to show how it works:
CODE:
#InputLevel 1 ; set input level to 1, all hotkeys underneath this directive have the ability to trigger other hotkeys with a smaller input level
*F1::Send('{F2}')
#InputLevel 0 ; set input level back to default value so hotkeys underneath don't accidentally fire other hotkeys
*F2::MsgBox('This is a message')
Anyway, here is the updated code so far.
CODE:
; all weapon0 keys here
*w::
*r::
*y::
*F2::
*u::Attack(0)
; all weapon1 keys here
*1::
*2::
*3::
*F1::
*4::Attack(1)
~*t::Attack('toggle') ; ~ prefix allows
Attack(weapon)
{
static weaponState := false
if weapon = 'toggle' {
weaponState := !weaponState
return
}
if weaponState != weapon {
SendEvent('t')
weaponState := weapon
}
SendEvent('{' SubStr(A_ThisHotkey, 2) '}')
}
Statistics: Posted by niCode — Today, 06:18