How do I batch Automapping?

(路西) #1

Currently, I have lot of maps wait to Automapping. I need open all the maps and click “A” or “a” for each map. Can I do it with a single command?, My english is bad, I hope you understand what I mean, Looking forward to your reply.

(Erik Schilling) #2


Currently this is unfortunately not possible, no. At least not with Tiled itself. You might be able to script it with something like AutoHotKey or AutoKey.


(路西) #3

I used AutoHotKey to solve my problem, thank you very much for your help.

(Thorbjørn Lindeijer) #4

(Thorbjørn Lindeijer) #5

I’ve just pushed a change that adds initial scripting capabilities to Tiled, which can be executed from the “Console” view. With that change it is possible to batch automapping as requested here by executing the following script:

var document = tiled.documentManager.currentDocument;
var firstDocument = document;
while (document) {
    document = tiled.documentManager.currentDocument;
    if (document === firstDocument)

The script is a little strange, because the API is currently still very limited. :slight_smile:

(路西) #6

Thank you for your reply, but I don’t know how to use this script. Can I use the command like this “tiled.exe -auto mapfilepath newmapfilepath”? If so, it would be perfect.

again thank you.

(Thorbjørn Lindeijer) #7

It can’t be executed from the command-line currently, though running scripts from the command-line will certainly be implemented. There is currently also no option to automap from the command-line, though that certainly would be nice.

However, if you install the latest snapshot, the script I provided above can be run by pasting it into the text input in the “Console” view. Later on, it will be possible to set up a shortcut to run such a script, for example.

The exact implementation of the script is subject to change though. In the development version, I’ve already changed it so that it should be written like this instead:

var assets = tiled.openAssets;
for (var i = 0; i < assets.length; ++i) {
    tiled.activeAsset = assets[i];

I think that’s a lot cleaner. The above script will work in the next development snapshot (to be published next week), but in the meantime you could use the previous script.