v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Editing 40d:Macros and keymaps

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.

You are editing a page for an older version of Dwarf Fortress ("Main" is the current version, not "40d"). Please make sure you intend to do this. If you are here by mistake, see the current page instead.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{Quality|Superior|11:05, 18 May 2015 (UTC)}}
+
Playing Dwarf Fortress means lots of typing.  Although the game has no internal macro/keymap system, using an external program can save you a great deal of time when dumping, rewalling, designating, and so forth.
{{av}}
 
Playing Dwarf Fortress means lots of typing.  Although the game has no internal macro/keymap system (except in alpha version 40d12), using an external program can save you a great deal of time when dumping, rewalling, designating, and so forth.
 
  
 
#  Go to [[Utilities#AutoHotKey]] and download AutoHotKey.  Installation is simple and the program uses few system resources.
 
#  Go to [[Utilities#AutoHotKey]] and download AutoHotKey.  Installation is simple and the program uses few system resources.
Line 10: Line 8:
 
Users may experience some issues in getting scripts to work, particularly when using looping scripts when experiencing low frame-rates.
 
Users may experience some issues in getting scripts to work, particularly when using looping scripts when experiencing low frame-rates.
 
* If experiencing low frame-rates, try adding delays ("Sleep 100" to pause for 100 milliseconds for example) within loops to allow the interface to keep up. If there are nested loops, sometimes adding a pause at the end of an inner loop is all that is needed to flush the keyboard buffer
 
* If experiencing low frame-rates, try adding delays ("Sleep 100" to pause for 100 milliseconds for example) within loops to allow the interface to keep up. If there are nested loops, sometimes adding a pause at the end of an inner loop is all that is needed to flush the keyboard buffer
* Another way to add delay during and after each simulated key press is to put <B>SetKeyDelay, 40, 40</B> at the start of the macro.
 
 
* Make sure that Dwarf Fortress maintains focus. IM windows are the enemy! Who needs friends anyhow? You've got Dwarf Fortress.
 
* Make sure that Dwarf Fortress maintains focus. IM windows are the enemy! Who needs friends anyhow? You've got Dwarf Fortress.
 
* This may go without saying, but most macros assume standard key-mappings. If you're using non-standard ones, you may have to edit the macro to get it to work.
 
* This may go without saying, but most macros assume standard key-mappings. If you're using non-standard ones, you may have to edit the macro to get it to work.
 
* Visiting liaisons can bring up screens that eat keystrokes, throwing a long-looping script out-of-phase with where it expects the game to be.  Wait for the farewell screen before running a long script.
 
* Visiting liaisons can bring up screens that eat keystrokes, throwing a long-looping script out-of-phase with where it expects the game to be.  Wait for the farewell screen before running a long script.
 
* The <B>SendPlay</B> function supports keys that the <B>Send</B> function does not, for example {{key|Shift-Enter}}.  According to the AutoHotKey documentation, <B>SendPlay</B> may also be better at preventing dropped keystrokes.
 
* The <B>SendPlay</B> function supports keys that the <B>Send</B> function does not, for example {{key|Shift-Enter}}.  According to the AutoHotKey documentation, <B>SendPlay</B> may also be better at preventing dropped keystrokes.
 
== [http://sun2design.com/quickfort/ Quickfort] ==
 
 
Quickfort is an AutoHotkey-based utility for Dwarf Fortress that helps you build fortresses from "blueprint" .CSV files (comma separated values). These files are easily created and edited in an app like Excel. Most building-oriented DF commands are supported through the use of multiple .CSV files to describe the different phases of DF construction (designation, building, stockpiles, and making adjustments). Many of the examples below can be reproduced in Quickfort.
 
 
 
== Built-in Macros ==
 
 
With the release of df_28_181_40d13, Dwarf Fortress supports macros without any outside program. They can be created by hitting escape to access the options menu and choosing the Key Bindings section. Once in the Key Bindings menu hit Shift+Tab to open the macro screen. The macros you create here are saved in the file "\data\init\interface.txt". Adding the following to the end of that file will create a macro that selects every item on the trade screen when you hit the tilde key (`).
 
 
<pre>
 
[BIND:MACRO0]
 
[SYM:`]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
[MACRO:SELECT:1]
 
[MACRO:STANDARDSCROLL_DOWN:1]
 
</pre>
 
 
Performance can be increased by changing the macro pause, MACRO_MS, from the default 150ms per command to zero.  Most dig macros can be created using combinations of the following:
 
<pre>
 
[MACRO:CURSOR_UP:1]
 
[MACRO:CURSOR_DOWN:1]
 
[MACRO:CURSOR_LEFT:1]
 
[MACRO:CURSOR_RIGHT:1]
 
[MACRO:SELECT:1]
 
[MACRO:DESIGNATE_DIG:1]
 
[MACRO:DESIGNATE_UNDO:1]
 
[MACRO:CURSOR_UP_FAST:1]
 
[MACRO:CURSOR_DOWN_FAST:1]
 
[MACRO:CURSOR_LEFT_FAST:1]
 
[MACRO:CURSOR_RIGHT_FAST:1]
 
[MACRO:MACRO123:1]
 
</pre>
 
Most of these should be self-explanatory. Each command is followed with a quantity.  To call other macros, use <pre>[MACRO:MACRO###:1]</pre> Each new macro begins with a bind command, consisting of BIND, the macro number, and a description:
 
<pre>[BIND:MACRO11:dig_round_room]</pre>  Spaces are not allowed in the description{{verify}}.  To bind this macro to a key, SYM is used.<pre>[SYM:Ctrl+Right]</pre> Ctrl, Alt, and Shift combinations are allowed, but not chords with more than one{{verify}}, like Ctrl+Shift+Right.  Also, the windows, or meta key, does not appear to be supported{{verify}}. Macros appear to only be terminated by the start of a new macro (BIND command) or the end of the interface.txt file.
 
 
Visit this [http://www.bay12games.com/forum/index.php?topic=40751.0 forum post] for additional macros, and discussion on macro creation.
 
  
 
== AutoHotKey Examples ==
 
== AutoHotKey Examples ==
  
 
===Dumping===
 
===Dumping===
 
====[[GuiDumper.ahk]]====
 
This script allows the user to specify a range of squares to dump.
 
 
 
====Stock Screen Dump====
 
====Stock Screen Dump====
 
Taken from an old version of [[User:Jackard|Jackard's user page]].
 
Taken from an old version of [[User:Jackard|Jackard's user page]].
  
To use, first have your bookkeeper do enough desk work so you can view individual items in the stocks listing.  Then bring it up and press del to quickly mark stuff.  To adjust the key repeat rate, edit the KEY_HOLD_MS value in \data\init\init.txt.
+
To use, first have your bookeeper do enough desk work so you can view individual items in the stocks listing.  Then bring it up and press del to quickly mark stuff.  To adjust the key repeat rate, edit the KEY_HOLD_MS value in \data\init\init.txt.
  
 
<pre>
 
<pre>
Line 107: Line 40:
 
This script uses a system similar the commands in the designations menu to mark most of the contents of a large area for dumping. [[User:Dukederek|My talk page]] has more detailed instruction.
 
This script uses a system similar the commands in the designations menu to mark most of the contents of a large area for dumping. [[User:Dukederek|My talk page]] has more detailed instruction.
  
Essentially you need to create two text files with the following titles and content. When playing DF it is safe to have blockdumpinit running constantly as long as you don't plan on using the ctrl-d combination for something else.
+
Essentially you need to create two text files with the following titles and content. When playing DF it is safe to have blockdumpinit running constantly as long as you dont plan on using the ctrl-d combination for something else.
  
 
'''blockdumpinit.ahk'''
 
'''blockdumpinit.ahk'''
Line 349: Line 282:
  
 
SetKeyDelay, 12 ;Key delay, to keep Dwarf Fortress from being overwhelmed.
 
SetKeyDelay, 12 ;Key delay, to keep Dwarf Fortress from being overwhelmed.
;Set higher if you get weird results, or lower to get the
+
:Set higher if you get weird results, or lower to get the
;script to run faster
+
:script to run faster
 
SLEEPTIME = 12 ;same thing, only used in the repeated key press loops though
 
SLEEPTIME = 12 ;same thing, only used in the repeated key press loops though
  
Line 792: Line 725:
  
 
===Bed Assigning macro===
 
===Bed Assigning macro===
This will assign bedrooms to your dwarves. Press F3 followed by a single digit indicating how many beds to assign. Can repeat the action, as the number of beds assigned is stored in a counter. Room size is default, but easily edited into the script. By [[User:Napsterbater|Napsterbater]].
+
This will assign bedrooms to your dwarfs. Press F3 followed by a single digit indicating how many beds to assign. Can repeat the action, as the number of beds assigned is stored in a counter. Room size is default, but easily edited into the script. By [[User:Napsterbater|Napsterbater]].
  
 
<pre>
 
<pre>
Line 821: Line 754:
 
This macro can read a spreadsheet and designate rooms according to it. [http://www.bay12games.com/forum/index.php?topic=1428.0 Version 1]
 
This macro can read a spreadsheet and designate rooms according to it. [http://www.bay12games.com/forum/index.php?topic=1428.0 Version 1]
  
Version 2 of this macro apparently only works in versions up to and including 38c {{verify}}, and can be found here: [http://www.bay12games.com/forum/index.php?topic=1890.0 Version 2]
+
Version 2 of this macro apparently only works in versions up to and including 38c <sup>[[verify]]</sup>, and can be found here: [http://www.bay12games.com/forum/index.php?topic=1890.0 Version 2]
  
 
====Fedor's chambered circle====
 
====Fedor's chambered circle====
Line 925: Line 858:
  
 
====LordGrunt's room macro====
 
====LordGrunt's room macro====
Based on 1 of the fractal [[Bedroom_design|bedroom designs.]]
+
Based on 1 of the fractal [[Bedroom_design| bedroom designs.]]
  
 
[http://mkv25.net/dfma/movie-1226-fractalbedrooms Demo Movie]
 
[http://mkv25.net/dfma/movie-1226-fractalbedrooms Demo Movie]
Line 1,714: Line 1,647:
  
 
====The MOUSE control====
 
====The MOUSE control====
For unrivaled mouse control in DF try [[User:Digger|this DF Mouse script]]
+
For unrivaled mouse control in DF try [http://www.dwarffortresswiki.net/index.php/User:Digger this DF Mouse script]
  
 
====Tile Counter or Scrolling Accelerator====
 
====Tile Counter or Scrolling Accelerator====
 
Lack of reference plus slow scroll speed make planning digging area frustrating,so here is the script that shows coordinate and speed scrolling up.
 
Lack of reference plus slow scroll speed make planning digging area frustrating,so here is the script that shows coordinate and speed scrolling up.
[[User:Daedalusai|ShowXY]]
+
[http://www.dwarffortresswiki.net/index.php/User:Daedalusai ShowXY]
  
 
===4-Pour Water Creation script===
 
===4-Pour Water Creation script===
Line 2,231: Line 2,164:
 
1111111111111111111111111111111111111
 
1111111111111111111111111111111111111
  
</pre>
 
 
=== jokermatt999's pump stack builder ===
 
 
Just a simple macro to place one mined level of a pump stack room, as illustrated in the pump stack page on this wiki. It's recommended you exit out after finishing up with it, as the macro is just assigned to p. Hit/Hold down p for multiple layers.
 
 
<pre>
 
p::Send i{Enter}{Enter}{Right}d{Enter}{Right}{Right}{Down}{Down}{Enter}h{Enter}{Enter}{Up}{Left}x{Enter}{Enter}{Left}{Left}{Down}h{Enter}{Enter}{Up}{Up}{Shift Down}.{Shift Up}
 
</pre>
 
 
<pre>
 
p::
 
Send i{Enter 2}
 
Send d6{Enter}33{Enter}
 
Send h{Enter 2}
 
Send x7{Enter 2}
 
Send h14{Enter 2}
 
Send 88{Shift Down}.{Shift Up}
 
return
 
 
</pre>
 
</pre>
  
 
{{Game_Interface FAQ}}
 
{{Game_Interface FAQ}}
 
[[Category:ahk scripts]]
 
[[Category:ahk scripts]]

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)

Templates used on this page: