I was looking for ways to prevent settlers from taking valuable stuff from the workshops and containers. Some of the lengths people went to and their lack of success was surprising. I like the simplicity of a lockable safe so I made an AutoHotKey script for securely locking and unlocking a player created floor safe using the console with the convenience of one button. The safe requires a key to unlock it, so it shouldn't be pickable by any settlers. About halfway through, I realized I was making a one-button unlocking cheat, doh. I don't have a problem resisting cheats and also don't really care what someone else may use the script for in a single-player game, so I'm posting it anyway. It may help people with game problems rather than cheating.
To use it, just focus on the safe and press "u" to unlock and "l" to lock. If you don't own the safe that you are locking, it doesn't get set to requiring a key, just back to locked.
-----------------------------------------------------------------------
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; may need to increase these if on a slower computer?
short_wait=50 ; time in milliseconds
long_wait=250
; assuming a full screen window on 1080p monitor
x_mid:=1920/2 ; middle of the window
y_mid:=1080/2
open_console(short_wait, long_wait, x_mid, y_mid)
{ SetKeyDelay, 20, 50
SendEvent {vkC0sc029} ; the Grave Accent Key (unshifted tilde) on qwerty keyboards (???)
Sleep, %short_wait%
MouseMove, %x_mid%, %y_mid%
Click down
Sleep, %short_wait%
Click up
Sleep, %long_wait%
Return
}
close_console(short_wait, long_wait)
{
SetKeyDelay, 20, 50
Sleep, %short_wait%
Send, {ENTER down}
Sleep, %short_wait%
Send, {ENTER up}
Sleep, %long_wait%
MouseMove, 0, 0
Click down
Sleep, %short_wait%
Click up
Sleep, %short_wait%
SendEvent {vkC0sc029}
Sleep, %short_wait%
Return
}
; only map the keys when 'Fallout4' is in the active window's title
#IfWinActive, ahk_class Fallout4
u:: ; unlock a safe with no key via console
open_console(short_wait, long_wait, x_mid, y_mid)
Send, unlock
close_console(short_wait, long_wait)
Return
l:: ; lock a safe that requires a key via console
open_console(short_wait, long_wait, x_mid, y_mid)
Send, lock -1
close_console(short_wait, long_wait)
Return