Find-As-You-Type (FAYT) scripts

Find-As-You-Type (FAYT) scripts let you type into the FAYT field and pass it to a script. The script can then (optionally) pass back a list of matches and perform actions, either as you type or when you push return.

This is very open-ended, and the manual doesn't include examples yet, so I've posted some here for you to play with.

These are more likely to be starting points than useful by themselves.

These scripts add entries to the Quick Keys list.

You can edit the keys and colors the same as built-in entries. (Scripts define the initial default key/color but you can change it here.)

Example 1 - FAYT Quick Nav Emulator Platforms

FAYT Quick Nav Emulator Platforms.js.txt (7.0 KB)

(Download and copy to /scripts, or use the new Settings > Install Script command.)

It scans a folder of different retro/emulation platforms and builds a list.

Custom rules are applied so that, for example, a folder named Nintendo Game Boy Color will be matched if I just type GBC:


Saves having to remember how I named all those folders months after the fact!

Example 2 - Custom search via FAYT

A very different example:

FAYT Search Preset.js.txt (2.4 KB)

(Download and copy to /scripts, or use the new Settings > Install Script command.)

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 intent 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 search 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.

The Find Preset defines which folders to search. If I need to add another folder, I just load the preset into the Find panel, update the folder list, and save it out again.

Expected preset name is MySearchPreset, but you can change it at the top of the script.

Example 3 - FAYT with Options

FAYT scripts can define up to 16 boolean flags the user can turn on and off in Preferences:

This is in addition to the usual script config dialogs you could make in the past.

The way these flags work may be unfamiliar (unless you're a C/C++ programmer or similar), so I've made an example script to show how it's done.

This script does nothing except define 16 flags and then tell you which are turned on as you send keypresses to it. It's only useful as an example for writing your own FAYT scripts.

// Called by Directory Opus to initialize the script
function OnInit(initData)
{ = "FAYT Flags Example";
	initData.version = "1.0";
	initData.copyright = "(c) 2023 Leo Davidson";
//	initData.url = "";
	initData.desc = "Script example";
	initData.default_enable = true;
	initData.min_version = "13.0";

// Define these values so our script is easier to read.
var FLAG_OptA = (1<<0);
var FLAG_OptB = (1<<1);
var FLAG_OptC = (1<<2);
var FLAG_OptD = (1<<3);
var FLAG_OptE = (1<<4);
var FLAG_OptF = (1<<5);
var FLAG_OptG = (1<<6);
var FLAG_OptH = (1<<7);
var FLAG_OptI = (1<<8);
var FLAG_OptJ = (1<<9);
var FLAG_OptK = (1<<10);
var FLAG_OptL = (1<<11);
var FLAG_OptM = (1<<12);
var FLAG_OptN = (1<<13);
var FLAG_OptO = (1<<14);
var FLAG_OptP = (1<<15);
// No more allowed currently.

// Called to add commands to Opus
function OnAddCommands(addCmdData)
	var cmd = addCmdData.AddCommand(); = "ExampleFAYTFlagsCommand";
	cmd.method = "OnExampleFAYTFlagsCommand";
	cmd.desc = "";
	cmd.label = "ExampleFAYTFlagsCommand";
	cmd.template = "";
	cmd.hide = true;
	cmd.icon = "script";

	var fayt = cmd.fayt;
	fayt.enable = true;
	fayt.key = "^";
	fayt.backcolor = "#000000";
	fayt.textcolor = "#909090";
	fayt.label = "FAYT Flags Example";
	fayt.flags = DOpus.Create.Map();
	fayt.realtime = true; // Call on every keypresss

	// Add a load of options named "Option A" through "Option P".
	fayt.flags[FLAG_OptA] = "Option A";
	fayt.flags[FLAG_OptB] = "Option B";
	fayt.flags[FLAG_OptC] = "Option C";
	fayt.flags[FLAG_OptD] = "Option D";
	fayt.flags[FLAG_OptE] = "Option E";
	fayt.flags[FLAG_OptF] = "Option F";
	fayt.flags[FLAG_OptG] = "Option G";
	fayt.flags[FLAG_OptH] = "Option H";
	fayt.flags[FLAG_OptI] = "Option I";
	fayt.flags[FLAG_OptJ] = "Option J";
	fayt.flags[FLAG_OptK] = "Option K";
	fayt.flags[FLAG_OptL] = "Option L";
	fayt.flags[FLAG_OptM] = "Option M";
	fayt.flags[FLAG_OptN] = "Option N";
	fayt.flags[FLAG_OptO] = "Option O";
	fayt.flags[FLAG_OptP] = "Option P";

function OnExampleFAYTFlagsCommand(scriptFAYTData)
	if (scriptFAYTData.fayt != "ExampleFAYTFlagsCommand")
		DOpus.Output('Unexpected FAYT: "' + scriptFAYTData.fayt + '"');

	// Report which options are turned on to the script log.
	var letters = "";
	if (scriptFAYTData.flags & FLAG_OptA) letters += "A";
	if (scriptFAYTData.flags & FLAG_OptB) letters += "B";
	if (scriptFAYTData.flags & FLAG_OptC) letters += "C";
	if (scriptFAYTData.flags & FLAG_OptD) letters += "D";
	if (scriptFAYTData.flags & FLAG_OptE) letters += "E";
	if (scriptFAYTData.flags & FLAG_OptF) letters += "F";
	if (scriptFAYTData.flags & FLAG_OptG) letters += "G";
	if (scriptFAYTData.flags & FLAG_OptH) letters += "H";
	if (scriptFAYTData.flags & FLAG_OptI) letters += "I";
	if (scriptFAYTData.flags & FLAG_OptJ) letters += "J";
	if (scriptFAYTData.flags & FLAG_OptK) letters += "K";
	if (scriptFAYTData.flags & FLAG_OptL) letters += "L";
	if (scriptFAYTData.flags & FLAG_OptM) letters += "M";
	if (scriptFAYTData.flags & FLAG_OptN) letters += "N";
	if (scriptFAYTData.flags & FLAG_OptO) letters += "O";
	if (scriptFAYTData.flags & FLAG_OptP) letters += "P";
	DOpus.Output("Flags: " + ((letters == "") ? "<none>" : letters));

Call me stupid but I can't understand how the 1st example works. When I start typing "$" in the FAYT I do get the "Emulator Platforms" Prompt but none of the auto expansion I see in the screenshots, and I do have typical ROM system folder names there.

You need to edit the g_path = ... line near the top of the script to point to the directory all the platforms are under. Forgot to mention that.

1 Like

Awesome! Works well. How about putting a return in when an item is clicked in the list please.

also = "FAYT";

Hmm, I don't know if scripts can do that, but it would definitely make sense for scripts where you'd never type anything after the selection. (FWIW, I usually use the cursor keys, as my hands are on the keyboard already.)

Good idea, we should probably come up with some standard groups for different script types, now they can arrange themselves like that.

@Leo did you get a Steam Deck??

i highly recommend it! i havent used this PC to game in nearly two years. i always like handheld, and the retro emulations graphics look WAY better than... hacking official hardware. LOL