assign a Keyboard Shortcut to a User Button
Re: assign a Keyboard Shortcut to a User Button
can you help by an example?
Re: assign a Keyboard Shortcut to a User Button
Show the full script in code tags
One of my scripts helped you out? Please donate via Paypal
Re: assign a Keyboard Shortcut to a User Button
it's too hard for me.
I stop here
I stop here
Re: assign a Keyboard Shortcut to a User Button
it doesn't matter.
I got hold of the solution.
(with regexreplace)
It works, but it does not take into account the existence of any previously set buttons.
any addition (such as by code addition of CommandButton1 in the toolbar) is welcome
I got hold of the solution.
(with regexreplace)
It works, but it does not take into account the existence of any previously set buttons.
Code: Select all
$newCB = <<<'EOD'
[CustomButtons]
Version=1
Count=1
1=""loader|:ladybug|1|0" load "<xyscripts>.\myscript.xys"; "
[BookmarkButtons]
EOD;
$content = readfile("<xydata>\<xyini>");
$content_new = regexreplace($content, "\[CustomButtons]([\s\S]*?)\[BookmarkButtons]", $newCB);
writefile("<xydata>\<xyini>", $content_new, "o");
#190; //restart
Re: assign a Keyboard Shortcut to a User Button
toolbar()
?One of my scripts helped you out? Please donate via Paypal
Re: assign a Keyboard Shortcut to a User Button
smoothly add a custom button at the end of active toolbar
Code: Select all
$oldtoolbar = toolbar();
toolbar($oldtoolbar."-,ctb1,".);
Re: assign a Keyboard Shortcut to a User Button
Can you at least test such things more extensively before posting them?
You're effectively removing the last entry with it^^
You're effectively removing the last entry with it^^
Code: Select all
$oldToolbar = toolbar();
if (!regexmatches($oldToolbar, "\bctb1\b")) {
toolbar($oldToolbar . ",ctb1");
}
One of my scripts helped you out? Please donate via Paypal
Re: assign a Keyboard Shortcut to a User Button
actually, I initially tested this code to adds to the first position and I mistakenly assumed that it works correctly (surprisingly, it doesn't)
working code //for first position cbt1
my proposals are only at the beginner level, (a few days of juggling the codes), my experience being in VBA and VB.net
in any case, I accept the criticism
working code //for first position cbt1
Code: Select all
$oldtoolbar = toolbar();
toolbar("ctb1,-".$oldtoolbar);
in any case, I accept the criticism
Re: assign a Keyboard Shortcut to a User Button
toolbar("ctb1,-".$oldtoolbar);
Cool, and now you're removing the existing first entry^^
One of my scripts helped you out? Please donate via Paypal
Re: assign a Keyboard Shortcut to a User Button
indeed
your code works flawlessly
Kudos
your code works flawlessly
Kudos
Code: Select all
$oldToolbar = toolbar();
if (!regexmatches($oldToolbar, "\bctb1\b")) {
toolbar($oldToolbar . ",ctb1");
}
Re: assign a Keyboard Shortcut to a User Button
And this is a way how it could be really done...
Code: Select all
$script = <<<'#EOD'
"loader|:ladybug|1|0" load "<xyscripts>\myscript.xys";
#EOD;
$script = replace(trim($script, <crlf>), <crlf>, "¶");
$iniFile = "<xydata>\<xyini>";
$iniContent = readfile($iniFile);
$section = getsectionlist("CustomButtons", $iniFile);
$cntBtns = gettoken(regexmatches($section, "^Count=\d+$"), 2, "=");
$section = regexreplace($section, "^(Version|Count)=\d+(\r?\n|$)");
$btnID = "";
while ($i++ < 64) {
$line = gettoken($section, $i, <crlf>);
// Find an existing but not-populated line or an empty one
if (regexmatches($line, "^\d{1,2}=""""$") || $line == "") {
$btnID = $i;
break;
}
}
end ($btnID == ""), "No free (x of 64) custom button entry found, aborted!";
// Add new / overwrite empty entry and adjust the "Count" if necessary
$newLine = quote($script . <tab 2>);
if ($btnID > $cntBtns) { setkey $btnID, "Count", "CustomButtons", $iniFile, 2; }
setkey $newLine, $btnID, "CustomButtons", $iniFile, 2;
// Restart without saving
#190;
One of my scripts helped you out? Please donate via Paypal
Re: assign a Keyboard Shortcut to a User Button
this is sophisticated far beyond the knowledge of most users (at least mine).
elegant, simple and useful.
elegant, simple and useful.
Re: assign a Keyboard Shortcut to a User Button
again, a problem in which I ask for your help.
after the code successfully writes to the xyplorer.ini file,

whatever I try, after Exit(saving) or savesettings or save configuration, the changes disappear.

can anything be done?
after the code successfully writes to the xyplorer.ini file,

whatever I try, after Exit(saving) or savesettings or save configuration, the changes disappear.

can anything be done?
- Attachments
-
- t2.png (3.75 KiB) Viewed 302 times
-
- t1.png (5.91 KiB) Viewed 302 times
Re: assign a Keyboard Shortcut to a User Button
That's why it uses "Restart without saving" at the end^^
One of my scripts helped you out? Please donate via Paypal
Re: assign a Keyboard Shortcut to a User Button
This trick works great.
Thank you.
Thank you.