Jump to content

Launching KSP with -popupwindow at a specified position


Recommended Posts

  • 1 month later...
So, i have added -popupwindow to my KSP-Link to make KSP run in a frameless windowed mode. Is there a way to specify the window position? Currently, KSP opens always centered on my screen (which i would like to change)

I'd also like to find out about this. It seems there must be something simple, but I can't think what.

Link to comment
Share on other sites

I've created a little AutoHotKey script that does the following:

  1. Launches KSP with -popupwindow.
  2. Moves the resulting KSP window to the top-left of the desktop
  3. And minimizes KSP when it's inactive.
  4. It also includes a HotKey for ultra-fine mouse movements - very handy when editing ships in the VAB and SPH.

If anyone wants to use this, but doesn't want to install AutoHotKey, I'll put a stand-alone executable version on my site (siggy).

;; Ezriilc's KSP AutoHotKey script.

;; To engage fine mouse movements, press the Mouse4/Thumb1/Back button while holding CTRL; release CTRL to disengage.
;; WARNING! This temporarily changes your Windows mouse settings.
;; If for some reason it crashes, you may need to set it back in the Control Panel.

#SingleInstance force
#Persistent
SendMode InputThenPlay
#UseHook

KSP_path := "C:\MyDocs\Games\Kerbal Space Program\ksp-win-0-21-1"
win_title := "Kerbal Space Program ahk_class UnityWndClass"

IfWinNotExist, %win_title%
{
Run, "%KSP_path%\KSP.exe" -popupwindow, "%KSP_path%"
}

WinWait, %win_title%,, 30
DllCall("SystemParametersInfo", UInt, 0x70, UInt, 0, UIntP, RatSpeedOrig, UInt, 0)
;; Set RatSpeedOrig to existing mouse speed from Windows (0x70 gets, 0x71 sets).
RatSpeedRetard = 1
IfWinActive, %win_title%
{
WinMove, %win_title%,, 0, 0
SetTimer KSP_active, -1
}else{
SetTimer KSP_inactive, -1
}
SetTimer StartAnnounce, -1


Return ;;;;;;;;;;;;;;;;;;; End of auto-execute ;;;;;;;;;;;;;;;;;;;

KSP_active:
WinWait, %win_title%,, 30
WinRestore, %win_title%
WinMove, %win_title%,, 0, 0
WinWaitNotActive, %win_title%
Goto KSP_inactive
Return
KSP_inactive:
IfWinNotExist, %win_title%
ExitApp
WinWait, %win_title%,, 30
WinMinimize, %win_title%
WinWaitActive, %win_title%
Goto KSP_active
Return

StartAnnounce:
note_start = 37 ;; Min: 37
note_stop = 5000 ;; Max: 32767 (don't)
note_step = 200
note_length = 3
note_span := note_stop - note_start
if(note_span < 0){
note_span -= note_span * 2
}
note_count := note_span / note_step

GoSub UpSound
GoSub DownSound
; GoSub UpSound
TrayTip Ezriilc's Smart Rat's got it goin' on!, CTRL + Back Thumb = Fine mouse control. `n Back Thumb only = Shift., 15
Return
UpSound:
note_curr := note_start
Loop % note_count{
SoundBeep note_curr, note_length
note_curr += note_step
}
Return
DownSound:
note_curr := note_stop
Loop % note_count{
SoundBeep note_curr, note_length
note_curr -= note_step
}
Return
TicSound:
SoundBeep 840, 5
Sleep 100
SoundBeep 840, 5
Return

#If WinActive(win_title)
~*XButton1:: ;; Back thumb button.
GetKeyState, CTRL_state, Control, P
if(CTRL_state = "D"){
DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, Ptr, RatSpeedRetard, UInt, 0)
GoSub UpSound
SetTimer UpSound, -1
SetTimer TicSound, 2000
KeyWait Control
DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, Ptr, RatSpeedOrig, UInt, 0)
SetTimer TicSound, Off
GoSub DownSound
SetTimer DownSound, -1
}else{
DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, Ptr, RatSpeedOrig, UInt, 0)
Send {Shift Down}
SetTimer UpSound, -1
SetTimer TicSound, 2000
KeyWait XButton1
Send {Shift Up}
SetTimer TicSound, Off
SetTimer DownSound, -1
}
Return

#If WinActive("ahk_class Notepad++")
~^s::
Reload
Return

Edited by Ezriilc
typo in code
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

×
×
  • Create New...