Hello all,
I am new to autohotkey. I have been tinkering for several hours but am unable to figure this one out:
what I need is a script that when I press "alt+2" the script sends "0+2" as zero is the modifier. I have tried something like the following:
/code
setkeydelay,-1,20
!2::
send, 0
sleep 10
send, 2
[/code]
My reasoning behind doing it that was is I intended to have the "0" key held for 20 milliseconds, with the "2" key being pressed 10 milliseconds into the "0" duration. This way it is like holding down 0 and pressing 2, which is what i need.
Thanks in advance for your insight!
Creating hotkeys that execute a "modifier + key" string
Started by
sandwich1
, Jun 03 2012 03:55 AM
6 replies to this topic
#1
sandwich1
Posted 03 June 2012 - 03:55 AM
#2
Posted 03 June 2012 - 04:00 AM
This is the usual method for holding a key down:
send, {0 down}2{0 up}orsend, {0 down}
send, 2
send, {0 up}
#3
Posted 03 June 2012 - 04:02 AM
This might work.
*!2::
send, {0 down}
sleep 10
send, {2}{0 up}
return
#4
sandwich1
Posted 03 June 2012 - 05:37 AM
thank you both for your prompt input.
I attempted the code suggested by pulover. it is working to some extent. the program I am using this script for is Star Wars: the Old Republic. what I'd like to accomplish is being able to use a "self-cast" modifier of alt on all my healing spells via autohotkey. unfortunately for some reason the game developers integrated the ability to bind a key as a "self-cast" modifier, but for some reason disallowed ctrl, shift, and alt to function as said keybind. Using the self-cast modifier allows me to cast spells on myself without changing my current target, thus making it quicker and more synergystic to cast various spells on various targets in sequence.
I have already tried remapping alt to the self-cast modifier i assigned in-game and it works like a charm but then I run into a whole mess of issues, first and foremost is being able to "alt-tab" between windows in windows 7. Additionally, there are other modifiers in-game that I would like to bind to other extraneous keys similar to "0" that I don't use physically. There is a modifier to direct spells toward a secondary target (without changing primary target), namely. This way, I can use "alt" as a modifier of my choosing using autohotkey and bind the combination of alt and various keys to specific spells directed at different specific targets (ie myself, secondary target), all without actually changing my primary target.
This is the script I just tried running to no avail in-game (i also ran the script as written verbatim by pulover, but made some modifications to attempt to get it to work):
/code
*!2::
send, {0 down}
sleep 30
send, {2}
sleep 30
send, {0 up}
return
[/code]
It did not appear to have any success in game. When I use script in text field it successfully types out "02". No way of knowing if the sleeps are functioning correctly. It is also possible that the sleeps are not long enough to be registered by the game client, but I have a hunch this isn't the issue.
I did have some results from the following script when I was tinkering earlier today (not that it performed as intended but that the game client gave me positive feedback that the modifier was indeed being "pressed", but not long enough to modify the spell to override the default target):
/code
!2::send, 0 & 2
[/code]
The game client indicated upon executing this particular script that the modifier did not successfully modify the target of the casted spell.
Thanks again for such a swift response!
I attempted the code suggested by pulover. it is working to some extent. the program I am using this script for is Star Wars: the Old Republic. what I'd like to accomplish is being able to use a "self-cast" modifier of alt on all my healing spells via autohotkey. unfortunately for some reason the game developers integrated the ability to bind a key as a "self-cast" modifier, but for some reason disallowed ctrl, shift, and alt to function as said keybind. Using the self-cast modifier allows me to cast spells on myself without changing my current target, thus making it quicker and more synergystic to cast various spells on various targets in sequence.
I have already tried remapping alt to the self-cast modifier i assigned in-game and it works like a charm but then I run into a whole mess of issues, first and foremost is being able to "alt-tab" between windows in windows 7. Additionally, there are other modifiers in-game that I would like to bind to other extraneous keys similar to "0" that I don't use physically. There is a modifier to direct spells toward a secondary target (without changing primary target), namely. This way, I can use "alt" as a modifier of my choosing using autohotkey and bind the combination of alt and various keys to specific spells directed at different specific targets (ie myself, secondary target), all without actually changing my primary target.
This is the script I just tried running to no avail in-game (i also ran the script as written verbatim by pulover, but made some modifications to attempt to get it to work):
/code
*!2::
send, {0 down}
sleep 30
send, {2}
sleep 30
send, {0 up}
return
[/code]
It did not appear to have any success in game. When I use script in text field it successfully types out "02". No way of knowing if the sleeps are functioning correctly. It is also possible that the sleeps are not long enough to be registered by the game client, but I have a hunch this isn't the issue.
I did have some results from the following script when I was tinkering earlier today (not that it performed as intended but that the game client gave me positive feedback that the modifier was indeed being "pressed", but not long enough to modify the spell to override the default target):
/code
!2::send, 0 & 2
[/code]
The game client indicated upon executing this particular script that the modifier did not successfully modify the target of the casted spell.
Thanks again for such a swift response!
#5
sandwich1
Posted 03 June 2012 - 05:51 AM
update:
the modified pulover-suggested script functions as intended when I bind the script to f4 instead of alt+2 (!2).
Now just need to try a few more tweeks, like binding the script to "! & 2" and stuff like that.
by the way, i am curious what the asterisk at the beginning of your suggested script does to the way the code is read (ie: "*!2::...")
the modified pulover-suggested script functions as intended when I bind the script to f4 instead of alt+2 (!2).
Now just need to try a few more tweeks, like binding the script to "! & 2" and stuff like that.
by the way, i am curious what the asterisk at the beginning of your suggested script does to the way the code is read (ie: "*!2::...")
#6
sandwhich1
Posted 03 June 2012 - 05:44 PM
still haven't figured out why the alt+2 combination isn't triggering the hotkey. and other single key works when i bind script to one. haven't tried other button combinations as hotkey binds yet.
#7
Posted 03 June 2012 - 09:51 PM
Hi, sandwhich1.
It's hard to say what's causing the issues, you should keep trying different things. Check the Hotkeys and remapping pages. The * symbol is to allow the hotkey to work when other modifiers are being held, I used it because it without that the hotkey would probably not repeat when holding alt key. You can also try to use {Blind} before the commands (check send page), it helps in games sometimes.
Another suggestion I can give you is another way of using two keys as a hotkey, as in this example:
It's hard to say what's causing the issues, you should keep trying different things. Check the Hotkeys and remapping pages. The * symbol is to allow the hotkey to work when other modifiers are being held, I used it because it without that the hotkey would probably not repeat when holding alt key. You can also try to use {Blind} before the commands (check send page), it helps in games sometimes.
Another suggestion I can give you is another way of using two keys as a hotkey, as in this example:
*2::
If GetKeyState("Alt", "P") ; when you press 2 it will check if alt is pressed before sending the commands.
{
send, {0 down}
sleep 10
send, {2}{0 up}
}
return




