Search code examples
stringpaintautohotkeyphotoshopprintscreen

AutoHotKey - Listen to string after PrintScreen button is pressed?


I want my script to listen to the string I will enter after the PrintScreen button is pressed. For example, if I press the PrintScreen button and type "paint" afterwards, it should open MSPaint. If I however type "photoshop", it should open Photoshop.. Is this possible?

Here is my attempt, a completely failure (I'm new to AHK by the way..)

~PrintScreen::paint::
    Run, MSPaint
    WinWaitActive, Untitled - Paint
    Send, ^v
return

~PrintScreen::photoshop::
    Run, Photoshop
    WinWaitActive, Adobe Photoshop CS6
    Send, ^v
return

Solution

  • well you are right, printScreen::paint:: is no valid AutoHotkey code.

    Make use of Ahk's Input command instead - it was made to listen for strings / characters:

    ~PrintScreen::
        input, outputString, i, {enter}.{esc}{tab}
        if outputstring = paint
        {
            Run, MSPaint
            WinWaitActive, Untitled - Paint
            Send, ^v
        } else if outputstring = photoshop
        {
            Run, Photoshop
            WinWaitActive, Adobe Photoshop CS6
            Send, ^v
        }
    return
    

    I however encourage you to have a look at input's options yourself to adjust it to your needs. Good luck