[Request] Context Menu Removed from opening via right click while in space only.

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

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

Post Reply
User avatar
StoneLegionYT
Posts: 1428
Joined: Fri, 4. Nov 05, 01:18
x4

[Request] Context Menu Removed from opening via right click while in space only.

Post by StoneLegionYT » Sat, 1. Dec 18, 17:22

Right now I have my gun bound to my Right Mouse button to fire... But sadly it also spams the context menu. But I don't want to lose it via the map, etc... Just while piloting my ship.

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13299
Joined: Sun, 15. Feb 04, 20:12
x4

Re: [Request] Context Menu Removed from opening via right click while in space only.

Post by euclid » Sat, 1. Dec 18, 18:05

Hi Kane Hart :-)

I'm with you on that one and we are not alone. I've set "Fire on Target" to the MMB and the RMB has now only "Target nearest Enemy". Still quite irritating if in the middle of a battle the context menu pops up. But this is the best setting I could find.

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

nemo1887
Posts: 300
Joined: Sat, 15. Dec 18, 08:40
x4

Re: [Request] Context Menu Removed from opening via right click while in space only.

Post by nemo1887 » Tue, 29. Jan 19, 19:52

patch 1.60 " Removed ability to map right mouse button to avoid conflicts with context menu function."



fire right mouse button !!!!!!!!!!!,no contextmenu in space!!

Cg089
Posts: 80
Joined: Fri, 18. Jan 19, 19:25
x4

Re: [Request] Context Menu Removed from opening via right click while in space only.

Post by Cg089 » Wed, 30. Jan 19, 04:16

I posted this in a thread talking about this exact issue in the beta forum earlier, but there are two workarounds I know of. First one, and I don't know if this is a peculiarity of my input setup somehow, or is just undocumented, is that LMB + RMB fires at the cursor position. The second, which will remove context menu from opening via right click ever (there's a keybinding), is as follows:
Cg089 wrote:
Wed, 30. Jan 19, 03:39
Hey guys, sorry I'm late to the party. I'm a friendly computer science student when I'm not gaming lol. I feel your pain, and it sounds like this is on the developer's priority list, but not very high on it, and that sucks, even if their prioritization makes sense. Fortunately, this has been a problem enough times that tools exist to fix it without having to wait for developers. Sometimes you want to rebind things for games that are old and are never going to be updated, or you don't want to wait for the patch, or you want to write some complicated macros to do complicated things (like video editing, for example) faster. So people have written tools to rebind keys and other input, essentially intercepting certain events from your keyboard and mouse, and swapping them for different events. Like a cool spy movie heist, only cooler. I know that sounds a bit complicated, but it's actually really easy to do. Literally all you have to do is install a program, create a text file, and click on it. If you managed to install X4 without that level of knowledge... I'd honestly be impressed.
The main tool for doing this on Windows is an open source tool known as AutoHotKey: autohotkey.com. I will happily try to write scripts for you guys since I know not everyone has programming experience (also because I can use them too :P ). AutoHotKey is pretty easy to pick up, but it's also kind of a mess. But it generally works quite well.
Here's the guide to installing it and then making a script to do something: https://autohotkey.com/docs/Tutorial.htm#s1. I'll provide the contents of the file, with line by line breakdowns of what the script does.

The overall result of the below script is that when the script is running and X4 is the current window, right-click becomes F12 keypresses. We can then tell the game to bind anything we want to F12, and it will never know that right-click was pressed in the first place. Instead, it'll think you pressed F12, and thus, whatever action we want to bind it to will be triggered, and the context menu will not.

Code: Select all

 ; Anything after a space followed by a ; is a comment and is ignored by AutoHotKey
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
#SingleInstance Force ; Stop any already running copies of this script to prevent craziness
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability Specifies exactly how it sends inputs
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory. Doesn't matter here, but good form
#IfWinActive ahk_exe X4.exe ; Only apply the rebind when we have X4.exe as the front window. Keeps your rightclick working normally in your browser etc.
RButton::F12 ; Rebind Right Click so that the game receives F12 instead of the right click. F12 could be any key, it just happened to be one I and hopefully most of you as well aren't using in X4 at the moment. So long as you change the in-game binding for the action you want right click to trigger, it should be fine
You'll also need to tweak some controls in game to make things stink less.
In my case, I changed the following controls in game:
General/Weapons/Fire primary weapons at cursor: F12 (Alternatively, if there was something else you wanted to bind right-click to, you'd set that to use F12. E.g. if you want it to to fire straight ahead, bind "Fire primary weapons" to F12 instead of binding "Fire primary weapons at cursor" to F12.)
General/Menu Access/Interaction menu: Ctrl+Enter (Chosen to be the same as the default locked binding for Menu Navigation/Menus - Digital/Menu - Open Context Menu, which is the same thing, but for map view. Alternatively, you may be able to set the secondary binding for this to whatever other combination you chose to bind the cockpit view interaction menu to).
So, if you follow that guide I linked using the script above, change the controls as described above, and remember to double click on the file you made to launch the script if it's not already running, rightclick will fire and not trigger the context menu. Don't worry about launching the script too many times - it'll kill any copies that are already running before it starts.
<snip>
I think the above workaround, while far less elegant than the developers actually fixing it, might hold you guys over until they have a chance :) . If you run into problems/need help figuring out how to extend it to do something slightly more complicated, please let me know, I'm happy to help. And the weather is so awful here that my college cancelled class tomorrow, so I actually have time to help for once.
Hope this post helps someone.

Post Reply

Return to “X4: Foundations - Scripts and Modding”