'Projects - LnzScript'

My Launchorz project makes it easy to automate repetitive tasks in Windows. Here are some of the scripts I've found to be the most useful. (Note that they are intended for Windows 7 and might not be compatible with something earlier.)

Open command-line to the current Explorer directory

include('getExplorerDirectory.js');
Window.activate( {'class':'CabinetWClass'});
// activate the most-recently-used Explorer window.
Time.sleep(100);
var strDir = getCurrentExplorerDirectory();
if (strDir)
  Process.openFile('cmd.exe', strDir);

You can download getExplorerDirectory.js.

Creating an index of all files in a directory

This script creates a text file index of all files in a directory, including subdirectories. The output is formatted nicely by indentation level. It uses the path of the currently open Explorer window and creates tree_files.txt.
include('getExplorerDirectory.js');

Window.activate( {'class':'CabinetWClass'})
Time.sleep(100);
var strDir = getCurrentExplorerDirectory();
if (strDir)
  Process.open('cmd.exe /c tree /f /a > tree_files.txt', strDir);

Expand repeated code

When working on a quick project, or writing in a language like Verilog, sometimes the same line of code is repeated a few times, with a different index. The following script takes a code fragment like
a[#] = b[#] & c[#];
and expands it to
a[0] = b[0] & c[0];
a[1] = b[1] & c[1];
a[2] = b[2] & c[2];
...
(This isn't a useful example but it depicts what the script does). All it does is replace the '#' character with a number.
include('<std>');
var sClipboard = Clipboard.getText();
if (sClipboard  && sClipboard.contains('#'))
{  
  var sRep = Dialog.input('Replace', 'How many repetitions? n=0 to ?', '3');
  if (isNumber(sRep))
  {    
    var sResult = '';
    for (var i=0; i<sRep; i++)
      sResult += sClipboard.replace(/#/g, i) + '\r\n';
    Clipboard.setText(sResult);
  }
}

Sort lines in the clipboard

var strClipboard = Clipboard.getText();
if (strClipboard) 
{
  var arr = strClipboard.split('\r\n');
  arr.sort();
  var strResult = arr.join('\r\n');
  Clipboard.setText(strResult);
}
(You could also normalize the line endings with strClipboard.replace(/\r\n/g, '\n') and split on \n).

Displaying an ANSI table

//opens an ascii table in notepad.
var s ='';
for (var i=32; i<128; i++)
{
  var si = (i<100)?' '+i : i.toString();
  s+= si + '\t' + String.fromCharCode(i);
  s+= '\r\n';
}
File.writeFile( File.getPathTemp()+'\\tmpascii.txt', s);
Process.open('notepad.exe '+File.getPathTemp()+'\\tmpascii.txt');
Showing a simple reference of ansi characters.

I also have a clipboard replacement script that gives you 26 different clipboards, each recalled by a letter. However, there exist many other clipboard-handling tools.

To learn more about Launchorz, you can watch some screencasts here. (It is similar to AutoIt, but has a full JavaScript language and namespaces).