Search code examples
macrosautohotkey

AutoHotkey On Screen Text


Trying to figure out how to have an onscreen text appear saying something like "Macro On" when the macro is enabled. Any ideas?

macro_on := 0

XButton2::
    macro_on := !macro_on
    if (macro_on)
        SetTimer, DoLoop, -0
    return


DoLoop:
    Loop {
        if (!macro_on)
            break
        Send {e down}   ; Hold key
        Sleep 332       ; Wait
        Send {e up} ; Release key
        Sleep 332       ; Wait
    }
    return

Tried just copy and pasting stuff I saw online but I got no clue what I'm doing and didn't work


Solution

  • #Requires AutoHotkey v1.1
    
    CoordMode, ToolTip, Screen
    
    macro_on := 0
    
    XButton2::
        macro_on := !macro_on
        if (macro_on)
        {
            ToolTip, Macro On, 0, 0, 1 ; Display ToolTip Nr1 on the top left corner of the screen
            SetTimer, DoLoop, -0
        }
        return
    
    
    DoLoop:
        Loop {
            if (!macro_on)
            {
                ToolTip,,,, 1  ; Remove that ToolTip
                break
            }
            Send {e down}   ; Hold key
            Sleep 332       ; Wait
            Send {e up} ; Release key
            Sleep 332       ; Wait
        }
        return
    

    See ToolTip and CoordMode.