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

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

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

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? 

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...