Thanks,
Ken
Code: Select all
Name: userbutton
Action: Emulates a click on a user customizable toolbar button.
Syntax: userbutton number, [action=1]
number: [required] Number of the user button.
You can retrieve the existing keys using the SC toolbar.
action: [optional]
0 = do nothing
1 = left-click [default]
2 = right-click
128 = edit user button dialog
Example:
userbutton 14, 128; //opens the Edit User Button dialog for ctb14.Code: Select all
"_Initialize"
// Edit this value to skip the warning dialog about saving your configuration.
// 0 = Never Save
// 1 = Always Save
Global $G_SAVE_PROMPT_RESPONSE = -1;
// STOP EDITING
Global $G_INITIALIZED = True;
"Edit User Button||1 : editUserButton"
// Ensure things are initialized.
Global $G_INITIALIZED;
if (! $G_INITIALIZED) {
Sub '_Initialize';
}
// Determine if the user minds us saving their configuration.
Global $G_SAVE_PROMPT_RESPONSE;
if ($G_SAVE_PROMPT_RESPONSE == 1) {
$response = 1;
} elseif ($G_SAVE_PROMPT_RESPONSE == 0) {
$response = 0;
} else {
// Prompt to before saving...
$response = Confirm(<<<#CONFIRM_MSG
To give you an accurate listing of your customized user buttons this script would like to save XYplorer's main configuration file ('<xyini>').
To save and then use the current and correct listing please click 'OK'.
Otherwise the possibly stale and incorrect listing will be used.
#CONFIRM_MSG);
}
if ($response == 1) {
#193; // File | Settings Special | Save Configuration
}
$SECTION = 'CustomButtons';
// Check the serialization version before continuing.
$version = GetKey('Version', $SECTION);
if ($version != 1) {
$response = Confirm(<<<#CONFIRM_MSG
This script was written based on version 1 of the custom user buttons data format.
Your configuration appears to be using version $version.
While it may be possible that this script still works, it might not be able to handle this format.
Please check for an updated version of this script before proceeding!
If you'd like to try continuing click 'OK'.
#CONFIRM_MSG,, 2);
End $response == 0;
}
// Get the number of supported CTBs.
$count = GetKey('Count', $SECTION);
// Create the format style.
$fmt = RegexReplace($count, '.', '0');
// Stores the final script.
// Doing this as a script allows us to attepmt to display the icons.
$ctbScript = '';
$i = 1;
while ($i <= $count) {
$ctb = GetKey($i, $SECTION);
if ($ctb UnLike '') {
// Extract the 'name|icon|?|?' portion.
$ctb = RegexReplace($ctb, '^"([^"]*)".*$', '$1');
// Get and sanitize the name.
$name = GetToken($ctb, 1, '|');
$name = Replace($name, '&', '&&');
$name = Replace($name, ' : ', ' :: ');
// Get the icon.
$icon = GetToken($ctb, 2, '|');
// If no icon is listed it might be an Open-With button.
if ($icon == '' && (Exists($name) + 0) > 0) {
$icon = $name;
}
// Attempt to redirect relative icon paths.
if ($icon Like '.*') {
$icon = "<xypath>\$icon";
}
// Format the index so we have decent alignment and access keys.
$key = Format($i, $fmt);
$key = RegexReplace($key, '(.)$', '&$1');
// Build the script.
// NOTE: userbutton() is an undocumented SC similar to button().
$ctbScript = $ctbScript . <<<#CTB_SCRIPT
"CTB $key: $name|$icon" userbutton($i, 128);
#CTB_SCRIPT;
}
$i++;
}
// Run the script.
Load $ctbScript, '*', 's';Code: Select all
$icon = "<xypath>\$icon"; } //...existing lines in script
if (!exists("$icon") && ($icon Like '*.ico')) { //check the icon_name by itself doesn't exist (since there's no path) and check that it's an "ico" file not a internal icon
$icon = "<xyicons>\$icon";
}
Right... I see that bug now.klownboy wrote:I notice it happens only on those CTBs where the icon, as listed in the edit CTB dialog, is the icon name by itself with no path and without using <xyicons>.