Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10657

    LTT
    Participant

    This macro gives a quick way to manage your event-driven macros.
    All your event-driven macros are listed in a menu. Clicking in the menu toggles the [Runs at Events] option for that macro.

    #10662

    LTT
    Participant

    I rewrote the macro.
    Now arrays are used to minimize the GetProfileInt/GetProfileString operations (now only once for each entry).

    nRunAtEvents = &h80000000

    ii=0
    Do
    nEventsN = editor.GetProfileInt(eeRegMacros, sCfg, "Events"& ii, -1)
    If nEventsN=-1 Then Exit Do

    If nEventsN><0 Then
    sMacroN = editor.GetProfileString(eeRegMacros, sCfg, "Macro"& ii, "")
    sEventsN = Right("_______"& Hex(nEventsN), 8)
    sN = Right(" "& ii, 7)

    sMenuText = sMacroN &vbTab& sEventsN & sN

    asMacroN = asMacroN &"|"& sMacroN
    anEventsN = anEventsN &" "& nEventsN
    aN = aN &" "& ii
    asMenuText = asMenuText &"|"& sMenuText
    End If

    ii=ii+1
    Loop Until ii>1023

    asMacroN = Split(asMacroN,"|")
    anEventsN = Split(anEventsN)
    aN = Split(aN)
    asMenuText = Split(asMenuText,"|")

    nMenu = UBound(aN)
    sMenuText = "▲Toggle Event-Driven Macros"& vbTab &" Max:"& Right(" "& ii-1, 6)

    Do
    Set menu = CreatePopupMenu
    For ii = 1 To nMenu
    menu.Add asMenuText(ii), ii, eeMenuChecked And anEventsN(ii)<0
    Next
    menu.Add "", 0, eeMenuSeparator
    menu.Add sMenuText, 0, eeMenuGrayed

    ii = menu.Track
    If ii=0 Then Quit

    anEventsN(ii) = anEventsN(ii) Xor nRunAtEvents
    sEventsN = Right("_______"& Hex(anEventsN(ii)), 8)
    sN = Right(" "& aN(ii), 7)
    asMenuText(ii) = asMacroN(ii) &vbTab& sEventsN & sN

    editor.WriteProfileInt eeRegMacros, sCfg, "Events"& aN(ii), anEventsN(ii)
    Loop

    The old code:

    nRunAtEvents = &h80000000

    Do
    Set menu = CreatePopupMenu

    ii=0
    Do
    nEventsN = editor.GetProfileInt(eeRegMacros, sCfg, "Events"& ii, -1)
    If nEventsN=-1 Then Exit Do

    If nEventsN><0 Then
    sMacroN = editor.GetProfileString(eeRegMacros, sCfg, "Macro"& ii, "")
    sMenuText = sMacroN &vbTab& Right("_______"& Hex(nEventsN), 8) & Right(" "& ii, 7)
    menu.Add sMenuText, ii+1, eeMenuChecked And nEventsN<0
    End If

    ii=ii+1
    Loop Until ii>1023
    menu.Add "", 0, eeMenuSeparator
    menu.Add "▲Toggle Event-Driven Macros Max:"& Right(" "& ii-1, 6), 0, eeMenuGrayed

    ii = menu.Track -1
    If ii<0 Then Quit

    nEventsN = editor.GetProfileInt(eeRegMacros, sCfg, "Events"& ii, -1)
    nEventsN = nEventsN Xor nRunAtEvents

    editor.WriteProfileInt eeRegMacros, sCfg, "Events"& ii, nEventsN
    Loop
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Share with friends... Tweet about this on TwitterShare on FacebookShare on Google+Email this to someone