Jump to content
Sign in to follow this  
johnbla

Keystroke to minimize SLX

Recommended Posts

Hi Maarten

 

Do you know if it is possible to assign a keystroke to maximise and minimize SLX? What I would like to do is assign a keystroke to allow this and then map it to my yoke so that I can bring SLX up with a push of a button.

 

I am unsure if Windows will allow this.

 

Many thanks again for a wonderful programme.

 

John

Share this post


Link to post
Share on other sites

Hi John,

 

I cannot include it within SLX itself, because keystrokes go to the active window only. The best thing to do is to download and install the AutoHotkey windows scripting tool and then create a new script (just a plain text file with a .ahk extenstion) that looks like this:

#NoEnv

SetTitleMatchMode, 1
DetectHiddenWindows, On
#F10::
	IfWinNotExist, SimLauncherX
		return
	ActiveHwnd := WinExist("A")
	WinActivate, SimLauncherX
	WinGet, MinMax, MinMax, SimLauncherX
	if (MinMax > -1) {
		PostMessage, 0x112, 0xF020,,, SimLauncherX
	} else {
		PostMessage, 0x112, 0xF120,,, SimLauncherX
	}
	WinActivate, ahk_id %ActiveHwnd%
return

In this example the Windows key + F10 is used as a shortcut key: # is used for the Windows key, ! for Alt, ^ for Ctrl, + for Shift. Map the shortcut key to one of your joystick buttons and your done.

 

The script toggles the SLX window between minimized and restored. If you want to toggle between minimized and maximized, you first need to maximize the SLX window manually. After you have installed AutoHotkey and created the script, double click on the .ahk script file to run it; if you like you can include a shortcut to the script file in your %ProgramData%\Microsoft\Windows\Start Menu\Programs\StartUp folder, so the script starts when you start Windows.

 

If you want to activate the SLX window after it's restored, put a semicolon in front of the 'WinActivate, ahk_id %ActiveHwnd%' line.
 

 

hope this helps,

 

Maarten


Maarten Boelens ([m][a:][R][t][ʏ][n])
Developer of SimLauncherX

ftx_supporter_avsim.gifC172Siggy1_zps11944daf.jpg

Share this post


Link to post
Share on other sites

Maarten

 

Many thanks. I got it going by pasting your text into notepad and saving it as an ahk file to minimize SLX, but when I hit Win F10 again to restore it, it flashes on the screen for a millisecond and then goes away again. Any ideas on what I am doing wrong?

 

Here is my ahk file:

 

#NoEnv
 
SetTitleMatchMode, 1
DetectHiddenWindows, On
#F10::
IfWinNotExist, SimLauncherX
return
ActiveHwnd := WinExist("A")
WinActivate, SimLauncherX
WinGet, MinMax, MinMax, SimLauncherX
if (MinMax > -1) {
PostMessage, 0x112, 0xF020,,, SimLauncherX
} else {
PostMessage, 0x112, 0xF120,,, SimLauncherX
}
WinActivate, ahk_id %ActiveHwnd%
return

 

 

Best regards

John 

Share this post


Link to post
Share on other sites

Hi John,

 

As I said: "If you want to activate the SLX window after it's restored, put a semicolon in front of the 'WinActivate, ahk_id %ActiveHwnd%' line."

 

thanks, Maarten


Maarten Boelens ([m][a:][R][t][ʏ][n])
Developer of SimLauncherX

ftx_supporter_avsim.gifC172Siggy1_zps11944daf.jpg

Share this post


Link to post
Share on other sites

Hi John,

 

As I said: "If you want to activate the SLX window after it's restored, put a semicolon in front of the 'WinActivate, ahk_id %ActiveHwnd%' line."

 

thanks, Maarten

 

Maarten

 

I did that and I still have the same problem. Sorry to be a pain, but I feel I am nearly there.

 

Here is my ahk file with the semicolon in. When I restore, it still flashes on the screen for a millisecond.

 

#NoEnv
 
SetTitleMatchMode, 1
DetectHiddenWindows, On
#F10::
IfWinNotExist, SimLauncherX
return
ActiveHwnd := WinExist("A")
WinActivate, SimLauncherX
WinGet, MinMax, MinMax, SimLauncherX
if (MinMax > -1) {
PostMessage, 0x112, 0xF020,,, SimLauncherX
} else {
PostMessage, 0x112, 0xF120,,, SimLauncherX
}
;WinActivate, ahk_id %ActiveHwnd%
return
 
 
Regards
John

Share this post


Link to post
Share on other sites

Hi John,

 

Something is stealing keyboard focus. What is the active window after you pressed the key combination?

 

thanks, Maarten


Maarten Boelens ([m][a:][R][t][ʏ][n])
Developer of SimLauncherX

ftx_supporter_avsim.gifC172Siggy1_zps11944daf.jpg

Share this post


Link to post
Share on other sites

Hi John,

 

Something is stealing keyboard focus. What is the active window after you pressed the key combination?

 

thanks, Maarten

 

 

Hi Maarten

 

The only thing I have running is SLX.

 

I press Win F10 and SLX minimizes to the taskbar. When I press Win F10 again, SLX stays on the screen for a millisecond before it disappears to the taskbar. I have tried using Alt F10 with the same result.

 

As I said, SLX is the only programme I have running. Do you think there could be a problem with my script? It is the same as above.

 

I appreciate the help you are giving me.

 

Regards

John

Share this post


Link to post
Share on other sites

Hi John,

 

It seems like the shortcut key is registered twice. Can you modify the script to look like this:

#NoEnv

SetTitleMatchMode, 1
DetectHiddenWindows, On
#F10::
	IfWinNotExist, SimLauncherX
		return
	if (A_TimeSincePriorHotkey > -1 and A_TimeSincePriorHotkey < 500)
		return
	ActiveHwnd := WinExist("A")
	WinActivate, SimLauncherX
	WinGet, MinMax, MinMax, SimLauncherX
	if (MinMax > -1) {
		PostMessage, 0x112, 0xF020,,, SimLauncherX
	} else {
		PostMessage, 0x112, 0xF120,,, SimLauncherX
	}
	;WinActivate, ahk_id %ActiveHwnd%
return

If that doesn't work, what's the name of your script file? 


Maarten Boelens ([m][a:][R][t][ʏ][n])
Developer of SimLauncherX

ftx_supporter_avsim.gifC172Siggy1_zps11944daf.jpg

Share this post


Link to post
Share on other sites

Hi Maarten

 

The new script is acting as before, only comes on for a millisecond. I have named it SLX hotkey.ahk

 

I am trying to upload it for you but there doesn't seem to be any options for that.

 

John

Share this post


Link to post
Share on other sites

Hi John,

 

Unfortunately I've run out of ideas. On my machine (Windows 8.1) the script runs perfectly fine and i don't know how I can be of any further help. If I think of something, I will let you know. 

 

thanks, Maarten


Maarten Boelens ([m][a:][R][t][ʏ][n])
Developer of SimLauncherX

ftx_supporter_avsim.gifC172Siggy1_zps11944daf.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...