1

In Photoshop I have 3 actions for my hotkey "g":

  1. If I hold "space + g", zoom in and enable tool (zoom);

  2. If tap "g", enable tool (smudge);

AND...

  1. If I tap "g" 2 times, open menu (Ctrl+Alt+F12). If tap 4 times, open another menu (Shift+Alt+F1).

NOTE: Need to be "~g" to work.

MY QUESTION:

How to group code 1 and 2 together with the third?

This way the third code don't works:

; CODES 1 AND 2 — WORKS:

g::
if !GetKeyState("Space","U")
{
    Send, g ; CODE 2
    return
} else {
    Send, ^{Numpad0} ; CODE 1
    Sleep 10
    Send, z
    return
}


; CODES 3 — WORKS:

~g::
    if (A_PriorHotkey <> "~g" or A_TimeSincePriorHotkey > 400)
    {
        KeyWait, g
        return
    }
    Send, % ["^!{F12}","+!{F1}"][(count >= 2 || !count) ? count := 1 : ++count]
return

; --------------------------------------------------
; Trying to put together...
; CODES 1 AND 2 + CODE 3 — (THIRD DON'T WORKS):

g::
    if !GetKeyState("Space","U")
    {
        Send, g
        return
    } else {
        Send, ^{Numpad0}
        Sleep 10
        Send, z
        return
    }
    if (A_PriorHotkey <> "~g" or A_TimeSincePriorHotkey > 400)
    {
        KeyWait, g
        return
    }
    Send, % ["^!{F12}","+!{F1}"][(count >= 2 || !count) ? count := 1 : ++count]
return
0

I do not know if the syntax of code below is correct because I'm newbie on AHK, but at least it works.

That works on Photoshop CC2015:

~g::
{
    Sleep, 150
    GetKeyState, state, g, U
    IfEqual, state, U
    {
        if (A_PriorHotkey <> "~g" or A_TimeSincePriorHotkey > 400)
        {
            KeyWait, g
            return
        }
        Send, % ["^!{F12}","+!{F1}"][(count >= 2 || !count) ? count := 1 : ++count]
        return
    }
    if !GetKeyState("Space","U")
    {
        Send, g
        return
    }
    else
    {
        Send, ^{Numpad0}
        Sleep 10
        Send, z
        return
    }
}
| improve this answer | |

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.