Jump to content

Visual Pinball 9.9.1 / Exit problem


koenka

Recommended Posts

Posted

Hi everyone,

I really hope someone is able to help me with the following: I downloaded Visual Pinball 9.9.1 and put this inside of the emulators folder. XML for the wheel etc. is correctly set up. AHK that I use is the standard 2.0 AHK that's included with the most recent install of Hyperspin.

MEmu = Visual Pinball
MEmuV = v8.1.1 & v9.12
MURL = http://sourceforge.net/projects/vpinball/
MAuthor = djvj
MVersion = 2.0
MCRC = 6B81A939
iCRC = 80311E26
MID = 635038268932497719
MSystem = "Visual Pinball"
;----------------------------------------------------------------------------
; Notes:
; Requires VPinMame v2.4
; Download xpath from http://www.autohotkey.net/~Titan/dl/xpath.zip and extract the xpath.ahk into your Hyperspin directory
; xpath is needed because AutoHotKey does not natively support reading/writing of XML files
; If you want to use a picture while the table is loading, place it on the dir with this module and define the width & height and its filename in the variables below.
; You can also set the color of the background
; If you use Esc as your exit_emulator_key, set EscClose to true. The emu closes faster if you don't use Esc, and this value doesn't seem to matter if you use Win7
;
; VPinMame uses the registry to store configs @ HKEY_CURRENT_USER\Software\Freeware\Visual PinMame
; Each time a new table is ran, it pulls the default configs into a new folder in the registry
; Visual Pinball stores settings in the registry @ HKEY_USERS\S-1-5-21-440413192-1003725550-97281542-1001\Software\Visual Pinball
;
; Editing Visual Pinball.xml:
; If your database xml has exe tags to support vp8 and vp9, make sure all vp8 game's tags match the vp8tag variable set below.
; Open your database and find all exe> and replace with vpexe>
; This tag will be ignored by HS, but let the script load the appropriate emu for those tables.
; This is done so you don't need separate modules for vp8 and vp9
;----------------------------------------------------------------------------
StartModule()
FadeInStart()

settingsFile := modulePath . "\" . moduleName . ".ini"
EscClose := IniReadCheck(settingsFile, "Settings", "EscClose","false",,1) ; This fixes VP from crashing (in WinXP) on exit when using Esc as your exit key.
showDMD := IniReadCheck(settingsFile, "Settings", "showDMD","true",,1)
updateDefaultDMD := IniReadCheck(settingsFile, "Settings", "updateDefaultDMD","true",,1) ; Set this to true if you want the script to set the default position of the DMD on next run.
dmdX := IniReadCheck(settingsFile, "Settings", "dmdX","45",,1) ; Your new default X position of the DMD
dmdY := IniReadCheck(settingsFile, "Settings", "dmdY","35",,1) ; Your new default Y position of the DMD
dmdWidth := IniReadCheck(settingsFile, "Settings", "dmdWidth","300",,1) ; Your new default DMD Width
dmdHeight := IniReadCheck(settingsFile, "Settings", "dmdHeight","75",,1) ; Your new default DMD Height

7z(romPath, romName, romExtension, 7zExtractPath)

; Update default DMD position & size so when new tables are ran, they use the new defaults
If ( updateDefaultDMD  = "true" ) {
dmdXcur := ReadReg("dmd_pos_x")
dmdYcur := ReadReg("dmd_pos_y")
dmdWcur := ReadReg("dmd_width")
dmdHcur := ReadReg("dmd_height")
If ( dmdXcur != dmdX or dmdYcur != dmdY or dmdWcur != dmdWidth or dmdHcur != dmdHeight ) {
		WriteReg("dmd_pos_x",dmdX)
		WriteReg("dmd_pos_y",dmdY)
		WriteReg("dmd_width",dmdWidth)
		WriteReg("dmd_height",dmdHeight)
	}
}

Run(executable . " /exit /play -""" . romPath . "\" . romName . romExtension . """",emuPath, "Min") ; hide does not work

WinWait("Preparing Table AHK_class #32770")
WinWaitClose("Preparing Table AHK_class #32770",,4)
Sleep, 500

; script to look for Please answer window, selects Yes I am and hits enter to continue loading table
Loop {
Sleep 50
IfWinExist, Please ; Nag screen the first time a table is ran
{	WinActivate, Please
	IfWinActive, Please
	{	SetControlDelay -1
		ControlClick, Button2, Please answer AHK_class #32770 ; Click Yes I am
		ControlSend, Button1, {Enter}, Please answer AHK_class #32770 ; Click the OK button
	}
} Else ifWinExist, Game Info ; unknown window
{	WinActivate, Game Info
	IfWinActive, Game Info
	{	Send {Enter}
		Send {Enter}
	}
} Else ifWinExist, Notice ; sound not 100% acurate
{	WinActivate, Notice
	IfWinActive, Notice
	{	Send {Enter}
		Send {Enter}
	}
} Else ifWinExist, VBScript ; all msg boxes from vp script (like vb/vpm version not high enough...)
{	WinActivate, VBScript
	IfWinActive, VBScript
		Send {Enter}
} ;else ifWinExist, Error ; serious errors - like z buffer too small and so on
;		{
	; we have some error and we want to see it so we don't send Enter
	;Send {Enter}
;			Gui, Destroy
;			WinActivate, Error
;			WinWaitActive, Error
;			WinWaitClose, Error
;			WinClose, ahk_class VPinball
;			Process, WaitClose, %executable%
;			ExitModule()
;		}
IfWinExist, Visual Pinball Player,, DMD ;Check if visual pinball is Ready
	IfWinActive, Visual Pinball Player,, DMD ;Check if visual pinball is Ready
		Break
}

Sleep, 500
WinWait("ahk_Class VPPlayer")
Sleep, 500
Loop {
IfWinActive, ahk_class VPPlayer
	Break
WinActivate, ahk_class VPPlayer
Sleep, 50
}
WinWaitActive("ahk_class VPPlayer")
Sleep, 1000

; Give focus to the dmd so it appears on top of the playfield
If showDMD = true
{	DetectHiddenWindows, off ; don't detect dmd if it is hidden
WinActivate, ahk_class MAME
WinWaitActive("ahk_class MAME",,2)
ControlClick,, ahk_class MAME ; clicking the dmd to set the WS_EX_TOPMOST parameter (AlwaysOnTop)
DetectHiddenWindows on
WinActivate, ahk_class VPPlayer
WinWaitActive("ahk_class VPPlayer")
}

FadeInExit()
Process("WaitClose",executable)
7zCleanUp()
FadeOutExit()
ExitModule()


ReadReg(var1) {
RegRead, regValue, HKEY_CURRENT_USER, Software\Freeware\Visual PinMame\default, %var1%
Return %regValue%
}

WriteReg(var1, var2) {
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Freeware\Visual PinMame\default, %var1%, %var2%
}

CloseProcess:
FadeOutStart()
If escClose = true
{	DetectHiddenWindows, On ;Or next line will not work
	Sleep, 50
	;ControlSend, Button1, q, ahk_class #32770
	ControlSend, Button2, r, ahk_class #32770 ; in case q crashes VP, use this
}
; If ( exe = vp8tag ) { 
	; WinClose, ahk_class VPinball
; } Else {
	Sleep, 150
	WinHide, ahk_class VPinball ;This line fixes where the VP Window flashes real quick when closing the window for a cleaner exit
	WinMinimize, ahk_class VPinball
	WinClose("ahk_class VPinball")
; }
Return

Starting Visual Pinball from HyperLaunchHQ works fine. It loads through the 9.9.1 exe (editor loads in the background), foreground is the table itself. Setting for the escape button in the emulator itself is set to disabled. But the ESC action through hyperlaunch doesn't close visual pinball, it's actually not doing anything at all. I tried a lot of different things, also changing the AHK file inside the CloseProcess.

I'm running Windows 8.1. I also noticed that the VPin 9.9.1 is executed via elevated command. Might this be the issue? I'm really clueless, hope someone is able to help me.

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...