Foxhole

Foxhole

Not enough ratings
Hammer's Delight: Click Without Clicking!
By yurisuika
Stop holding down LMB for hours and let your computer do it for you! How to enable ClickLock feature in Windows and set a hotkey to toggle it while in-game using AHK!
   
Award
Favorite
Favorited
Unfavorite
Introduction
Have you ever wished that hammering out vehicles in a garage, scrapping salvage for hours, or many of the things in Foxhole that wear out your left mouse button and associated finger could be alleviated? Well, there is a solution!

Enabling ClickLock
Windows has a built-in feature called ClickLock, found under the mouse settings. Just open up the Settings menu, nagivate to Devices > Mouse > Additional Mouse Options, and you will see the dialog box with the checkbox to toggle it.

Now you can hold down LMB for a couple seconds to trigger it! Your click will hold until you click again! Your finger will thank you!

This is great already as it is, but you will still have to tab out of the game every time you want to toggle it. There is a better way!

Installing AutoHotkey
AutoHotkey is a scripting software that you can use to make your own hotkey to toggle ClickLock with.

Open your browser and navigate to AutoHotkey's website[www.autohotkey.com], download, and install it!

Once done, you can then proceed to creating a script!

Creating an AHK Script
Open up Explorer and choose where you want to have your script be stored.

AHK will have added itself to your right-click context menu, so you can choose New > AutoHotkey Script. Name the file whatever you like!

Right click the file and Edit Script or open it in your preferred editor!

The contents are as simple as this! Please note which version of AHK you have installed, as which script you choose will depend on it. As we see here, the AHK 2 script differs because hotkeys are now functions and require brackets, as well as that the toggle variable now has to be declared and initialized.

#Requires AutoHotkey 2.0+ ~ScrollLock:: { static toggle := false DllCall("SystemParametersInfo", "UInt", 0x101F, "UInt", 0, "UInt", toggle:=!toggle, "UInt", 0) ;SPI_SETMOUSECLICKLOCK Return }

#Requires AutoHotkey 1.1- ~ScrollLock:: DllCall("SystemParametersInfo", "UInt", 0x101F, "UInt", 0, "UInt", toggle:=!toggle, "UInt", 0) ;SPI_SETMOUSECLICKLOCK Return

~ScrollLock:: sets the keybind that you want to toggle ClickLock with and what follows after the double colons is what is ran from that hotkey.

In this example, I am using the Scroll Lock key to toggle ClickLock, but you can set it to anything you like! For documentation on how to choose your own hotkeys, see AHK's website[www.autohotkey.com]!

Double click to run it and you can now toggle ClickLock while in Foxhole!

Scheduling a Task
There is one more step you can take to make your life easier, and that is to make it so this script is ran every time you log in to your computer so you don't have to manually launch it!

The best way to go about this is using Task Scheduler. There are a number of ways to open it, but one of the quickest is to open Run using Win + R and entering taskschd.msc.



Once open click Create Basic Task... on the right.

Name it whatever you wish and then proceed to the Trigger section. Here set it to When I log on, and then proceed. Under Action, leave it as Start a program.

Under program/script, enter "C:\Program Files\AutoHotkey\AutoHotkey.exe", or wherever you have installed the AHK executable. Under the arguments section, add the location of your script! In my example, it is at C:\ClickLock.ahk.

Proceed and click Finish, and you are done!

Alternatively: Using an Autoclicker
An autoclicker is a program that will repeatedly click on a position on the screen, whereas ClickLock keeps the left click held down.

ClickLock and autoclickers both work for some things and each for only some others in Foxhole:
  • Both are great for hammering out structures, repairing vehicles, shoveling trenches and bunkers, and manually scrapping fields.
  • Only ClickLock works for using a BMS - Scrap Hauler on a field. This must be held down to function.
  • Only autoclickers work for taking stuff from stockpiles, such as basic materials from a refinery. This requires a click each time you want to take another stack.

One popular autoclicker among Foxhole players is NIAutoclicker[github.com]. It is a simple program that you activate and toggle with Alt + Backspace to select a position. You can use Alt + - to change some settings such as click rate and amount of click positions.



One big advantage is that this can run whether the window is active or not. This means you can dig out your huge bunker base while tabbed out to do other things!

One downside is that you must start the program again to select a different position to click. We can, however, use AHK to create a script to run it again with a hotkey!

Following the steps you learned before, you can make a new AHK script as so:

#Requires AutoHotkey 2.0+ ~Pause:: { Run "C:\NiAutoclicker.x64.exe" }

#Requires AutoHotkey 1.1- ~Pause:: Run "C:\NiAutoclicker.x64.exe"

Of course, just change the location to wherever your autoclicker executable is. I've used the Pause key, but once again you can set the hotkey to whatever you desire!
6 Comments
Sh1my Apr 20, 2024 @ 8:22pm 
not working(
yurisuika  [author] Apr 17, 2024 @ 7:04am 
ClickLock will not continue to work in-game when tabbed out, but NIAutoclicker will. I do not know if other autoclicker programs will, as I have not tried any others.
Sh1my Apr 17, 2024 @ 3:42am 
not working when alt tab
Sh1my Apr 17, 2024 @ 1:44am 
why is autohotkey not working in browser and only in game?
[Jaeger] The Rock Jan 25, 2023 @ 7:10am 
I'll have to give a try because I absolutely hate having to hold my mouse when building
[Jaeger] The Rock Jan 25, 2023 @ 7:10am 
That's a pretty cool use of Auto Hot Key