Log in

View Full Version : Emergency movement with AutoHotkey



Akoko
01-22-2008, 01:35 AM
Hi, I'm wondering if there's a way to recognize key downs and key ups as separate events.

#IfWinActive, World of Warcraft
~^w::
ControlSend,,{Ctrl down}{w down}{w up}{Ctrl up}, ahk_id %idClone%
return

I'm trying to make it so that when I hold down control, it will make my clone move the same way. However, this is using the same format as when just pressing a single keystroke, like 1-9 for spells. If i try to hold down W, the clone will rapidly start and stop resulting in amusing, (and very very slow) forward twitching movements. Is there any way to measure an event, when I press down W it will keep moving until i release W?

Lokked
01-22-2008, 03:56 AM
The following uses the cursor keys (arrow keys between qwerty and number pad) to move all Alts (but not main) forward, backward, and turning left and right, for as long as the key is pressed down.

Please note on the Alt machines I have my movement keys bounded to SDFE, rather then blizzard's default ASDW. You can change the below to however you like.

I notice you use the %idMain% and %idClone%, so you can just delete 3 of the 4 lines and change the remaining one from %wowidX% to %idClone%.

up::
KeyWait, up, D
#IfWinActive, World of Warcraft
{
ControlSend,, {E Down}, ahk_id %wowid2%
ControlSend,, {E Down}, ahk_id %wowid3%
ControlSend,, {E Down}, ahk_id %wowid4%
ControlSend,, {E Down}, ahk_id %wowid5%
}
Return

up Up::
#IfWinActive, World of Warcraft
{
ControlSend,, {E Up}, ahk_id %wowid2%
ControlSend,, {E Up}, ahk_id %wowid3%
ControlSend,, {E Up}, ahk_id %wowid4%
ControlSend,, {E Up}, ahk_id %wowid5%
}
Return

down::
KeyWait, Down, D
#IfWinActive, World of Warcraft
{
ControlSend,, {D Down}, ahk_id %wowid2%
ControlSend,, {D Down}, ahk_id %wowid3%
ControlSend,, {D Down}, ahk_id %wowid4%
ControlSend,, {D Down}, ahk_id %wowid5%
}
Return

down Up::
#IfWinActive, World of Warcraft
{
ControlSend,, {D Up}, ahk_id %wowid2%
ControlSend,, {D Up}, ahk_id %wowid3%
ControlSend,, {D Up}, ahk_id %wowid4%
ControlSend,, {D Up}, ahk_id %wowid5%
}
Return

left::
KeyWait, left, D
#IfWinActive, World of Warcraft
{
ControlSend,, {S Down}, ahk_id %wowid2%
ControlSend,, {S Down}, ahk_id %wowid3%
ControlSend,, {S Down}, ahk_id %wowid4%
ControlSend,, {S Down}, ahk_id %wowid5%
}
Return

left Up::
#IfWinActive, World of Warcraft
{
ControlSend,, {S Up}, ahk_id %wowid2%
ControlSend,, {S Up}, ahk_id %wowid3%
ControlSend,, {S Up}, ahk_id %wowid4%
ControlSend,, {S Up}, ahk_id %wowid5%
}
Return

right::
KeyWait, right, D
#IfWinActive, World of Warcraft
{
ControlSend,, {F Down}, ahk_id %wowid2%
ControlSend,, {F Down}, ahk_id %wowid3%
ControlSend,, {F Down}, ahk_id %wowid4%
ControlSend,, {F Down}, ahk_id %wowid5%
}
Return

right Up::
#IfWinActive, World of Warcraft
{
ControlSend,, {F Up}, ahk_id %wowid2%
ControlSend,, {F Up}, ahk_id %wowid3%
ControlSend,, {F Up}, ahk_id %wowid4%
ControlSend,, {F Up}, ahk_id %wowid5%
}
Return



Lokked

opt
01-22-2008, 05:38 AM
without having a wowid1 if you change focus to a second screen does this script break? I havnt tried without wowid1 but I would like to know if thats a problem i might be having, wasnt aware it would work this way.

Akoko
01-22-2008, 10:11 PM
up::
KeyWait, up, Up
#IfWinActive, World of Warcraft
{
ControlSend,, {Up Down}, ahk_id %idClone%
}
Return

up Up::
#IfWinActive, World of Warcraft
{
ControlSend,, {Up Up}, ahk_id %idClone%
}
Return

down::
KeyWait, Down, Down
#IfWinActive, World of Warcraft
{
ControlSend,, {Down Down}, ahk_id %idClone%
}
Return

down Up::
#IfWinActive, World of Warcraft
{
ControlSend,, {Down Up}, ahk_id %idClone%
}
Return

left::
KeyWait, left, Left
#IfWinActive, World of Warcraft
{
ControlSend,, {Left Down}, ahk_id %idClone%
}
Return

left Up::
#IfWinActive, World of Warcraft
{
ControlSend,, {Left Up}, ahk_id %idClone%
}
Return

right::
KeyWait, right, Right
#IfWinActive, World of Warcraft
{
ControlSend,, {Right Down}, ahk_id %idClone%
}
Return

right Up::
#IfWinActive, World of Warcraft
{
ControlSend,, {Right Up}, ahk_id %idClone%
}
Return

I'm using this, and the character seems to turn and move backwards properly. However whenever I press forward he runs forward indefinitely and I can't stop him unless i turn off autohotkey.

Lokked
01-23-2008, 04:24 AM
To be honest with you, I couldn't get it to work properly worth a damn using the cursor keys on the alts, the way you have it.

Also, your sintax for Keywait is incorrect, and is probably the root of your problem:

Keywait, up, D

Keywait, down, D

etc...

The D specifies that Keywait is waiting for the XXX key to be pressed DOWN before doing anything else with the following script. It is not simply a reiteration of the desired keypress.

The way you currently have it, your Keywait command is most likely either not functioning at all, or just ignoring the faulty sintax.

I translated a cursor key press on my main PC keyboard into the Alpha movement keys on the alts' windows (ESDF in my case, by default it is WASD for up, left, down and right, respectively) because I couldn't get the Alts' cursor movements to work properly.

Lokked