// This adds a FAYT Quick Key which runs a particular Find Files Preset (g_preset, below), adding whatever you type as the filename pattern. // The intention is to be able to quickly search a pre-defined list of folders, regardless of the current location and without having to open // the Find Files panel. // The searh does not start until you push return. // If you type the configured quick key twice before your search string, the "Any Word" option will be turned on for the search. var g_preset = "MySearchPreset"; var g_nameInternal = "FAYTSearchExample"; var g_defKey = "!"; var g_defBackColor = "#ffc6c6"; var g_defTextColor = "#000000"; function OnInit(initData) { initData.name = "FAYT Search " + g_preset; initData.version = "1.0"; initData.copyright = "(c) 2023 Leo Davidson"; // initData.url = "https://resource.dopus.com/c/buttons-scripts/16"; initData.desc = ""; initData.default_enable = true; initData.min_version = "13.0"; } function OnAddCommands(addCmdData) { var cmd = addCmdData.AddCommand(); cmd.name = g_nameInternal; cmd.method = "OnFAYTSearch"; cmd.desc = ""; cmd.label = g_nameInternal; cmd.template = ""; cmd.hide = true; // Hide from button editor menus cmd.icon = "script"; var fayt = cmd.fayt; fayt.enable = true; fayt.key = g_defKey; fayt.backcolor = g_defBackColor; fayt.textcolor = g_defTextColor; fayt.label = "Search " + g_preset; // fayt.flags - optional Map of flags (flag value -> label) - need to use DOpus.Create.Map fayt.realtime = false; // Call after return, not on every keypresss } function OnFAYTSearch(scriptFAYTData) { if (scriptFAYTData.fayt != g_nameInternal) { DOpus.Output('Unexpected FAYT: "' + scriptFAYTData.fayt + '"'); return; } if (scriptFAYTData.key != "return") { DOpus.Output('Unexpected FAYT: "' + scriptFAYTData.fayt + '" called unexpectedly'); return; } var tab = scriptFAYTData.tab; var query = scriptFAYTData.cmdline; if (query == "" || query == scriptFAYTData.quickKey) { return; } var cmdLine = 'Find PRESET="' + g_preset + '" COLLNAME="Find Results" CLEAR'; // if (query[0] == scriptFAYTData.quickKey) { cmdLine += ' ANYWORD'; query = query.slice(1); } cmdLine += ' NAME="' + query + '"'; var cmd = DOpus.Create.Command(); cmd.SetSourceTab(tab); cmd.RunCommand(cmdLine); // DOpus.Output(cmdLine); }