Automate routine with Autohotkey in Steam ver
For me, the most tedious thing in mass construction is to choose the necessary material. Or every time, click on the button to remove the item. So I automated these two things with Autohotkey. If you spend a little time, it will be much easier and faster to build.
Autohotkey is a very lightweight scripting language for automation. Here you can download it (i use v1.1): https://www.autohotkey.com/
You need download it, install, reload, and now you can launch your scripts. To make a script, just make blank text file (rmb - new - text document), then change extension from "txt" to "ahk" and run it with code - that's it.
Code (copy-paste it in your ahk file and additional changes needed, explanations below):
#ifWinActive ahk_class SDL_app
!d::
MouseGetPos, xpos, ypos
BlockInput, MouseMove
MouseMove, 1911, 143, 0
Sleep 30
Send {LButton down}
Sleep, 20
Send {LButton up}
Sleep, 50
MouseMove, %xpos%, %ypos%, 0
Sleep 300
Send {RButton down}
Sleep, 20
Send {RButton up}
Sleep, 50
BlockInput, MouseMoveOff
Return
!l::
MouseGetPos, xpos, ypos
BlockInput, MouseMove
MouseMove, 1380, 250, 0
Sleep 30
Send {LButton down}
Sleep, 20
Send {LButton up}
Sleep, 50
Send {L}
Sleep, 20
Send {i}
Sleep, 20
Send {m}
Sleep, 20
Send {e}
Sleep, 20
Send {s}
Sleep, 20
Send {t}
Sleep, 20
Send {o}
Sleep, 20
Send {n}
Sleep, 20
Send {e}
Sleep, 20
Send {Space Down}
Sleep, 20
Send {Space Up}
Sleep, 20
Send {b}
Sleep, 20
MouseMove, 2030, 313, 0
Sleep 30
Send {LButton down}
Sleep, 20
Send {LButton up}
Sleep 50
MouseMove, %xpos%, %ypos%, 0
BlockInput, MouseMoveOff
Return
!j::
MouseGetPos, xpos, ypos
BlockInput, MouseMove
MouseMove, 1380, 250, 0
Sleep 30
Send {LButton down}
Sleep, 20
Send {LButton up}
Sleep, 50
Send {j}
Sleep, 20
Send {e}
Sleep, 20
Send {t}
Sleep, 20
Send {Space Down}
Sleep, 20
Send {Space Up}
Sleep, 20
Send {b}
Sleep, 20
MouseMove, 2030, 313, 0
Sleep 30
Send {LButton down}
Sleep, 20
Send {LButton up}
Sleep 50
MouseMove, %xpos%, %ypos%, 0
BlockInput, MouseMoveOff
Return
#ifWinActive
Explanations:
There 3 hotkeys, Alt+d - autodelete, Alt+l - choose "limestone blocks" and click "all", Alt+j - "jet blocks" and click "all"
!d::
Autodelete installed crafts - it clicks on the removal icon and returns the cursor back and close opened window
Alt+d - It is hotkey i define to run the code ("!" - alt, you can customize it: "^" - ctrl, "+" - shift) d - just d, so you can change to ^+r:: — "ctrl + shift + r"
MouseMove, 1911, 143, 0
where the script will move the mouse, we all have different monitors, and these numbers will be different, so you have to define your own. To do this, run script first, script icon will appear on taskbar, RMB and run "Window Spy". Window spy wall appear and you can see your mouse position numbers (x, y). You need to define your cursor position numbers. Run DF in windowed mode, hide your taskbar, fullscreen DF window, move the mouse cursor to the delete icon, change my numbers to yours. Save and reload script (RMB on taskbar icon - "reload this script"). If you play fullscreen, subtract from Y 20 (Your mouse position like 1620 107 - you need 1620 87).
!l:: and !j::
Moves the cursor to the entry point of the material, presses LMB, enters the name of the material, chooses "All". You also need to change the number of cursors (there two of it - input the name of the material and the button "all"). And of course change all the letters in the title of the material to the one you need.
P.S.
I locked mouse while the script is running, so that my random mouse movements do not stop it, but the lock only works if you run the script as administrator. If you run the script without administrator, it will work, but it cannot lock your mouse moves.
When you build, there’s one limitation - your mouse should be on the left side of the screen. If the mouse is in the right part, the input window will appear in the left, which breaks the whole script.
Posted Jan 16, 2023, 2:22 AM UTC · edited
Has anyone done this with a Logitech mouse or keyboard? I have the G642 mouse or something like that and recently saw that they also have a scripting feature now.