Lua:shortCutToText

From Cheat Engine
Jump to navigation Jump to search

⚠️ Version Notice

This function requires Cheat Engine 6.4+.

<> Lua API Reference

function shortCutToText(shortcut) : string

Returns the textual representation of a shortcut integer.

This function is available in Cheat Engine 6.4 and later.

Function Parameters[edit]

Parameter Type Description
shortcut Integer The shortcut value to convert to text.

Returns[edit]

String — The textual representation of the given shortcut value.

Description[edit]

shortCutToText converts a shortcut integer into a human-readable shortcut string.

This is useful when reading shortcut values from menu items, actions, or other GUI objects and displaying or storing them as text.

Examples[edit]

Convert a shortcut integer to text[edit]

1 local shortcut = textToShortCut("Ctrl+Alt+F1")
2 local text = shortCutToText(shortcut)
3 
4 print(text)

Read a menu item shortcut[edit]

1 local menuItem = createMenuItem(MainForm)
2 
3 menuItem.ShortCut = textToShortCut("Ctrl+Shift+F5")
4 local shortcutText = shortCutToText(menuItem.ShortCut)
5 
6 print(shortcutText)

Convert multiple shortcut values[edit]

 1 local shortcuts = {
 2   textToShortCut("Ctrl+F1"),
 3   textToShortCut("Ctrl+F2"),
 4   textToShortCut("Ctrl+F3")
 5 }
 6 
 7 for i, shortcut in ipairs(shortcuts) do
 8   local text = shortCutToText(shortcut)
 9 
10   print(text)
11 end

Store a shortcut as text[edit]

1 local menuItem = createMenuItem(MainForm)
2 
3 menuItem.ShortCut = textToShortCut("Ctrl+Alt+M")
4 
5 local storedShortcut = shortCutToText(menuItem.ShortCut)
6 
7 print("Stored shortcut: " .. storedShortcut)

Round-trip shortcut conversion[edit]

1 local originalText = "Ctrl+Shift+F9"
2 local shortcut = textToShortCut(originalText)
3 
4 local convertedText = shortCutToText(shortcut)
5 
6 print(originalText)
7 print(convertedText)

Display a shortcut in a message[edit]

1 local shortcut = textToShortCut("Alt+F4")
2 local message = "Current shortcut: "
3 
4 message = message .. shortCutToText(shortcut)
5 
6 showMessage(message)

Main Pages

Core Lua documentation entry points

Lua
Script Engine