1

I really need your help. I trying to program an AutoHotkey script but I not quite getting a working solution.

My current AutoHotkey script is:

#IfWinActive Guild Wars 2
shift & 1::
Send, 1
sleep 500
Send, y
return

So when I’m in Guild Wars and hold Shift and press 1, it will do my macro. So I can spam 1 (while holding Shift) and it will do it again and again. The problem is, I always need to hold Shift. My desire is, when I press Shift ONE time, it will do the macro always when I spam 1. But it should do the macro only till I play another key (Ctrl, F1,, F2). So if I play another key, it should be doing the normally 1 (so no macro).

  • With pressing Shift one time and spamming 1 = my macro
  • After pressing a key like Ctrl, F1,, F2 it should do the normal 1 (no macro).
0

This will do the trick:

#ifWinActive Guild Wars 2

shift::  ; Shift to toggle auto-spammer
    hotkey, ifWinActive, Guild Wars 2
    hotkey, $1, shift_1, on
    loop {
        input, keystroke, l1 v, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
        if keystroke not contains 1
            break
    }
    hotkey, $1, off
return

shift_1:
    send 1
    sleep 500
    send y
return

Alternatively, if you want the Shift toggle to modify X hotkeys from 1-9:

#ifWinActive Guild Wars 2

X = 9  ; Set this to the number of keys you want to be auto-spammable

loop %X% {  ; Create hotkeys 0-X
    hotkey, ifWinActive, Guild Wars 2
    hotkey, $%a_index%, autoSpammer
}

shift::  ; Shift to toggle auto-spammer
    autoSpam = on
    loop {
        input, keystroke, l1 v, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
        if regExMatch(keystroke, "[^0-9]")
            break 
    }
    autoSpam = off
return

autoSpammer:
    thisHotkey := regExReplace(a_thisHotkey, "[^0-9]")
    if autoSpam = on
    {
        sendInput %thisHotkey%
        sleep 500
        sendInput y
    }
    else
        send %thisHotkey%
return

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.