assign a Keyboard Shortcut to a User Button
Posted: 10 Sep 2020 00:40
I have created a User Button executing a custom script; I would like to assign a Keyboard Shortcut to this User Button. Is this possible? Thanks
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
Code: Select all
01. Either:
Menu - Tools - Customize Toolbar... (hold CTRL when you click on the "Customize Toolbar..." entry!)
or
Press and hold the CTRL key (for all the following clicks!) - Right click any button on the toolbar and choose "Customize Toolbar..." from the context menu
Look at the identifier inside the square brackets at the end of a button you want to assign the keyboard shortcut to
E.g. "[ctb1]", "[undo]", ...
02. Menu - User - Manage Commands...
Category:
Run Script
Commands:
Button "New..."
Context menu: Add New Command
Command Properties:
Action : Run specified script.
Caption: E.g.: Execute user button 1
Script : button "ctb1";
Notes: You can access every button by using its identifier regardless if it's on the toolbar or not!
Look up the script command "button" in the help file to see all of its possible mouse click types
Button "Assign Keyboard Shortcut..."
Choose a keyboard shortcut to be able to emulate the button click here...
Button "OK" (to close the "Manage User-Defined Commands" window)
Hi highend, I know this thread is over a year old now but I tried this on several custom buttons and it doesn't work for me. I tried it on a standard and it worked for that. I would welcome any suggestions you might have. TIAhighend wrote: ↑10 Sep 2020 05:26Code: Select all
01. Either: Menu - Tools - Customize Toolbar... (hold CTRL when you click on the "Customize Toolbar..." entry!) or Press and hold the CTRL key (for all the following clicks!) - Right click any button on the toolbar and choose "Customize Toolbar..." from the context menu Look at the identifier inside the square brackets at the end of a button you want to assign the keyboard shortcut to E.g. "[ctb1]", "[undo]", ... 02. Menu - User - Manage Commands... Category: Run Script Commands: Button "New..." Context menu: Add New Command Command Properties: Action : Run specified script. Caption: E.g.: Execute user button 1 Script : button "ctb1"; Notes: You can access every button by using its identifier regardless if it's on the toolbar or not! Look up the script command "button" in the help file to see all of its possible mouse click types Button "Assign Keyboard Shortcut..." Choose a keyboard shortcut to be able to emulate the button click here... Button "OK" (to close the "Manage User-Defined Commands" window)
Sorry, highend, but it seems I have wasted your time. Last night I tried it on 4 different buttons and it didn't work but this morning I've created the UDCs again and they're working just fine
Code: Select all
userbutton 999, 132, "Test", "::e 'Left Click!'", "::e 'Right Click!';";userbutton emulates a click on a custom toolbar button^^[CustomButtons] section in the .ini file, do the changes there and then quit & restart XY without saving settings...Code: Select all
[CustomButtons]
Version=1
Count=1
1=""new script launcher|:up|0|0" $allScripts = listfolder(<xyscripts>, "*.xys"); ¶ $count_xys = gettoken($allScripts, "count", ",");¶ ¶ if ($count_xys) {¶ $allScripts = replace(report("{basename} - ({comment})|",$allScripts)," - ()");¶ $selectedscript = inputselect("Select one script to execute",$allScripts,,32);¶ If ($selectedscript>"") ¶ {¶ $selectedscript = regexreplace($selectedscript, "(.+) -.+", "$1");¶ load $selectedscript; ¶ }¶ } else {¶ $mycom = "This is a autocreated script";¶ writefile("<xyscripts>\hello.xys", " msg ""Your scripts folder not contain any script (*.xys)!<br>Warning:$mycom!<br>Script location is <xyscripts>"",48,,""$mycom"";");¶ tag $mycom, "<xyscripts>\hello.xys", 2;¶ load "<xyscripts>\hello.xys" }¶ } "
readfile()[CustomButtons] section content getsectionlist()^<number>=""$ (e.g. via regex) => A non-used one