Page 1 of 1

Keyboard Shortcut for Closing Windows?

Posted: Thu Aug 02, 2018 1:29 pm
by Chimera533
I'm looking to map a button on my Steam Controller to close windows in the game. The best I can find is a guide for AutoHotKey. Since I can't post links, you can google this to find it:

How to create a hotkey to close in game screens and dialogues (AutoHotKey solution) + some other cool shortcuts

I'm not familiar with AutoHotKey but it looks like the script is doing a lot more than just remapping a key. Just wondering if there is a simple way to do this. If this is the only way I suppose I can just use this script then map my controller button to the button in the script.

RE: Keyboard Shortcut for Closing Windows?

Posted: Fri Aug 03, 2018 9:51 pm
by Chimera533
If anyone is interested, I could not find a shortcut to natively close in-game windows but the AutoHotKey script works a charm. I gave myself a crash course in AutoHotKey and bound the window close commands to a key combo that I'm pretty sure Distant Worlds doesn't use. Then I bound that key combo to my Steam Controller and it works without fail (so far).

RE: Keyboard Shortcut for Closing Windows?

Posted: Sat Aug 04, 2018 5:15 pm
by rxnnxs
I am interested in your AHK script.
I also did not like the ESC behaviour. I would like to close all open windows before going into optinos mode.
Now if you already have a AHK script that, lets say, lays all close windows commands to "Q", this would be fantastic!

RE: Keyboard Shortcut for Closing Windows?

Posted: Sat Aug 04, 2018 6:02 pm
by Chimera533
Here it is. It's just the same script from the guide that you can google but with different key bindings:

Code: Select all

 #IfWinActive, Distant Worlds
 #MaxThreads 1
 SendMode Event
 SetControlDelay, -1
 SetKeyDelay, 20
 SetMouseDelay, -1
 FirstTime:=True
 
 >^]::Suspend
 
 >^\::  ; Change XButton1 to Esc if you prefer standard UI feel keys
 	{
 	ControlClick, Close
 	;ControlClick, Cancel
 	ControlGet, isGoodbyeVis, Visible, , Goodbye
 	ControlGet, isNothanksVis, Visible, , No thanks
 	If isGoodbyeVis
 	{
 		ControlFocus, Goodbye
 		ControlSend, Goodbye, {Enter}
 	}
 	If isNothanksVis
 	{
 		ControlFocus, No thanks
 		ControlSend, No thanks, {Enter}
 	}
 	return
 	}
 


This binds RCTL+] to suspend the script and RCTL+\ to close windows. I haven't had a need to suspend the script but I kept the functionality just in case. If you want to use the Q key to close windows, you should just be able to replace this line:

Code: Select all

>^\::  ; Change XButton1 to Esc if you prefer standard UI feel keys

with this line:

Code: Select all

q::  ; Change XButton1 to Esc if you prefer standard UI feel keys
There are ways to launch the game from the AHK script and close the script after the game closes but don't ask me how. I basically just learned enough to get me going. I also use another program to change my desktop resolution before launching the game so I have a hacked together solution that calls a bunch of things from a batch file including this AHK script.