Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

HOW TO: Add Mouse Binds to PrBoom (Plus) Using AutoHotKey in Windows

Recommended Posts

HOW TO: Add Mouse Binds to PrBoom (Plus) Using AutoHotKey in Windows

* If you would like to open doors/hit switches with a single Right Click or Middle Click then this will help.

* If you would like to use the Mouse Wheel Up and Wheel Down to select a single weapon each then this will help.

* If you have any better ideas, this might help.

At it’s most basic AutoHotKey can remap keyboard, mice and joystick buttons to most any other button yet the program can do so much more. One can even create another program from it’s scripting language and compile into a self contained exe. The self contained exe is a great feature. Any script can be compiled to an exe and ran from anywhere (like a USB stick) without AutoHotKey needing to be installed on the host system.

First, go to http://www.autohotkey.com/ to download the latest version and install it. Be sure to check out the Keyboard, Mouse & Joystick Reference.

Once installed, open Notepad or create a new text file with an .ahk extention and edit it to include the following code. Replace keys as desired.

After you made the file just double click it to run it. A green icon with a white H will appear in the area next to the windows clock. When compiled to an exe you can even specify an icon of your own. Right clicking the icon will give you the option to edit, reload or quit the program though there is little need to quit the program as I'll explain after the code.

#SingleInstance ignore
#IfWinActive PrBoom


SendEvent {4 Down}
Sleep 200
SendEvent {4 Up}

SendEvent {3 Down}
Sleep 200
SendEvent {3 Up}

SendEvent {7 Down}
Sleep 200
SendEvent {7 Up}

SendEvent {6 Down}
Sleep 200
SendEvent {6 Up}
Ok, from the top.

The command “#SingleInstance ignore” suppresses a warning message that the script is already running when the currently running script is re-launched. This allows me to place a script launch command in a batch file to ensure it is always running when PrBoom is launched.

The next command “#IfWinActive PrBoom” enables the script to function when, and only when, a window with “PrBoom” in the title is active. This means that Windows, Web Browsers etc remain unaffected. Change “PrBoom” as needed to work with other ports or DosBox.

The next 4 commands are simple re-binds for Right Click, Middle (Wheel) Click, 4th and 5th Mouse Buttons to Spacebar, key 5, key 1 and key 2 respectively. Replace 5 with “Tab” (less the quotes) to open/close the Automap with a middle click.

Lastly, since the mouse wheel has no release (Up) event of it's own the last 4 command groups tell the game a key has been pressed (Down) and is held (Sleep) for 200ms and then released (Up). If you have problems with the game not registering the input or the game switches to the SSG and then the SG without you meaning to; adjust the Sleep time up or down.


Everything should work on Vista/7. Everything but WheelLeft/Right should work on XP. Win9x... not sure.

Right and Middle mouse buttons still perform their PrBoom assigned action unless disabled in PrBoom’s config
mouseb_strafe               -1
mouseb_forward              -1
Other Shortcuts

If you add the following code you can change levels by pressing Enter and typing cl## and pressing Enter again
To display a different tray icon.

Place this code at the top of your script. It simply tells AutoHotKey to look in the script's working folder for an icon (or in this case, inside prboom-plus.exe and select the 1st icon). There are 6 icons inside prboom-plus.exe, change the 1 to a 2 or a 3 etc. Optionally, place an icon whatever.ico in the folder with the script and change code from “prboom-plus.exe” to “whatever.ico”
Menu, Tray, Icon, prboom-plus.exe, 1
This also works when the script is compiled as an exe, unfortunately, either way “prboom-plus.exe” or “whatever.ico” must be in the same folder as the script or compiled exe or it will error out unless the icon is added during the process of compiling an exe.

To Compile an exe.

Those wishing to create a standalone exe (and optionally skip installing AutoHotKey entirely by downloading their Zip file instead.)

Locate the “Compiler” folder found in the install folder or extracted from the root of the zip file. Launch Ahk2Exe.exe and browse for your script file. Optionally you can select an output file destination and name as well as an icon file. Once ready hit convert and your script is now a standalone exe that does not require AutoHotKey to be installed or an icon file in the working folder.

Hope that helps.

-EDIT- Bit of Quake Info.

If you want mouselook you might have to create a text file named autoexec.cfg in your id1 folder and add the " +mlook " command.

To disable mouse acceleration in many Quake engines without resorting to system wide registry hacks is it necessary to add -dinput to the command line. Unfortunately -dinput has the side effect of disabling mouse wheel function in game. To remedy this we can create an ahk file to remap keyboard bindings to the mouse wheel.

In quake and my autoexec.cfg I have set page up and page down to scroll my weapons from powerful to weak respectively, similar to ZDoom's default behavior. However pgup and pgdn can be changed to any number/letter that has a weapon or command bound to it. Since quake is a little more responsive with the mouse wheel then PrBoom was we are going leave out the sleep command from the code.
#SingleInstance ignore
#IfWinActive , WinQuake , <-- Change to name of Engine, check window name or taskbar.

SendEvent {pgup Down}
SendEvent {pgup Up}

SendEvent {pgdn Down}
SendEvent {pgdn Up}
In my quake autoexec.cfg / config.cfg I have set the following for weapon scroll up and down.

bind "PgUp" "impulse 10"
bind "PgDn" "impulse 12"

Share this post

Link to post

I did some quick dirty hacks in m_menu/misc.c. Is it even better?


Probably now you can bind mouse for 'use' (directly), 'move backward' and 'strafe left/right'. Also probably you can remove a bind by pressing the same key/button.

Is it really necessary to have ability to bind any action to any mouse button?

Share this post

Link to post

Thank you very much for looking into this! It would be great to not depend on AutoHotKey anymore.

I tried the prboom-plus- and it works great with Fire on Left and Use on Right with Middle unbound however when I exit the program and start it again my Fire and Use are bound to the Left button and Right is unbound.

entryway said:

Is it really necessary to have ability to bind any action to any mouse button?

I mostly just want single click Use on Right/Middle buttons while disabling Strafe/Forward on the mouse. I toyed with putting the Automap on the Middle button and later a user on Doomworld was asking if that was possible so a range of functions would be appreciated by some users here.

Finally, weapons would be really nice even if it is only on the Right/Middle buttons. I remember that Quasar posted somewhere about wanting to add full mouse (wheel, 4th & 5th button) support to Eternity but that it would take a while because of all the work involved due to limitations in SDL and old DOS code still in Eternity. So I could see myself wanting to bind Fists or Rocket launcher to the Middle button along side the keyboard bind of course if the 4th mouse button isn't supported.

Share this post

Link to post

The mouse has been fully bindable in EE for a quite a while now, barring 4th & 5th button business, which Gez has sent me a fix for. I just have to decide where I'm going to map those virtual keys. I think that I need to redesign the entire thing now that it shouldn't be strictly limited to 256 codes.

Share this post

Link to post
entryway said:

Is it really necessary to have ability to bind any action to any mouse button?

Being able to properly bind use is all I really want. The ability to unbind is great, too. Thanks for looking into this.

Share this post

Link to post

Interesting, I was actually looking at a the possibility to remap keystrokes to the mouse buttons, just like intellimouse driver does. Except that the last intellimouse driver for windows 98 only handles 3 buttons mice and only a few specific Microsoft 5 buttons mice)

The problem is that: will it work in Windows 98 ? and will it work from a within Win98 command line for Doom2.exe/heretic.exe ?

I'll try your script under 98 and get back here.
If not I wish there was a proper win98 tool out there to remap keys just like intellimouse did.

EDIT : it doesnt work ... mouse remap is not available in win98 ... but it's possible since intellimouse does it. I would pay to have something like this that actually works. Anybody up to the task ? :D

Share this post

Link to post
VinceDSS said:

it doesnt work ... mouse remap is not available in win98

The Good News: entryway might be working on making this native in PrBoom-Plus (YAY) but since it isn't ready yet I looked at the Docs again and it said for Win9x "The recommended method is to use Send and KeyWait." So try this please. Delete the contents of your .ahk file and add or make a new one with only the following to test if Right Mouse acts as Spacebar.

#SingleInstance ignore
#IfWinActive PrBoom

Send {Space Down}
KeyWait RButton
Send {Space Up}
If it works I have made Italic the key name we are 'mapping to' and Bold the key name we are 'mapping from' so you can easily see what to edit if you wish. MButton is the name of the Middle/Wheel Click.


The Bad News: The Docs also state that Wheel support is only NT/2000/XP or later and XButton1/2 (4th/5th mouse buttons) are only supported in 2000/XP or later. Part of it is probably because Windows 9x has no native driver support for 4th/5th mouse buttons.

Share this post

Link to post

Well, intellimouse 4.12 (for win98) support remapping keystrokes to 4 & 5. That's what I use for my doom2.exe / heretic.exe setup.
Intellimouse was not detecting the 4th and 5th button when it was plugged on the USB, changed to PS2 and now it works.

Anyhow, I was very interested in the mousewheel side of this.
Yet again for command line apps in Win98, not prboom-plus. A prboomplus port for heretic 1.3 would be interesting though.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now