Skip to content

Instantly share code, notes, and snippets.

@KSneijders
Last active March 27, 2024 07:00
Show Gist options
  • Save KSneijders/9231eeec1a66b314c3402729f0c455fa to your computer and use it in GitHub Desktop.
Save KSneijders/9231eeec1a66b314c3402729f0c455fa to your computer and use it in GitHub Desktop.
The new HKP hotkey file format explained

AoE2:DE HKP file format

Disclaimer

This is my first time working with HKI and HKP files so there might be mistakes in my assumptions.
That being said, the file format shown below definitely is correct.

Please place a comment below if you find any issues regarding these notes.


For information about the exact hotkey distribution, see my other gist.


This document explains the 'new' .hkp format introduced in update 83607.

To explain the differences in the format I'll cover the 'old' structure (.hki files) here too.


TL;DR

You're here just for the changes, makes sense. There's only a couple:

There's two files now, for specifics see: HKP file paths.
The tag <profile> in <profile>/Base.hkp or <profile>.hkp refer to the name of the hotkey profile. These paths are relative from the profile folder where the .hki files reside too.

File: <profile>.hkp

This file is the same as the 'old' hki format.

File: <profile>/Base.hkp

For the <profile>/Base.hkp or <profile>/Pompeii.hkp (RoR DLC) the following changes apply:

In the main struct of the file:

Between the fields version (uint32) and number_of_menus (uint32) add the following:

  • base_menus (HkiMenu) hardcoded to repeat=3

For a quick overview of the new HKP structure, see Struct: HkpFile (Base.hkp).


HKI file specifications

HKI file path

The hki format contained a single file, which was stored in the following location:

C:\Users\<user>\Games\Age of Empires 2 DE\<steam-id>\profile\<hotkey-profile-name>.hki

There's three structs in this file, they're documented below:

HKI file structure

Struct: HkiFile

Main struct, covering the entirety of the hki file.

Name Type Repeat Description
version uint32 1x The version of the file. Latest: 0x40400000
number_of_menus uint32 1x The amount of menus in this file (see HkiMenu struct)
menus HkiMenu number_of_menus The hotkey menus

Struct: HkiMenu

A single menu in the file containing a set of hotkeys.
A single menu corresponds to a single tab in the hotkey menu in the game.

Name Type Repeat Description
number_of_hotkeys uint32 1x The amount of hotkeys in this menu (see HkiHotkey struct)
hotkeys HkiHotkey number_of_hotkeys The hotkeys in this menu

Struct: HkiHotkey

A single hotkey for a singular action.

Name Type Repeat Description
key int32 1x The keycode of the hotkey (mostly the same as ASCII, except for mouse (wheel) hotkeys)
string_id int32 1x The string ID of the name of the hotkey field from the key-value-strings-utf8.txt file
ctrl int8 1x If the ctrl modifier is set for this hotkey
alt int8 1x If the alt modifier is set for this hotkey
shift int8 1x If the shift modifier is set for this hotkey
'mouse' int8 1x -Unsure-

Other

The latest <profile>.hki file contains 409 hotkeys over 24 menus.


HKP file specifications

HKP file path

With the hkp format, there are now two files instead of one, these are stored in the following locations:

C:\Users\<user>\Games\Age of Empires 2 DE\<steam-id>\profile\<hotkey-profile-name>.hkp
C:\Users\<user>\Games\Age of Empires 2 DE\<steam-id>\profile\<hotkey-profile-name>\Base.hkp

If you own the RoR DLC you'll have a third hkp file located next to the Base.hkp at:

C:\Users\<user>\Games\Age of Empires 2 DE\<steam-id>\profile\<hotkey-profile-name>\Pompeii.hkp

HKP file structure

Struct: HkpFile (Base.hkp)

Main struct, covering the entirety of the <profile>/Base.hkp & <profile>/Pompeii.hkp file.

Name Type Repeat Description
version uint32 1x The version of the file. Latest: 0x86406666
base_menus HkpMenu 3x Base hotkey menus
number_of_menus uint32 1x The amount of menus in this file (see HkpMenu struct)
menus HkpMenu number_of_menus The hotkey menus

Struct: HkpMenu

This struct has not changed since the hki file format

See: HkiMenu

Struct: HkpHotkey

This struct has not changed since the hki file format

See: HkiHotkey

Other

The new hkp files contain:

  • <profile>/Base.hkp: 212 hotkeys over 18 menus

  • <profile>.hkp: 188 hotkeys over 9 menus

  • <profile>/Pompeii.hkp: 146 hotkeys over 16 menus

  • Combined for the base game: 400 hotkeys over 27 menus

  • Combined for the RoR game: 334 hotkeys over 25 menus


Other changes

These changes I happened to stumble upon, there's probably more.

Flare changes

  • With HKI the flare hotkey used to use the 19289 "Flare" string ID
  • With HKP the flare hotkey uses the 19235 "Flare" string ID

Small duplicate fix

In both the hki and the hkp file are duplicates (hotkeys you can set on two keys at once):

  • 19023: Go to Next Idle Villager
  • 19024: Go to Last Notification
  • 19068: Go to Next Idle Military Unit
  • 19026: Go to Town Center
  • 19153: Toggle Idle Pointers *

*: On the HKI format, the "Toggle Idle Pointers" hotkey also appeared twice even though it doesn't appear twice in the menus in game. This has been 'fixed' with the HKP format.

@lcp415123561421
Copy link

How to view and edit .hkp files?

@KSneijders
Copy link
Author

KSneijders commented Oct 27, 2023

@lcp415123561421 How to view and edit .hkp files?

I don't think there's an application currently that allows you to edit them.
I made this and the other gist to help people be able to easily upgrade existing applications 🙂

Edit: There now is a website to edit the newer hotkey format: https://hotkeyeditor.com/ (Which credits this file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment