Difference between revisions of "Lua:shortCutToText"
Jump to navigation
Jump to search
m (Minor edit. Added Version Notice Template.) |
(Major overhaul of the post.) |
||
| Line 1: | Line 1: | ||
{{VersionNotice|6.4+}} | {{VersionNotice|6.4+}} | ||
| − | {{ | + | [[Category:Lua]] |
| − | < | + | {{CodeBox|'''function''' shortCutToText(''shortcut'') ''':''' string}} |
| − | print(shortCutToText( | + | |
| − | + | Returns the textual representation of a shortcut integer. | |
| − | + | ||
| − | + | This function is available in Cheat Engine 6.4 and later. | |
| − | print(shortCutToText( | + | |
| − | </ | + | ===Function Parameters=== |
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|Parameter | ||
| + | !align="left"|Type | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |shortcut | ||
| + | |Integer | ||
| + | |The shortcut value to convert to text. | ||
| + | |} | ||
| + | |||
| + | ===Returns=== | ||
| + | String — The textual representation of the given shortcut value. | ||
| + | |||
| + | ===Description=== | ||
| + | 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=== | ||
| + | |||
| + | ====Convert a shortcut integer to text==== | ||
| + | <syntaxhighlight lang="lua" line highlight="2"> | ||
| + | local shortcut = textToShortCut("Ctrl+Alt+F1") | ||
| + | local text = shortCutToText(shortcut) | ||
| + | |||
| + | print(text) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Read a menu item shortcut==== | ||
| + | <syntaxhighlight lang="lua" line highlight="4"> | ||
| + | local menuItem = createMenuItem(MainForm) | ||
| + | |||
| + | menuItem.ShortCut = textToShortCut("Ctrl+Shift+F5") | ||
| + | local shortcutText = shortCutToText(menuItem.ShortCut) | ||
| + | |||
| + | print(shortcutText) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Convert multiple shortcut values==== | ||
| + | <syntaxhighlight lang="lua" line highlight="8"> | ||
| + | local shortcuts = { | ||
| + | textToShortCut("Ctrl+F1"), | ||
| + | textToShortCut("Ctrl+F2"), | ||
| + | textToShortCut("Ctrl+F3") | ||
| + | } | ||
| + | |||
| + | for i, shortcut in ipairs(shortcuts) do | ||
| + | local text = shortCutToText(shortcut) | ||
| + | |||
| + | print(text) | ||
| + | end | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Store a shortcut as text==== | ||
| + | <syntaxhighlight lang="lua" line highlight="5"> | ||
| + | local menuItem = createMenuItem(MainForm) | ||
| + | |||
| + | menuItem.ShortCut = textToShortCut("Ctrl+Alt+M") | ||
| + | |||
| + | local storedShortcut = shortCutToText(menuItem.ShortCut) | ||
| + | |||
| + | print("Stored shortcut: " .. storedShortcut) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Round-trip shortcut conversion==== | ||
| + | <syntaxhighlight lang="lua" line highlight="4"> | ||
| + | local originalText = "Ctrl+Shift+F9" | ||
| + | local shortcut = textToShortCut(originalText) | ||
| + | |||
| + | local convertedText = shortCutToText(shortcut) | ||
| + | |||
| + | print(originalText) | ||
| + | print(convertedText) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Display a shortcut in a message==== | ||
| + | <syntaxhighlight lang="lua" line highlight="4"> | ||
| + | local shortcut = textToShortCut("Alt+F4") | ||
| + | local message = "Current shortcut: " | ||
| + | |||
| + | message = message .. shortCutToText(shortcut) | ||
| + | |||
| + | showMessage(message) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | {{LuaSeeAlso}} | ||
Latest revision as of 20:05, 25 June 2026
Returns the textual representation of a shortcut integer.
This function is available in Cheat Engine 6.4 and later.
Contents
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)
[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)