HenryEx

CE Hotkeys Manager

Aug 18th, 2026
4,660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.36 KB | Source Code | 0 0
  1. --[===[
  2. Author: YoucefHam
  3. Discord:    YoucefHam#5634
  4.  
  5. ADD to Edit Menu "Hotkey Manager"
  6.     "Get Table Hotkeys", => This will show you a list with all the Memory records that have Hotkeys.
  7.     "Remove All Hotkeys", => This will remove all the Hotkeys from All the Memory records.
  8. ]===]
  9.  
  10. local HotkeysManagerName = 'miHotkeysManager'
  11. local HotkeysManagerCaption = '&Hotkey Manager'
  12. local miHotkeysManager
  13.  
  14. -- Get Table Hotkeys
  15. function GetHotkeys()
  16.     local mr = getAddressList()
  17.     if mr.Count > 0 then
  18.         local _GetHotKeys = ""
  19.         local _KeyCode = {[1]="LBUTTON",[2]="RBUTTON",[3]="CANCEL",[4]="MBUTTON",[5]="XBUTTON1",[6]="XBUTTON2",[8]="Backspace",[9]="TAB",[12]="Clear",[13]="Enter",[16]="SHIFT",[17]="CONTROL",[18]="ALT",[19]="PAUSE",[20]="CAPSLOCK",[27]="ESCAPE",[32]="SPACE",[33]="PGUP",[34]="PGDOWN",[35]="NumpadEnd",[36]="HOME",[37]="LEFT_ARROW",[38]="UP_ARROW",[39]="RIGHT_ARROW",[40]="DOWN_ARROW",[41]="SELECT",[42]="PrintScreen",[43]="EXECUTE",[44]="SNAPSHOT",[45]="INSERT",[46]="DELETE",[47]="HELP",[48]="0",[49]="1",[50]="2",[51]="3",[52]="4",[53]="5",[54]="6",[55]="7",[56]="8",[57]="9",[65]="A",[66]="B",[67]="C",[68]="D",[69]="E",[70]="F",[71]="G",[72]="H",[73]="I",[74]="J",[75]="K",[76]="L",[77]="M",[78]="N",[79]="O",[80]="P",[81]="Q",[82]="R",[83]="S",[84]="T",[85]="U",[86]="V",[87]="W",[88]="X",[89]="Y",[90]="Z",[91]="LWIN",[92]="RWIN",[93]="AppsKey",[95]="Sleep",[96]="NUMPAD0",[97]="NUMPAD1",[98]="NUMPAD2",[99]="NUMPAD3",[100]="NUMPAD4",[101]="NUMPAD5",[102]="NUMPAD6",[103]="NUMPAD7",[104]="NUMPAD8",[105]="NUMPAD9",[106]="NUMPAD_MULTIPLY",[107]="NUMPAD_ADD",[108]="SEPARATOR",[109]="NUMPAD_SUBTRACT",[110]="NUMPAD_DECIMAL",[111]="NUMPAD_DIVIDE",[112]="F1",[113]="F2",[114]="F3",[115]="F4",[116]="F5",[117]="F6",[118]="F7",[119]="F8",[120]="F9",[121]="F10",[122]="F11",[123]="F12",[124]="F13",[125]="F14",[126]="F15",[127]="F16",[128]="F17",[129]="F18",[130]="F19",[131]="F20",[132]="F21",[133]="F22",[134]="F23",[135]="F24",[144]="NUMLOCK",[145]="SCROLLLOCK",[156]="WheelLeft",[157]="WheelRight",[158]="WheelDown",[159]="WheelUp",[160]="LSHIFT",[161]="RSHIFT",[162]="LCONTROL",[163]="RCONTROL",[164]="LALT",[165]="RALT",[166]="Browser_Back",[167]="Browser_Forward",[168]="Browser_Refresh",[169]="Browser_Stop",[170]="Browser_Search",[171]="Browser_Favorites",[172]="Browser_Home",[173]="Volume_Mute",[174]="Volume_Down",[175]="Volume_Up",[176]="Media_Next",[177]="Media_Prev",[178]="Media_Stop",[179]="Media_Play_Pause",[180]="Launch_Mail",[181]="Launch_Media",[182]="Launch_App1",[183]="Launch_App2",[186]=";",[187]="=",[188]=",",[189]="-",[190]=".",[191]="/",[192]="`"}
  20.         for _Record = 0 , mr.Count - 1 do -- Read all records in the Table
  21.             local _keyCount = mr[_Record].HotkeyCount -- Get How many keys
  22.             if _keyCount > 0 then
  23.                 local _HotKeys = ""
  24.                 for _Hotkey = 0, _keyCount - 1 do -- Read All key list
  25.                     local _Keys = ""
  26.                     local _KeyData = mr[_Record].Hotkey[_Hotkey].Keys -- Get How many unique keys
  27.                     for _Modifiers = 1, #_KeyData  do
  28.                         if _KeyCode[mr[_Record].Hotkey[_Hotkey].Keys[_Modifiers]] ~= nil then
  29.                             if _Modifiers == 1  then _Keys = _KeyCode[mr[_Record].Hotkey[_Hotkey].Keys[_Modifiers]]
  30.                                                 else _Keys = _Keys.." + ".._KeyCode[mr[_Record].Hotkey[_Hotkey].Keys[_Modifiers]]
  31.                             end
  32.                         else
  33.                             if _Modifiers == 1  then _Keys = "VK0"..mr[_Record].Hotkey[_Hotkey].Keys[_Modifiers]
  34.                                                 else _Keys = _Keys.." + ".."VK0"..mr[_Record].Hotkey[_Hotkey].Keys[_Modifiers]
  35.                             end
  36.                         end
  37.                     end
  38.                     if _Hotkey == 0 then _HotKeys = _Keys
  39.                                     else _HotKeys = _HotKeys.."; ".._Keys
  40.                     end
  41.                 end
  42.                 _GetHotKeys = _GetHotKeys.."Rec: "..mr[_Record].getDescription().."\n      HotKeys:  ".._HotKeys.."\n"
  43.             end
  44.         end
  45.         if #_GetHotKeys > 1 then showMessage(_GetHotKeys)
  46.                             else showMessage("No HotKeys Found!!!")
  47.         end
  48.     end
  49. end
  50.  
  51. -- Remove All Hotkeys
  52. function removeAllHotkeys()
  53.     local mr = getAddressList()
  54.     if mr.Count > 0 then
  55.         local _isRemovedAny = false
  56.         for _Record = 0 , mr.Count - 1 do -- Read all records in the Table
  57.             local _keyCount = mr[_Record].HotkeyCount -- Get How many keys
  58.             if _keyCount > 0 then
  59.                 _isRemovedAny = true
  60.                 for __i = _keyCount - 1, 0, -1 do -- Destroy all HotKeys in the record
  61.                     mr[_Record].Hotkey[__i].Destroy()
  62.                 end
  63.             end
  64.         end
  65.         if _isRemovedAny    then showMessage("All Hotkeys Removed")
  66.                             else showMessage("No HotKeys Found!!!") end
  67.     end
  68. end
  69.  
  70. -- Add menus
  71. local function addMenuItem(MenuItem, caption, onClick)
  72.     local newItem = createMenuItem(MenuItem)
  73.     MenuItem.add(newItem)
  74.     newItem.Caption = caption
  75.     newItem.OnClick = onClick
  76.     return newItem
  77. end
  78.  
  79. -- create Hotkey Manager
  80. local function addHotkeysManagerMenu()
  81.     if not getMainForm().ComponentByName['Edit3'].Visible then getMainForm().ComponentByName['Edit3'].Visible = true end
  82.     local parent = getMainForm().ComponentByName['Edit3'] or getMainForm().Menu.Items
  83.     local separatorMenu = createMenuItem(parent)
  84.     separatorMenu.Caption = '-'
  85.     parent.add(separatorMenu)
  86.    
  87.     local miHotkeysManager = createMenuItem(parent)
  88.     miHotkeysManager.Name = HotkeysManagerName
  89.     miHotkeysManager.Caption = HotkeysManagerCaption
  90.     parent.add(miHotkeysManager)
  91.    
  92.     addMenuItem(miHotkeysManager,translate('&Get Table Hotkeys'), GetHotkeys)
  93.     addMenuItem(miHotkeysManager,'-')
  94.     addMenuItem(miHotkeysManager,translate('&Remove All Hotkeys'), removeAllHotkeys)
  95. end
  96.  
  97. addHotkeysManagerMenu()
Advertisement
Add Comment
Please, Sign In to add comment