Handy tool for customizing controls

OfftheRails

Registered User
Joined
Aug 19, 2011
Messages
4,644
Age
43
I use autohotkey to customise my controls and allow for things like joystick buttons that only work as long as they're held down... I've also got a useful little script that displays my throttle percentage on the screen. Handy for learning to land the jets, hover the choppers and to make sure you're stopped on the runway.

A couple of things to know - it's set up right now to use BF2 colours and display itself in the bottom right of a 1920*1080 display. You can alter the position and appearance of the indicator by editing the file in notepad. I've commented the variables that can be edited; they are lines 20-29 if you're using notepad++ or similar.

I have the indicator display a number between -100% to +100%. 0% is idling the engines in a jet or a perfectly flat hover in a chopper. If you prefer a different scale you'll need to edit the following line in the Code section at the bottom of the script:

Code:
	throttle := 100 - (2 * joyz)

Put whatever function you want. Change it to

Code:
	throttle := 100 - (joyz)

to set the scale to 0% to 100%, or change it to something completely different.

FYI, PB has no trouble at all with these scripts in spite of a fairly bad rep from Dolphin Diving Days. BF2 is pretty good at detecting and ignoring virtual mouse clicks and so forth.
 
The script!

Code:
;;;;;;;;;;;;;;;;;;;;;
;; Throttle Indicator
;;;;;;;;;;;;;;;;;;;;;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook
#KeyHistory 500

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;EDIT THE FOLLOWING SECTION TO SUIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

xposition = 1800 ;where to display the indicator. Relative to the top-left corner of 
yposition = 1035 ;screen #1 if you have multiple monitors

FontName = IrisUPC   ;}This is a pretty good match for BF2's
FontSize = 18        ;}HUD. You may wish to change these values.
FontBoldness = 1000  ;}Play around! Experiment!
TextColour = d3d2b3  ;}BF3 will be very different!

BackgroundColor = 4a4d42 ;Background colour used for anti-aliasing purposes. Choose something that's a good contrast to TextColour and blends in fairly well with the background colour
JoystickNumber = 1 ;You might need to change this if you have more than one stick


;;;;;;;;;;;;;;;;;;;;;;;;;
;;END OF EDITABLE SECTION
;;;;;;;;;;;;;;;;;;;;;;;;;

SetFormat, float, 03  ; Omit decimal point from axis position percentages.
GetKeyState, joy_info, %JoystickNumber%JoyInfo
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %BackgroundColor%
Gui, Font, s%FontSize% w%FontBoldness%, %FontName%
Gui, Add, Text, vMyText c%TextColour%, XXXXX YYYYY  ; XX & YY serve to auto-size the window.
; Make all pixels of this color transparent and make the text itself translucent (150):
WinSet, TransColor, %BackgroundColor% 2000

;;;;;;;
;;Timer
;;;;;;;

SetTimer, UpdateOSD, 20
return

;;;;;;
;;Code
;;;;;;

UpdateOSD:
	GetKeyState, joyz, %JoystickNumber%JoyZ
	throttle := 100 - (2 * joyz)
	GuiControl,, MyText, %throttle%`%
	Gui, Show, x%xposition% y%yposition% NoActivate  ; NoActivate avoids deactivating the currently active window.
return

To use, download autohotkey (linked in the post above) and save the code as a plain text file with an .ahk extension - eg throttle.ahk. Double-click to run; right-click the icon in the system tray to exit.
 
I've been using it for ages with no issues. I think pb gets uppity if you compile the script into an .exe file but autohotkey itself is fine
 
Back
Top