As part of an ongoing project (It'll eventually be a post on my blog) I've been working with very high-resolution heightmaps and got a bit tired of waiting for long erosion runs to finish, so I worked out a way to automate the process using AutoHotkey, a program that lets you build and run scripts of keyboard and mouse input. I've built [this script](https://www.dropbox.com/s/ffieiv3v1n...200.4.ahk?dl=0) that includes a library of functions that navigate the Wilbur menus to apply specific commands, as well as an example of a script built with these functions.

Each function works by assuming Wilbur is open and the mouse is placed over "Select" on the menu bar. The function inputs the proper commands to navigate through the menus and select the option for a specific command (or just uses hotkeys if they're available) and then, if necessary, also inputs the proper options in any configuration windows. It will wait for any progress windows to close, and check that the program is ready to run again (by trying to open the "map info" window) before starting the next function. For long functions this may sometimes make the program look like it's crashing and not responding. Not every Wilbur process is included--some would be very complex to code out and a few are simply inaccessible from keyboard inputs alone--but pretty much all the most commonly used ones are.

So in short, to run the example script, you would:

- Download and install AutoHotkey

- Download the erosion pasta script linked above

- Change the x and y values within the example script to the resolution of your heightmap.

- Start the script by double-clicking the script

- Open Wilbur, load the heightmap you wish to erode, and make sure it's set to the proper vertical scaling and sea level.

- Make sure that there is a greyscale mask named "noise.png" that is in the same directory as that heightmap (maybe also load that mask as a selection once before you start to make sure Wilbur looks at the right directory later).

- Place the mouse over "select" in the menu bar.

- Press Ctrl-f

The script should run through and then show a message once it completes. You can pause it any time with Ctrl-p, and unpause it the same way (but there's really no guarantee it will properly continue if interrupted in the middle of a function) and stop it and unload the script with Ctrl-x.

You can construct your own script using the functions in a similar way to the example. They key is that every script should start with a global speed variable (which sets the timing of various pauses throughout the functions; a speed of 1 should usually be fine but higher values may help prevent the functions executing too quickly on slower computers or larger maps), and the "checksel" function (which loads a selection to clear an issue with the "load selection" window behaving oddly the first time it is opened, and so must be given an existing greyscale image to load, but the image itself isn't important). If your script involves loading and saving of files, you may also want to check that Wilbur is looking into the right directories first before running it.

This is a bit of a hack, of course, so there are some major downsides and caveats:

- Wilbur must be left open as the main window and the mouse must not be moved while a script executes.

- I have not extensively tested every function here so cannot guarantee that they are all working perfectly.

- Even if the functions work right on my computer, I can't guarantee they will work right on other computers that may behave differently.

- This script is built for Wilbur version 1.90; Older or later versions may have different menu layout or behavior that breaks these functions (I know specifically that the precipiton function with multiple passes probably won't work right on older versions).

The example script is one I've been using for large maps at roughly 2 km/pixel resolution. Basically I start with a sketch like this:

Click image for larger version. 

Name:	weg test2.png 
Views:	37 
Size:	46.9 KB 
ID:	133727

(Note the exponential elevation scaling)

I convert that to greyscale and smooth it out and noise it up in Gimp (and threw in a trench just for testing):

Click image for larger version. 

Name:	test2 c.png 
Views:	24 
Size:	915.3 KB 
ID:	133728

And then apply the script (with an additional exponential scaling at the end, which I didn't include in the script because I like to place those reference elevations in the upper-left first) to get a result like this:

Click image for larger version. 

Name:	test2 out river.png 
Views:	42 
Size:	812.5 KB 
ID:	133729