In checkbox mode, we click a file, then we can press SPACE key to toggle checked/unchecked status of that file, and this operation will not affect the checked status of other files.
Now I want to use AHK script to do it, some code like: space & c::dopusrt.exe /cmd select checked=toggle
but I cannot find a command like this.
"Select TOCHECKS" will cause other unselected files to be unchecked.
I need help, please...
But I have use SPACE as sequence key, such as:
SPACE,SPACE =========== Select FIRST EXACT MAKEVISIBLE=immediate
SPACE,1 =========== Set SORTBY=name
SPACE,2 =========== Set SORTBY=modified
...
So using AHK to sendinput {space} will trigger these sequence key leading with SPACE.
I hope there is such a command in DO for calling from outside.
Or, is there some message number in DOpus to do the toggle ? So that we can use AHK's "SendMessage" like this: SendMessage 0x0114, 1, 0, ControlGetFocus("A")
I ran into this because I use SPACE for another command so it doesn't work for (un-)checking files in checkbox mode, so I want to use another key to check/uncheck/toggle. Is there really no command to just check/uncheck/toggle the checkbox (in cb-mode) of the currently selected file? If so, would be great if one can be added. Thanks.
Thanks. That's good to know. Ideally, I'd like to use a custom key, e.g. SHIFT-S, which I think requires DOpus to offer a command for that and I'm surprised it does not seem to exist.
I do use SHIFT + letter without problems (e.g. SHIFT-C to copy). When focus is in an input field (e.g, when renaming a file), DOpus does not trigger the shortcut, but the capital letter is typed as expected.
Caveat
This can be a downside as well: I use SHIFT-R to do inline-rename, but when activated, I can't just hit SHIFT-R again to cycle the inline-rename selections (stem, ext, full etc.), as it'll type captial R instead, but that's fine of course.
This does invert all checkboxes, i.e., check previously unchecked boxes and vice versa - not what I'm looking for. Instead, I want to toggle the currently selected file(s) only.
You can do it via scripting
Try using this User Command: ToggleSelection (you need to import it via the Customize dialog...). ToggleSelection.ouc (3.7 KB)
function OnClick(clickData) {
// --------------------------------------------------------
var cmd = clickData.func.command;
cmd.deselect = false; // Prevent automatic deselection
// --------------------------------------------------------
var tab = clickData.func.sourcetab;
var checkbox_mode = tab.stats.checkbox_mode;
//DOpus.Output('checkbox_mode=' + checkbox_mode);
var ch_selcount = tab.selstats.selitems; //items checked
var selcount = tab.stats.selitems; //items selected
//DOpus.Output('ch_selcount=' + ch_selcount + '; selcount=' + selcount);
//No checkbox mode, just normal selection
//or no items selected, we deal with checked items only
if (!checkbox_mode || !selcount ) {
cmd.RunCommand('Select ALL');
cmd.RunCommand('Select DESELECT FROMSCRIPT')
}
//items selected, check one by one 'cause we can't easily tell
//which is selected but not checked
else {
var items = tab.all;
var check_items = DOpus.NewVector();
var uncheck_items = DOpus.NewVector();
//DOpus.Output('items=' + items.count);
var counter = 0; //counter for selected
for (var i = items.count - 1; i >= 0; i--, counter++) {
//item is not selected, omitted
if (!items(i).selected) continue;
//so we don't iterate the whole batch
if (counter === selcount) break;
//DOpus.Output('item=' + items(i));
if (items(i).checked) uncheck_items.push_back(items(i));
else check_items.push_back(items(i));
}
if (!uncheck_items.empty) {
cmd.SetFiles(uncheck_items);
DOpus.Output('Deselecting ' + uncheck_items.count + ' items...');
cmd.RunCommand('Select FROMSCRIPT DESELECT');
}
if (!check_items.empty) {
cmd.SetFiles(check_items);
DOpus.Output('Selecting ' + check_items.count + ' items...');
cmd.RunCommand('Select FROMSCRIPT');
}
}
}
Note : It does not work on shell path types.
Note 2: I've corrected the case for non-checkbox mode. So if you already downloaded it, please do it again (sorry about that).
Oh, I did not know about that internal hotkey.
But I'm not sure what that Select command is actually trying to do—the result is pretty far from what I expected.
Anyway, you can get full support everywhere just by using Evaluator and a regular function type:
It works in all contexts, for both checkbox mode and normal selection.
On the other hand, the simplified script version looks better to me—maybe because it can differentiate between regular selections and checkbox selections.
function OnClick(clickData) {
// --------------------------------------------------------
var cmd = clickData.func.command;
cmd.deselect = false; // Prevent automatic deselection
// --------------------------------------------------------
var tab = clickData.func.sourcetab;
var checkbox_mode = tab.stats.checkbox_mode;
//DOpus.Output('checkbox_mode=' + checkbox_mode);
var selcount = tab.stats.selitems; //items selected
//DOpus.Output('selcount=' + selcount);
//No checkbox mode, just normal selection
//or no items selected, we deal with checked items only
cmd.ClearFiles();
if (!checkbox_mode || !selcount ) {
cmd.RunCommand('Select INVERT');
}
else {
DOpus.SendKey('ctrl+alt+space');
}
}
The sendkey solution is interesting and should work, but it is and feels like a workaround.
Generally, as a user I'd expect that all shortkeys are listed under Settings / Customize Toolbars and Keys... / Keys and thus, have a command that can be used with any key. However, SPACE to check/uncheck files in checkbox mode is not listed there (as no command exists).
Maybe this can be fixed in a future version. Thanks.
Space to select things in a list is a standard part of Windows, and it'd be like including explicit hotkeys to move the cursor around, or for each letter you can type on the keyboard.
It also does totally different things depending on which type of control has focus, unlike most hotkeys where it only matters which window has focus.
Workaround or not, you can create a User Command (or something similar) using the script above and assign whatever hotkey you want—spacebar, etc.
Isn’t that what really matters in the end? I don’t really see the difference between having a built-in option and setting one up yourself (with your specific needs) if you still get the result you’re after.