[MOD] Simple Hotkeys

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
ChemODun
Posts: 634
Joined: Mon, 12. Feb 07, 21:58
x4

[MOD] Simple Hotkeys

Post by ChemODun »

Simple Hotkeys

A small, growing collection of simple hotkey actions for X4: Foundations, built on top of the Native Hotkey API - every action below is bindable by the player through the native game keybinding UI, just like a vanilla control.

Image

Overview

This mod doesn't add any UI of its own. It registers a set of small, focused actions with the Native Hotkey API, which then exposes them on its own Hotkey Management > Hotkey Bindings page (under Options), where the player assigns the actual physical key through the same native remap UI (and conflict-detection) every other control uses.

Most actions only fire while the player is actually piloting their own ship (no menu open); a couple are map-only instead - see each action's description below for where it applies.

Requirements
  • X4: Foundations: Version 9.00 or higher.
  • Native Hotkey API by Chem O`Dun, version 8.00.01 or higher:
  • Indirectly depends on the UI Extensions and HUD mod by kuertee, which is a dependency of the Native Hotkey API:
Installation Hotkey Actions

All of the actions below show up automatically on the Native Hotkey API's Hotkey Bindings page once this mod is enabled - there is nothing to configure here, just assign a key to whichever ones you want to use.
Spoiler
Show
Image
  • Rename Selected/Targeted Object - opens the vanilla rename popup for the selected (map) or targeted (piloting) object, if it's player-owned.
  • Follow Target - engages autopilot to the current target (which tracks a moving target, i.e. "follow"); pressed again on the same target, it disengages autopilot instead.
  • Eject Illegal Wares - drops all illegal cargo from the ship's hold and the player's own inventory, based on the local sector's police faction.
  • Print Combined Skill of Target - shows a notification with the combined skill of the current target's crew.
  • Zoom In (Flight Mode) - piloting only: steps the camera FOV through increasing zoom factors (1x -> 2x -> 4x -> 8x) on repeated presses; pressing again once at the highest factor resets straight back to the FOV that was active before zooming started.
  • Launch Satellite / Launch Advanced Satellite - launches a satellite or advanced satellite, if one is carried.
  • Launch Laser Tower Mk1 / Mk2 - launches a laser tower of the chosen mark, if one is carried.
  • Launch Mine / Launch Tracker Mine / Launch Friend-or-Foe Mine - launches the chosen mine type, if one is carried.
  • Toggle Right Info Panel - map only: toggles the map's right-side info panel for the current selection, mirroring the existing sidebar icon (there's no vanilla hotkey for either side's info panel, only mouse clicks).
Please not forget - you can disable any of these actions in appropriate Hotkey Requests section of the Native Hotkey API's menu, if you don't want to use them.
Spoiler
Show
Image
Credits Acknowledgements
  • EGOSOFT - for the X series.
  • kuertee - for the UI Extensions and HUD that the Native Hotkey API (and therefore this mod) relies on.
Last edited by ChemODun on Wed, 1. Jul 26, 07:52, edited 2 times in total.
Multiply entropy by absolute zero

Freedom in space
User avatar
ChemODun
Posts: 634
Joined: Mon, 12. Feb 07, 21:58
x4

Re: [Mod] Simple Hotkeys

Post by ChemODun »

Changelog

[1.02] - 2026-06-30
  • Added
    • Toggle Right Info Panel (map only) - no vanilla hotkey exists for either side's info panel, only mouse clicks.
  • Removed
    • Launch Navigation Beacon / Launch Resource Probe - vanilla already has native hotkeys for these (Deploy Navigation Beacon / Deploy Resource Probe).
  • Changed
    • Renamed Zoom In to Zoom In (Flight Mode) to make clear it only works while piloting.
[1.01] - 2026-06-28
  • Fixed
    • Minor bug fixes and improvements.
[1.00] - 2026-06-24
  • Added
    • Initial version: rename selected/targeted object, follow target, eject illegal wares, print combined skill of target, zoom in/reset, and the full deployable launch family (satellites, navigation beacon, resource probe, laser towers, mines).
Last edited by ChemODun on Wed, 1. Jul 26, 07:52, edited 1 time in total.
Multiply entropy by absolute zero

Freedom in space
azaghal
Posts: 438
Joined: Wed, 21. Mar 07, 13:19
xr

Re: [MOD] Simple Hotkeys

Post by azaghal »

A rename hotkey in X4... Now I have seen everything... Does this mean I can finally get rid of this atrocity? :)

Code: Select all

#!/bin/bash

offset_x=600
offset_y=200

window_id=$(xdotool search --class x4)

original_position=$(xdotool getmouselocation --shell)

original_x=$(echo "$original_position" | grep "^X=" | sed -e 's/X=//')
original_y=$(echo "$original_position" | grep "^Y=" | sed -e 's/Y=//')

xdotool \
    search --class X4 windowactivate --sync \
    mousemove --sync "$offset_x" "$offset_y" \
    key Ctrl+Return sleep 0.1

box=( $(flameshot screen --region "300x540+${offset_x}+${offset_y}" --raw | tesseract - - hocr | grep Rename | head -n1 | grep -o "bbox[^;]*") )

left="${box[1]}"
top="${box[2]}"
right="${box[3]}"
bottom="${box[4]}"

number_regex='^[0-9]+$'

if [[ $left =~ $number_regex && $top =~ $number_regex && $right =~ $number_regex && $bottom =~ $number_regex ]]; then
    (( pos_x = offset_x + left + (right - left) / 2 ))
    (( pos_y = offset_y + top + (bottom - top) / 2 ))
    xdotool \
        search --class X4 \
        mousemove --sync "$pos_x" "$pos_y" sleep 0.2 \
        key Return sleep 0.1 \
        key Home key --repeat 11 Right sleep 0.1
fi

xdotool search --class X4 mousemove "$original_x" "$original_y"
Thank you :)
User avatar
ChemODun
Posts: 634
Joined: Mon, 12. Feb 07, 21:58
x4

Re: [MOD] Simple Hotkeys

Post by ChemODun »

Enjoy!
Multiply entropy by absolute zero

Freedom in space
User avatar
ChemODun
Posts: 634
Joined: Mon, 12. Feb 07, 21:58
x4

Re: [MOD] Simple Hotkeys

Post by ChemODun »

[1.02] - 2026-06-30
  • Added
    • Toggle Right Info Panel (map only) - no vanilla hotkey exists for either side's info panel, only mouse clicks.
  • Removed
    • Launch Navigation Beacon / Launch Resource Probe - vanilla already has native hotkeys for these (Deploy Navigation Beacon / Deploy Resource Probe).
  • Changed
    • Renamed Zoom In to Zoom In (Flight Mode) to make clear it only works while piloting.
Multiply entropy by absolute zero

Freedom in space
User avatar
beko
Posts: 95
Joined: Thu, 11. Jun 20, 21:14
x4

Re: [MOD] Simple Hotkeys

Post by beko »

azaghal wrote: Tue, 30. Jun 26, 23:12 A rename hotkey in X4... Now I have seen everything... Does this mean I can finally get rid of this atrocity? :)
Haha tesseract, awesome :D I'm not the only crazy who used this before to automate some gaming bit: https://beko.famkos.net/2022/12/09/surv ... singworld/ 🤓

Sorry for OT :D

Return to “X4: Foundations - Scripts and Modding”