Hi,
I've created script to search Google in Chrome for the name of the currently selected file/folder. It simply get the file/folder name, removes the path, trims white space, encodes the URI, then opens it in Chrome.
Everything works fine except the last Chrome RunCommand line. Instead of opening a single Chrome Tab with the search, it opens numerous tabs, one even includes the drive letter of the selected file which no longer exists in the variable being passed to the command! Even the RunCommand Clipboard SET works correctly.
Any idea's why it's not passing the final variable correctly? Is this a bug or something I've coded incorrectly? Any help would be greatly appreciated.
Thanks.
function OnClick(clickData) {
// Confirm file/folder selected
var selected_files = clickData.func.sourcetab.selected;
var num_files = selected_files.count;
if (num_files < 1) { return; }
// Get selected file/folder fullpath
var enumFiles = new Enumerator(selected_files);
var currentFile = enumFiles.item();
// Extract filename from fullpath
var query = String(currentFile.name).replace(/^.*[\\\/]/, '')
// Trim white space and encode
query = encodeURI(query.replace(/^\s+|\s+$/gm,''));
// Display query string
var dlg = clickData.func.Dlg;
dlg.message = "Query: " + query;
dlg.Show();
DOpus.Output(query);
DOpus.create.command.RunCommand("Clipboard SET " + query);
DOpus.create.command.RunCommand("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe google.com/search?q=" + query);
return;
}