Jump to content

FPLaunch MOD: Pause and Loading screens...


samwyze

Recommended Posts

I have the same problem as gwjrabbit in post #275. When I exit VP with FPLaunch v1.295, my DMD and UltraVP don't exit properly when mapping exitEmulatorKey to Joy8 or E in the Settings.ini file. This worked properly in v1.20. I have bring up a task bar, and kill the processes off. I get the same behavior in either HyperPin or directly in VP.

I'm running VP v9.1.2, UltraVP 6.0.8, and FPLaunch v1.295 with a nanotech controller/plunger.

Any ideas?

When you run VP without HP, how does exit key on pinball wizard work -

a) you have to press it for 3 seconds and then table exits

or

B) table exits as soon as you press exit key?

And when you exit do you go to vp editor or you exit all the way out to windows (by the way is it win7 or xp)?

And when you do this without hp, uvp stays running, right?

So if it is a) you exit only after 3 seconds then it means you can exit clean with short press on exit and then 1 or enter, and you get uvp crash only when you hold esc for exit321 screen? Then you could tune exit process so it is quicker with parameter fadespeed. Fadespeed is sleep time in miliseconds, after 100 fadespeed sleeps you exit the table, default is 25, x100 = ~2500 miliseconds, together with time spent on calculations it could be more then 3 seconds so vp exits before i have a chance to kill it my self.

So if you put fadesleep to ~5 - ~10 you will exit in ~half a second before vp gets exit signal, so i will be able to close it my way (which is by closing editor window which is more clean way).

If it is B) you are exiting right away as soon as you press exit key then you have to change it in PBW configuration or in VP configuration. There should be some util to config this for pbw. So your configuration has to be such that when you play in VP without hyperpin in the background you CAN'T EXIT with exit key. When you do that you can configure exitemulatorkey and start testing with HP and fplaunch, and it should work with "joy8" or "e", both is ok.

Same thing is with fp, you must not configure fp so that joy8 exits. You must remove joy8 as exit key from fp configuration.

All this problems come from two major limitations of ahk, ahk can't stop joystick buttons and it can't send joystick buttons. And pinball wizard actually sends joy8 button and some software like joy2key translates it to esc, and no ahk script can stop it, so you have to config it different in pbw and vp and fp first.

Link to comment
Share on other sites

i tried today on a cab with full hd lcd

i did not see any drop during the game (after pressing esc), but there is a drop regarding running vp without hp

first fp is on start, second is after starting game an keepin the ball in the plunger

Without hp:

afm 1100 900

panthera 1400 800

with hp and new fplaunch:

afm 600 630

panthera 700 650

hp, new fplaunch, all false:

afm 600 850

panthera 700 730

only hp running in back, no any fplaunch running, vp is started manualy

afm 700 870

panthera 1000 800

so it looks like fplaunch takes some fps, and hp takes only few fps

will have to try 1.0 version also to see what can be done to minimize fps loss

Hey blur. I had a little play with the fps that are lost once a graphic has been displayed and managed to fix it. *It was quite a lot of experimenting but this is what worked in the end:

(1) in the method that creates the loading graphic do a destroy

at the end. No fps is lost after loading a table.

(2) changed the create loading screen sub-routine to only create one image for the one requested by the caller. *Before doing so it destroys the previous graphic.

(3) in the loop that displays the 3 loading images I replaced each of the 'GUI n show' statements to instead call the sub-routine to create the loading image for the given parameter.

With these changes no FPS is lost despite how many time the Pause/Editing window is launched for one table. The whole thing is quite odd as it only affects some tables.

I do get some flicker with the 321 countdown but it is ok. The whole thing seems to relate to garbage collection but where you garbage collect appears to be important. You mat find a cleaner solution but just wanted to share my findings with you. I am not at home now, but if you want my sample script them please pm me and i will send it over to you experiment with. Cheers

Excuse the typos - typed on a iPod touch :)

Edited by settingsons
Tidied up and corrections
Link to comment
Share on other sites

When you run VP without HP, how does exit key on pinball wizard work -

a) you have to press it for 3 seconds and then table exits

or

B) table exits as soon as you press exit key?

And when you exit do you go to vp editor or you exit all the way out to windows (by the way is it win7 or xp)?

And when you do this without hp, uvp stays running, right?

So if it is a) you exit only after 3 seconds then it means you can exit clean with short press on exit and then 1 or enter, and you get uvp crash only when you hold esc for exit321 screen? Then you could tune exit process so it is quicker with parameter fadespeed. Fadespeed is sleep time in miliseconds, after 100 fadespeed sleeps you exit the table, default is 25, x100 = ~2500 miliseconds, together with time spent on calculations it could be more then 3 seconds so vp exits before i have a chance to kill it my self.

So if you put fadesleep to ~5 - ~10 you will exit in ~half a second before vp gets exit signal, so i will be able to close it my way (which is by closing editor window which is more clean way).

If it is B) you are exiting right away as soon as you press exit key then you have to change it in PBW configuration or in VP configuration. There should be some util to config this for pbw. So your configuration has to be such that when you play in VP without hyperpin in the background you CAN'T EXIT with exit key. When you do that you can configure exitemulatorkey and start testing with HP and fplaunch, and it should work with "joy8" or "e", both is ok.

Same thing is with fp, you must not configure fp so that joy8 exits. You must remove joy8 as exit key from fp configuration.

All this problems come from two major limitations of ahk, ahk can't stop joystick buttons and it can't send joystick buttons. And pinball wizard actually sends joy8 button and some software like joy2key translates it to esc, and no ahk script can stop it, so you have to config it different in pbw and vp and fp first.

A - VP exits after about 3 seconds of holding the Joy8 button.

When it exits, VP completely exits (dies?), and all I'm left with is the UVP and DMD.

I'm running Vista (ick) Home Premium SP2. I was too cheap to upgrade it to 7, and too lazy to pull out my old XP Pro CD and reimage the box. Now I've got too many tables configured to want to start all over again.

From HP, if I tap the exit button, then press 1 or Enter, the game does exit cleanly. However, all I have is the "joystick" keys, so that doesn't help much, but maybe helps explain what's happening to you.

I tried messing with the fadesleep values. I tried 1, 5, 10, 25, 35, 100, and didn't see any difference.

I've seen many others say they're happy with the ipac controller. Should I just bite the bullet and drop the $40 and get a controller and map my buttons with it? With as many hours as I've spent on this, maybe dropping $40 is the easy way out. I'd still use the nanotech controller for tilting and plunger control, but would I avoid these issues by using the ipac for my buttons?

MikeN

Link to comment
Share on other sites

you must have same resolution in vp, fp and in windows.

if they are not loading screen goes to the side.

Turns out it's not the resolution of the monitors - that was set correctly.

It's just that the Windows 7 taskbar on the main screen clip region somehow also through the load screen window, even though it's not actually drawn. It just masks it.

I moved the taskbar to the second monitor and now the entire load graphic is shown.

Link to comment
Share on other sites

Turns out it's not the resolution of the monitors - that was set correctly.

It's just that the Windows 7 taskbar on the main screen clip region somehow also through the load screen window, even though it's not actually drawn. It just masks it.

I moved the taskbar to the second monitor and now the entire load graphic is shown.

great, glad you solved it!

Link to comment
Share on other sites

A - VP exits after about 3 seconds of holding the Joy8 button.

When it exits, VP completely exits (dies?), and all I'm left with is the UVP and DMD.

From HP, if I tap the exit button, then press 1 or Enter, the game does exit cleanly. However, all I have is the "joystick" keys, so that doesn't help much, but maybe helps explain what's happening to you.

I tried messing with the fadesleep values. I tried 1, 5, 10, 25, 35, 100, and didn't see any difference.

Many people work happily with PBW so i see no reason to buy ipac.

For fadespeed value you should see slower or quicker change of exit 321 screens - you don't see it? maybe sleep doesn't work on vista? You did change fadespeed line in settings.ini?

You can find this part of code:

            if (loopVal = [b]10[/b]) {
               if (Paused = 1) {
                   if (systemName = "Future Pinball")
                       GoSub PauseFP
                   else
                       GoSub PauseVP
               }
               Gosub CreateExitScreen
               if (systemName = "Future Pinball")
                   GoSub CreateBlackScreen
               Gui, 3:Show
           } else if loopVal = [b]40[/b]
               Gui, 2:Show
           else if loopVal = [b]70[/b]
               Gui, 1:Show
           Sleep,  %fadespeed%
           if (loopVal = [b]100[/b]) {
               if (systemName = "Visual Pinball")
                   GoSub, CloseVP
               else if (systemName = "Future Pinball")
                   GoSub, CloseFP
               break
           }

and change bolded numbers (number of loops before exit) to 5, 10 15, 20 or 10, 20 30 40, and recompile ahk. Then you should be able to exit before VP gets exit key.

For "esc" "1" and "enter" keys - they are all configurable with lines:

exitEmulatorKey= Esc

exitEmulatorKey2= 1

exitEmulatorKey3= Enter

in settings.ini.

Just change them to any button like:

exitEmulatorKey= Joy8

exitEmulatorKey2= Joy7

exitEmulatorKey3= Joy6

The idea is to use start (1) and plunger (enter) buttons from your cab ie from your PBW so check what is button number for start and plunger and set them.

Edited by blur
Link to comment
Share on other sites

Ok, I think I may have found a possible bug. I'm only running HP on a single screen, so I have the playfield and DMD showing. Running the original 1.1 FPLaunch my DMD shows on top of the table. Tried 1.13 since that is the first MOD and it shows up on the table. I then upgraded to 1.294, and now my DMD blinks for a second, and then disappears behind the table when the table loads. Alt-Tabbing brings it back to the front. But, once I click to focus the playfield again it disappears. I then upgraded to 1.295wip2, and it still has the same issue.

So I put my original FPLaunch and settings.ini file back in and it shows correctly. I've been trying to figure out what it was for almost a week now. But, I'm pretty sure it's FPLaunch MOD doing it. I'm thinking it has to do with the new graphics files showing on screen, since the 1.294 is when the issue arose. I tried setting the useLoadScreen to false, but it still happens.

Recap:

1.1 - DMD shown on playfield.

1.13 - DMD shown on playfield.

1.294 - DMD blinks then disappears behind table.

1.295 wip2 - DMD blinks then disappears behind table.

Edited by HyphyCus
Link to comment
Share on other sites

you're welcome :)

hyphy i know for this problem - it works on two screens but not on one

problem is that i added:

winactivate backglass (uvp backglass),

winactivate dmd,

winactivate playfield

after start of every table

this is done to make dmd appear in front of backglass, and it works fine if dmd is on backglass window

if it is on playfield it stays under the playfield

probably it's better not to touch anything and leave to vp and uvp to open windows in order they like

you can remove all this commands and recompile, here is how it should look after commenting these lines:

    WinWaitActive, ahk_class VPPlayer ;Wait for vp to be Ready before killing Gui blackScreen
   ;WinActivate, ahk_class TBackglass
   ;WinActivate, ahk_class MAME
   ;WinActivate, ahk_class VPPlayer
   Gui, Destroy
   Process, WaitClose, %executable%

i also find it better this way cause often some table puts dmd on playfield and then you don't see it, and you have to do alt-tab

i don't know how it will work for people that get backglass cover dmd, but for me it's better without these commands, maybe i will remove them in next release

proper way as you all know from your own experience with vp would be to activate dmd (alt-tab) and then click on dmd and then click on playfield, that makes dmd stay over the table, but i did not find a way to click in a window, only in coordinate and i don't know the coordinates where dmd would be

maybe it is doable with some ahk scripting

usually setting vpinball.exe to nt 4.0 sp5 compatibility mode solves this problem with dmd - but those commands still have to be removed cause they are not needed then.

Edited by blur
Link to comment
Share on other sites

WinWaitActive, ahk_class VPPlayer ;Wait for vp to be Ready before killing Gui blackScreen
;WinActivate, ahk_class TBackglass
;WinActivate, ahk_class MAME
;WinActivate, ahk_class VPPlayer
   Gui, Destroy
Process, WaitClose, %executable%

I commented those out as shown above (hopefully it's correct), and recompiled and it still does it. I had my VPinball.exe already at NT4 compatibility so I didn't need to change that. Just for reference I'm on VP912 and Win7x64.

Link to comment
Share on other sites

Correct. It blinks once, and then disappears. My DMD is shown when I run it in VP. It's weird because Ill bring it back to the front by alt-tabbing, but when I click back to the playfield to play the table it pushes it back again.

Link to comment
Share on other sites

If it blinks you did not removed winactivate from the right place.

What version did you edit?

It's easier with 295 wip 2, you just search for this comment

;Wait for vp to be Ready before killing Gui blackScreen

and comment lines after that

in 294 you have to comment win activate on several places

to solve the problem in game - you alt-tab to dmd, then click on dmd, then click on playfield - try it, it should bring dmd in front and give focus to vp

Link to comment
Share on other sites

I edited 1.295wip2. And I did the correct lines as I listed in the code 2 posts above. That was copied from my ahk. I did compile too. Doing the quick solve as you suggest always brings the focus back to the playfield and hides the DMD.

EDIT: Ok, I deleted the nvram of a few tables, then reran the games and now they show up. I don't know what happened there, but they seem to show up now. I had a clean install of VPinball and HP I was testing this on, so something saved weird. But, the new code seems to work now. Thanks for the help! I couldn't use HP without the load screens, they are awesome!

Edited by HyphyCus
Link to comment
Share on other sites

here is the new version 1.295 wip 3

download from megaupload:

http://www.megaupload.com/?d=HR79NG2H

or if mega is too busy:

http://uploading.com/files/e1294955/FPLaunch1.295wip3.zip/

new features are:

slamit support

winactivates removed

reduced time for exit screens (so pinball wizard should not exit)

about fps drop - i have one new gui destroy in loadscreen, but gui destroy was executed before also right after exit from loadscreen

i tested fps drop on pause window a little and main reason for fps drop is change of focus, i get same fps drop when i just go from vp to explorer many times, so this is probably due to vp, not due to fplaunch

/**
* FPLaunch MOD Version 1.295 WIP 3
TO DO:

Fixes
+ fix runtime error on close (set exe to comp mode)
+ fix dmd not visible behind playfield (set exe to comp mode)
+ fps drop - same drop comes from loose of focus
+ shorter time for esc screens
- fix slow down after close (vp still closing)
- fix late printscreen in fp


New features
+ win activate of secondary fp window - doesn't help
+ put version in usage
+ bigboss additions (more exe files, sound mods ...)
+ support for slamit pinball
- while loading esc should be quick kill and exit
- save printscreen-a under name taken from description
- fp auto positioning
- new images with new text

* Modified by dumpster.monkey (samwyze) & blur 
* Based on original FPLaunch 1.2 by BadBoyBill
* Includes modified pause code from ManoWars Nuevo FPLaunch 1.2
* Includes exit png's based on jpg's from BBB's 'exit feature' thread
* Includes support for Pause on Exit by blur
*   Esc and then 1 or Enter exits, Esc and then Esc again takes you back to the game
* Includes support for Pause in FP by blur
*   For pause to work in FP you have to assign right mouse button to pause in FP
* Includes support for saving FP table position (scrolllock) on exit by blur
* VP nag screen removal by blur
*
* All images are to be placed in %HyperPinDir%\Media\HyperPin\Images 
*
* These settings are automatically added to your settings.ini
* file in the %HyperPinDir%\Settings folder on first start:
*   [FPLaunch]
*   exitScriptKey    = q & s
*   exitEmulatorKey  = Esc
*   toggleCursorKey  = t
*   pauseVPinball       = p
*   hideCursor       = true
*   hideDesktop      = true
*   hideTaskbar      = true
*   useExitScreen    = true
*   usePauseKey      = true
*   useLoadScreen    = true
*   fadespeed        = 25
*   useExitAsPause   = true
*   exitEmulatorKey2 = 1
*   exitEmulatorKey3 = Enter
*   pauseFPKey       = RButton
*   saveFPTables     = true
*
* NOTE: This is a wip and is by no means complete or optimized
* Feel free to disect, mod, clean, optimize, distribute or delete!
* 
* Autohotkey script by BadBoyBill  [email protected]
* CursorHide by Lazlo
* 
* If you are reading this and do not have autohotkey you can get it
* @ http://www.autohotkey.com/download/
* If you would like to modify this script and share it thats OK, but
* see if your modification is something that we would like to add
* to the official version.   
*
* Refer to the autohotkey documentation for the keyoboard keylist
* 
* If this script does not support your favorite emulator
* then please request support @ http://www.hyperspin-fe.com/forum   
*
* Supports Future Pinball and Visual Pinball
*
*/

#SingleInstance force      ;Prevent multiple instances
#InstallKeybdHook
#InstallMouseHook
#UseHook
#KeyHistory 500
#MaxThreadsPerHotkey 1
SetTitleMatchMode 2        ;Use relaxed title matching
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
DetectHiddenWindows on

;*******************************************************************************
;*                  EDIT BELOW THIS POINT AT YOUR OWN RISK                     *
;*******************************************************************************   

;------------------------------------------------------------------------------;
;                       GET PARAMATERS AND SET HOTKEYS                         ;
;------------------------------------------------------------------------------;

;CHECKING FOR 2 PARAMS, IF NOT THEN EXIT
if 0 < 2
{
   MsgBox FPLaunch v. 1.295 WIP 3`nUsage: FPLaunch.ahk/exe "System Name" "Rom Name"
   ExitApp
}

systemName = %1%
tableName = %2%
hyperini = %A_ScriptDir%\Settings\Settings.ini
picDir = %A_ScriptDir%\Media\HyperPin\Images\
;------------------------------------------------------------------------------;
;                              GET AND CHECK PATHS                             ;
;------------------------------------------------------------------------------;
GoSub, CheckINI
IniRead, iniEmuPath, %hyperini%, %systemName%, Path
emuPath := GetFullName(iniEmuPath)
IniRead, iniTablePath, %hyperini%, %systemName%, Table_Path
tablePath := GetFullName(iniTablePath)
IniRead, executable, %hyperini%, %systemName%, Exe

iniKeys = exitScriptKey,exitEmulatorKey,hideCursor,toggleCursorKey,hideDesktop,hideTaskbar
,useExitScreen,usePauseKey,pauseVPinball,useLoadScreen,fadespeed
,useExitAsPause,exitEmulatorKey2,exitEmulatorKey3,pauseFPKey,saveFPTables
Loop, parse, iniKeys, `,
  {
     IniRead, %A_LoopField%, %hyperini%, FPLaunch, %A_LoopField%
  }

romExtension =
GoSub, CheckPaths

loadspeed := fadespeed * 10

Hotkey, %exitScriptKey%, ExitScript

; we use loading screeen dimentions for all screens
;If  (useLoadScreen = "true") {
   ProgBar = 0
   gui, 99:add,picture,hwndloadpic, %A_ScriptDir%\Media\HyperPin\Images\Loading.png
   controlgetpos,,,wLoad,hLoad,,ahk_id %loadpic%
   gui, 99:destroy    
   wLoad := Round(wLoad*A_ScreenWidth/1280)
   xLoad := Round(A_ScreenWidth/2-(wLoad/2))
   hLoad := Round(hLoad*A_ScreenHeight/800)
   yLoad := Round(A_ScreenHeight/2-(hLoad/2))
   wLoadProgress := Round(20*A_ScreenWidth/1280)
   xLoadProgress := Round(145*A_ScreenWidth/1280)
   hLoadProgress := Round(194*A_ScreenHeight/800)
   yLoadProgress := Round(288*A_ScreenHeight/800)
;}  
;If  (usePauseKey = "true") {
   Paused = 0
;    PausePic =
;    gui, 98:add,picture,hwndpausepic, %picDir%\Media\HyperPin\Images\Pause.png
;    controlgetpos,,,wPause,hPause,,ahk_id %pausepic%
;    gui, 98:destroy
;    wPause := Round(wPause*A_ScreenWidth/1280)
;    xPause := Round(A_ScreenWidth/2-(wPause/2))
;    hPause := Round(hPause*A_ScreenHeight/800)
;    yPause := Round(A_ScreenHeight/2-(hPause/2))
;}
;If  (useExitScreen = "true") {
   Exiting = 0
;    Exit =
;    gui, 97:add,picture,hwndexitpic, %A_ScriptDir%\Media\HyperPin\Images\Exit_1.png
;    controlgetpos,,,wExit,hExit,,ahk_id %exitpic%
;    gui, 97:destroy
;    wExit := Round(wExit*A_ScreenWidth/1280)
;    xExit := Round(A_ScreenWidth/2-(wExit/2))
;    hExit := Round(hExit*A_ScreenHeight/800)
;    yExit := Round(A_ScreenHeight/2-(hExit/2))
;}

if (hideCursor = "true")
{
 MouseMove %A_ScreenWidth%,%A_ScreenHeight%
 Hotkey, %toggleCursorKey%, ToggleCursor
 SystemCursor("Off")
}

if (hideTaskbar = "true")
{
 WinHide, ahk_class Shell_TrayWnd
 WinHide, Start ahk_class Button
}

if (hideDesktop = "true")
{
 Gui, Color, 000000
 Gui +AlwaysOnTop -Caption +ToolWindow
 Gui, Show, x0 y0 W%A_ScreenWidth% H%A_ScreenHeight%, BlackScreen
}

WinClose, cmd.exe

;------------------------------------------------------------------------------;
;                                  RUN SYSTEM                                  ;
;------------------------------------------------------------------------------;



;**********************************FUTURE PINBALL***********************************
if (systemName = "Future Pinball") {
 ; big boss bigscore
 if(tableName = "BigScore") {
   Hotkey, $%exitEmulatorKey%, CloseSlam
   ;Remap some keys (enter to down arrow for plunger, 1 to s for start, 2 to 1 for insert coin, both ctrl to enter.
   ;setworkingdir, "..\SlamIt\BigScore.exe"
   Run, "..\slamit\go.bat", "..\SlamIt"
   WinWait, ahk_class SlamIt Pinball - Big Score
   Gui, destroy
   #IfWinActive ahk_class SlamIt Pinball - Big Score
   RControl::Enter
   LControl::Enter
   Enter::down
   5::1
   1::s
   #IfWinActive ; This puts subsequent remappings and hotkeys in effect for all windows.
   Process, WaitClose, BigScore.exe
 } else {
   if (useExitScreen = "true")
       Hotkey, $*%exitEmulatorKey%, ExitScreen
   else if (useExitAsPause = "true")
       Hotkey, $*%exitEmulatorKey%, PauseFP
   else
       Hotkey, $*%exitEmulatorKey%, CloseFP

   if  (usePauseKey = "true") {
       Hotkey, $*%pauseVPinball%, PauseFP
       ;Hotkey, $*Pause, PauseFP
   }

   Hotkey, $!F4, ShowFP

   if (saveFPTables = "true") {
       Hotkey, $ScrollLock, SetSaveFPNeeded
       Run, "%emuPath%\%executable%" /open "%tablePath%\%tableName%.fpt" /play /arcaderender,,Min UseErrorLevel
   } else
       Run, "%emuPath%\%executable%" /open "%tablePath%\%tableName%.fpt" /play /Exit /arcaderender,,Min UseErrorLevel

   If (useLoadScreen   = "true") ;Draw the loading Gui with wrapped Progress bar
       Gosub CreateLoadScreen
   Else {
       WinWait, ahk_class FuturePinball
       WinHide, ahk_class FuturePinball
   }
   WinWait, ahk_class FuturePinballOpenGL
   WinActivate, ahk_class FuturePinballOpenGL
   WinWaitActive, ahk_class FuturePinballOpenGL
   Gui, destroy   
   WinWait, ahk_class FuturePinballOpenGLSecondary,,1
   WinActivate, ahk_class FuturePinballOpenGLSecondary
   WinWaitActive, ahk_class FuturePinballOpenGLSecondary,,1
   WinActivate, ahk_class FuturePinballOpenGL
   Process, WaitClose, %executable%
 }
}
;**********************************VISUAL PINBALL***********************************
else if (systemName = "Visual Pinball")
 {
   ; bigboss
   ; Array examples: http://www.autohotkey.com/docs/misc/Arrays.htm
   ; Read config file for vp9.08 tables
   vp908count = 0
   ; This loop retrieves each line from the file, one at a time.
   Loop, Read, %A_ScriptDir%\Settings\vp908tables.txt
   {
       vp908count += 1  ; Keep track of how many items are in the array.
       vp908array%vp908count% := A_LoopReadLine  ; Store this line in the next array element.
   }

   ; Check if table is in the vp908tables array.
   Loop %vp908count%
   {
       ; The following line uses the := operator to retrieve an array element:
       element := vp908array%A_Index%  ; A_Index is a built-in variable.
       if(tableName = element)
       {
           TableIndex = %A_Index%
           vpExeIndex = %TableIndex%
           vpExeIndex += 1        
           executable := vp908array%vpExeIndex%
           break
       }
   }

   ; Read config file for disable HD rendering tables since this is a global setting now.
   HDRenderOffCount = 0
   HDRenderOffChanged = 0
   ; This loop retrieves each line from the file, 1 at a time.
   Loop, Read, %A_ScriptDir%\Settings\hdrenderofftables.txt
   {
       HDRenderOffCount += 1  ; Keep track of how many items are in the array.
       HDRenderOffArray%HDRenderOffCount% := A_LoopReadLine  ; Store this line in the next array element.
   }

   ; Check if table is in the no hdrender array and write the VP hardwarerender key to off.
   Loop %HDRenderOffCount%
   {
       ; The following line uses the := operator to retrieve an array element:
       element := HDRenderOffArray%A_Index%  ; A_Index is a built-in variable.
       if(tableName = element)
       {
           HDRenderOffChanged = 1
           RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Visual Pinball\Player, HardwareRender, 0
           break
       }
   }

   ; Read config for sound volume hard codes
   SoundModCount = 0
   SoundChangeAmount = 0
   Loop, Read, %A_ScriptDir%\Settings\soundmodtables.txt
   {
       SoundModCount += 1
       SoundModCountArray%SoundModCount% := A_LoopReadLine
   }

   ; Check if table is in the vp908tables array.
   Loop %SoundModCount%
   {
       ; The following line uses the := operator to retrieve an array element:
       TableIndex = %A_Index%
       SoundIndex = %TableIndex%
       SoundIndex += 1        
       TheTable := SoundModCountArray%TableIndex%
       TheSoundAmount := SoundModCountArray%SoundIndex%

       if(tableName = TheTable)
       {
           ; Set the new sound change amount. Should be a + or - number otherwise it needs a , SoundSet, absoluteamt
           ; SoundSet: http://www.autohotkey.com/docs/commands/SoundSet.htm
           ; SoundGet: http://www.autohotkey.com/docs/commands/SoundGet.htm
           ;SoundSet, %TheSoundAmount%
           Send {Volume_Down %TheSoundAmount%}
           break
       }
   }


  ; rosve
  ;--------------------------------------------------------------
  ;------     check if an active backglass shall be started -----
  ;--------------------------------------------------------------
   StringRight, ending, tableName, 3
   if (ending = "B2S")
   {
       Run, %tablePath%%tableName%.exe, %tablePath%
       sleep 200
   }

   Run, "%emuPath%\%executable%" /play -"%tablePath%%tableName%.vpt",, Min UseErrorLevel ;Run Minimized
   ;was the best way I could hide the vp editor and play loading screens as WinHide didn't seem to find them

   If  (useExitScreen = "true")
       Hotkey, *%exitEmulatorKey%, ExitScreen
   Else If (useExitAsPause = "true")
       Hotkey, *%exitEmulatorKey%, PauseVP
   Else
       Hotkey, *%exitEmulatorKey%, CloseVP

   If  (usePauseKey = "true") {
       Hotkey, $*%pauseVPinball%, PauseVP
       ;Hotkey, $*Pause, PauseVP
   }

   Hotkey, $!F4, ShowVP

   If (useLoadScreen   = "true") ;Draw the loading Gui with wrapped Progress bar
       Gosub CreateLoadScreen
   Else {
       WinWait, ahk_class VPinball
       WinHide, ahk_class VPinball
   }
   WinWaitActive, ahk_class VPPlayer ;Wait for vp to be Ready before killing Gui blackScreen
   ;WinActivate, ahk_class TBackglass
   ;WinActivate, ahk_class MAME
   ;WinActivate, ahk_class VPPlayer
   Gui, Destroy
   Process, WaitClose, %executable%
}
else
{
   MsgBox,48,Error,%systemName% is an invalid System Name or %executable% isnt supported yet,6
}

;------------------------------------------------------------------------------;
;                WHEN EMULATOR FINISHES OR IF LAUNCH EXE FAILS                 ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************

if (ErrorLevel = "ERROR")
{
 MsgBox,48,Error,Failed to run executable check your paths,6
}
Goto ExitScript ; Exits script and returns to frontend


;------------------------------------------------------------------------------;
;                                KILL COMMANDS                                 ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************

CloseProcess:
Hotkey, %exitScriptKey%, Off
Process, Close, %executable%
Process, WaitClose, %executable%
return

; big boss bigscore
CloseSlam:
WinClose, ahk_class SlamIt Pinball - Big Score
goto ExitScript
return

PauseFP:
if (Paused = 0) {
   Paused = 1
   WinActivate, ahk_class FuturePinballOpenGL
   WinWaitActive, ahk_class FuturePinballOpenGL
   Send {%pauseFPKey%}
   WinWaitActive, ahk_class FuturePinballOpenGL
   Gosub CreateBlackScreen
   Gosub CreatePauseScreen
   Hotkey, $%exitEmulatorKey2%, CloseFP
   Hotkey, $%exitEmulatorKey2%, On
   Hotkey, $%exitEmulatorKey3%, CloseFP
   Hotkey, $%exitEmulatorKey3%, On
} else {
   Paused = 0
   Gui 1: Destroy
   Gui 5: Destroy
   WinActivate, ahk_class FuturePinballOpenGL
   WinWaitActive, ahk_class FuturePinballOpenGL
   Send {%pauseFPKey%}
   Hotkey, $%exitEmulatorKey2%, Off
   Hotkey, $%exitEmulatorKey3%, Off
}
return

pauseVP:
If (Paused = 0) {
   Paused = 1
   Gosub CreatePauseScreen
   Hotkey, $%exitEmulatorKey2%, CloseVP
   Hotkey, $%exitEmulatorKey2%, On
   Hotkey, $%exitEmulatorKey3%, CloseVP
   Hotkey, $%exitEmulatorKey3%, On
} Else {
   Paused = 0
   Gui, Destroy
   WinActivate, ahk_class VPPlayer
   Hotkey, $%exitEmulatorKey2%, Off
   Hotkey, $%exitEmulatorKey3%, Off
}
return

ShowFP:
if (Paused = 1)
   Gosub PauseFP
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {Esc}
WinWaitClose, ahk_class FuturePinballOpenGL
WinShow, ahk_class FuturePinball
WinRestore, ahk_class FuturePinball
WinActivate, ahk_class FuturePinball
WinWaitActive, ahk_class FuturePinball
SystemCursor("On")
WinShow, ahk_class Shell_TrayWnd
WinShow, Start ahk_class Button
Suspend, On
WinWait, ahk_class FuturePinballOpenGL
Suspend, Off
SystemCursor("Off")
WinHide, ahk_class Shell_TrayWnd
WinHide, Start ahk_class Button
WinHide, ahk_class FuturePinball
WinMinimize, ahk_class FuturePinball
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
return

ShowVP:
if (Paused = 1)
   Gosub PauseVP
WinActivate, ahk_class VPPlayer
WinWaitActive, ahk_class VPPlayer
WinClose, ahk_class VPPlayer
WinWaitClose, ahk_class VPPlayer
WinShow, ahk_class VPinball
WinRestore, ahk_class VPinball
WinActivate, ahk_class VPinball
WinWaitActive, ahk_class VPinball
SystemCursor("On")
WinShow ahk_class Shell_TrayWnd
WinShow Start ahk_class Button
Suspend, On
WinWait, ahk_class VPPlayer
Suspend, Off
SystemCursor("Off")
WinHide, ahk_class Shell_TrayWnd
WinHide, Start ahk_class Button
WinHide, ahk_class VPinball
WinMinimize, ahk_class VPinball
WinWaitActive, ahk_class VPPlayer
;WinActivate, ahk_class TBackglass
;WinActivate, ahk_class MAME
;WinActivate, ahk_class VPPlayer
return

SetSaveFPNeeded:
saveFPNeeded = true
Send {ScrollLock}
return

CloseFP:
;close all gui's except black screen (gui 5)
Loop, 4
   Gui, %A_Index%: Destroy
;hide and minimize fp editor
WinHide, ahk_class FuturePinball
WinMinimize, ahk_class FuturePinball
;Future Pinball must be closed this way instead of killing process
;or it wil not save your last game information.i.e score/credtis
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {Esc}
WinWaitClose, ahk_class FuturePinballOpenGL
;saving fp table position, black screen hides fp window
if (saveFPTables = "true") and (saveFPNeeded = "true") {
   ;WinRestore, ahk_class FuturePinball
   WinActivate, ahk_class FuturePinball
   WinWaitActive, ahk_class FuturePinball
   WinMenuSelectItem, ahk_class FuturePinball,,File,Save
   Sleep, 1000
}
WinClose, ahk_class FuturePinball
GoSub, ExitScript
return

CloseVP:
Hotkey, %exitScriptKey%, Off
; rosve
; --------------------------------------------------------------
; --- Close the animated backglass -----------------------
; --------------------------------------------------------------
if (ending = "B2S")
{
WinKill, Form1
}
;Visual Pinball must be closed this way instead of killing process 
;or it wil not save your last game information.i.e score/credtis
;DetectHiddenWindows, on ;Or next line will not work
Loop, 4
Gui, %A_Index%: Destroy
;This line fixes where the VP Window flashes real quick
;when closing the window for a cleaner exit
WinHide, ahk_class VPinball
WinMinimize, ahk_class VPinball
WinClose, ahk_class VPinball
; bigboss
; Restore hdrender original value
if (HDRenderOffChanged)
   RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Visual Pinball\Player, HardwareRender, 1
; Restore master volume original value
if (TheSoundAmount)
   Send {Volume_Up %TheSoundAmount%}
GoSub, ExitScript
return

CreateLoadScreen:
   Gui, Destroy ; kill Gui blackScreen
   Gui, Color, EEAA99
   Gui, Margin, 0, 0
   Gui, Add, Picture, h%hLoad% w%wLoad% vLoadPic, %picDir%loading.png
   Gui, Add, Progress, x%xLoadProgress% y%yLoadProgress% w%wLoadProgress% h%hLoadProgress% -smooth 0x8 c0C32A5 vLoading vertical BackgroundFFFFFF 
   Gui +AlwaysOnTop -Caption +Lastfound
   Gui, Show, AutoSize Center, loadScreen
   WinSet, TransColor, EEAA99
   Loop {
       Sleep %loadspeed%
       ;ProgBar += 1
       ;If ProgBar = %loadspeed%
       ;{
           GuiControl,, Loading, 1
       ;    ProgBar = 0
       ;}
       ; get rid of nag screens
       ifWinExist, Please
       {
           WinActivate, Please
           IfWinActive, Please
           {
               Send {Tab}
               Send {Space}
               Send {Enter}
           }
       } else ifWinExist, Game Info
       {
           WinActivate, Game Info
           IfWinActive, Game Info
           {
               Send {Enter}
               Send {Enter}
           }
       } else ifWinExist, Notice
       {
           WinActivate, Notice
           IfWinActive, Notice
           {
               Send {Enter}
               Send {Enter}
           }
       } else ifWinExist, VBScript
       {
           WinActivate, VBScript
           IfWinActive, VBScript
           {
               Send {Enter}
           }
       } else ifWinExist, Error
       {
           ;IfWinActive, Error
           ;{
               ;Send {Enter}
               Gui, Destroy
               WinActivate, Error
               SystemCursor("On")
               Process, WaitClose, %executable%
               ExitApp
           ;}
       }
       if (systemName = "Visual Pinball") {
           IfWinExist, Visual Pinball Player,, DMD ;Check if visual pinball is Ready
           {
               IfWinActive, Visual Pinball Player,, DMD ;Check if visual pinball is Ready
               {
                   Break
               }
           }
       } else {
           IfWinExist, ahk_class FuturePinballOpenGL ;Check if visual pinball is Ready
           {
               IfWinActive, ahk_class FuturePinballOpenGL ;Check if visual pinball is Ready
               {
                   Break
               }
           }
       }
   }
Gui, Destroy  ; Vic
Return

CreateBlackScreen:
   CaptureScreen(3)
   ;Sleep 100
   WinWaitActive, ahk_class FuturePinballOpenGL,,2
   Gui 5: Destroy
   Gui 5: Color, 000000
   Gui 5: Margin, 0, 0
   Gui 5: Add, Picture, W%A_ScreenWidth% H%A_ScreenHeight% vScreenPic, screen.bmp
   Gui 5: +AlwaysOnTop -Caption +ToolWindow
   Gui 5: Show, x0 y0 W%A_ScreenWidth% H%A_ScreenHeight%, BlackScreen
Return

CreatePauseScreen:
/*
   Gui, Destroy ; kill Gui blackScreen
   Gui, Color, EEAA99
   Gui, Margin, 0, 0
   Gui, Add, Picture, h%hLoad% w%wLoad% vPausePic, %picDir%pause.png
   ;Gui, Add, Progress, x%xLoadProgress% y%yLoadProgress% w%wLoadProgress% h%hLoadProgress% -smooth 0x8 c0C32A5 vLoading vertical BackgroundFFFFFF 
   Gui +AlwaysOnTop -Caption +Lastfound
   Gui, Show, AutoSize Center, pauseScreen
   WinSet, TransColor, EEAA99
*/
   Gui, Destroy
   Gui, Color, EEAA99
   Gui, Margin, 0, 0
   Gui, Add, Picture, h%hLoad% w%wLoad% vPausePic, %picDir%pause.png
   Gui +AlwaysOnTop -Caption +Lastfound
   Gui, Show, AutoSize Center, pauseScreen
   WinSet, TransColor, EEAA99
   ;Gui, Show
Return

CreateExitScreen:
    Gui, Destroy
   Loop, 4
     {
       ExitPic = Exit_%A_Index%.png
       Gui %A_Index%: Destroy
       Gui %A_Index%: Color, EEAA99
       Gui %A_Index%: Margin, 0, 0
       Gui %A_Index%: Add, Picture, w%wLoad% h%hLoad%, %picDir%%ExitPic%
       Gui %A_Index%: +AlwaysOnTop -Caption +Lastfound
       Gui %A_Index%: Show, AutoSize Center Hide
       WinSet, TransColor, EEAA99
     }
Return

ExitScreen:
   if (Exiting = 1)
       return
   else
       Exiting = 1
   LoopVal = 0
   Loop {  
       state = 0
       GetKeyState, statep, %exitEmulatorKey%, P
       if statep = D
           state = 1
       GetKeyState, statel, %exitEmulatorKey%
       if statel = D
           state = 1
       if (state) {
           if (loopVal = 10) {
               if (Paused = 1) {
                   if (systemName = "Future Pinball")
                       GoSub PauseFP
                   else
                       GoSub PauseVP
               }
               Gosub CreateExitScreen
               if (systemName = "Future Pinball")
                   GoSub CreateBlackScreen
               Gui, 3:Show
           } else if loopVal = 30
               Gui, 2:Show
           else if loopVal = 50
               Gui, 1:Show
           Sleep,  %fadespeed%
           if (loopVal = 70) {
               if (systemName = "Visual Pinball")
                   GoSub, CloseVP
               else if (systemName = "Future Pinball")
                   GoSub, CloseFP
               break
           }
       } else {
           Exiting = 0
           if (LoopVal < 10 && useExitAsPause = "true") {
               if (systemName = "Visual Pinball")
                   GoSub, PauseVP
               else if (systemName = "Future Pinball")
                   GoSub, PauseFP
           } else {
               Loop, 5
                   Gui, %A_Index%: Destroy
               WinActivate, Visual Pinball Player,, DMD
               WinActivate, ahk_class FuturePinballOpenGL
           }
            Transvalue = 0
           LoopVal = 0
            break
       }
       LoopVal += 1
   }
Return

ExitScript:
Loop, 5
   Gui, %A_Index%: Destroy
Process, Exist, HyperPin.exe
PID := errorLevel
;no need to show taskbar on exit, it can only cause problems
;it was already commented in 1.10
;if (hideTaskbar = "true") {
 ;WinShow ahk_class Shell_TrayWnd
 ;WinShow Start ahk_class Button
;}
if (PID) {
 WinActivate, ahk_pid %PID%
 ;WinWaitActive, ahk_pid %PID%
}
if (hideCursor = "true")
 SystemCursor("On")
;to debug script uncomment the pause
;Pause
ExitApp

OnExit, ExitScript
return


;------------------------------------------------------------------------------;
;                                 REST OF SCRIPT                               ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************



SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
   static AndMask, XorMask, $, h_cursor
       ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
       , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
       , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
   if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
   {
       $ = h                                          ; active default cursors
       VarSetCapacity( h_cursor,4444, 1 )
       VarSetCapacity( AndMask, 32*4, 0xFF )
       VarSetCapacity( XorMask, 32*4, 0 )
       system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
       StringSplit c, system_cursors, `,
       Loop %c0%
       {
           h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
           h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
           b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
               , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
       }
   }
   if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
       $ = b  ; use blank cursors
   else
       $ = h  ; use the saved cursors

   Loop %c0%
   {
       h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
       DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
   }
}
ToggleCursor:
 SystemCursor("Toggle")
 WinShow ahk_class Shell_TrayWnd
 WinShow Start ahk_class Button
return

IniRead(Filename, Section, Key, Default = "") { 
  FileRead, text, *t %Filename% 
  text = `n%text%`n 
  StringTrimLeft, text, text, InStr(text, "`n[" . Section . "]`n") 
  Loop, 8 { 
     sp := sp . " " 
     StringReplace, text, text, %Key%%sp%=, %Key%= 
     If ErrorLevel 
        Break 
  } 
  start := InStr(text, "`n" . Key . "=") 
  If !start 
     Return, Default 
  start += StrLen(Key) + 2 
  StringMid, Value, text, start, InStr(text, "`n", false, start) - start 
  Return, Value 
}

;Get Full Path from Relative Path
GetFullName( fn ) {
  static buf, i
  if !i
     i := VarSetCapacity(buf, 512)
  DllCall("GetFullPathNameA", "str", fn, "uint", 512, "str", buf, "str*", 0)
  return buf
}

CheckINI:
 IfNotExist, %A_ScriptDir%\HyperPin.exe
 {
   MsgBox,48,Error, Must be in same directory as HyperPin.exe,6
   Goto ExitScript 
 }
 IfNotExist, %A_ScriptDir%\Settings\Settings.ini
 {
   MsgBox,48,Error,Cannot Find %A_ScriptDir%\Settings\Settings.ini,6
   Goto ExitScript 
 }
return

CheckPaths:
 romFound =
 StringRight, emuPathBackSlash, EmuPath, 1
 StringRight, tablePathBackSlash, TablePath, 1

 If (emuPathBackSlash != "\" || tablePathBackSlash != "\")
   {
     MsgBox,48,Error, Make sure your paths contains a backslash on the end ,6
     Goto ExitScript
   }
 If (executable = "")
   {
     MsgBox,48,Error, Missing executable in Settings.ini ,6
     Goto ExitScript
   }
 If (tablePath = "")
   {
     MsgBox,48,Error, Missing rom path in Settings.ini ,6
     Goto ExitScript
   }
 If (emuPath = "")
   {
     MsgBox,48,Error, Missing emulator path in Settings.ini ,6
     Goto ExitScript
   }
 If (exitScriptKey = "ERROR") or (useExitAsPause = "ERROR") or (exitEmulatorKey3 = "ERROR")
   Gosub addIni
 IfNotExist, %EmuPath%%Executable%
 {
   MsgBox,48,Error,Cannot Find %EmuPath%%Executable%,6
   Goto ExitScript 
 }
return

addIni:
 IniWrite, q & s, %hyperini%, FPLaunch, exitScriptKey
 IniWrite, Esc, %hyperini%, FPLaunch, exitEmulatorKey
 IniWrite, t, %hyperini%, FPLaunch, toggleCursorKey
 IniWrite, p, %hyperini%, FPLaunch, pauseVPinball
 IniWrite, true, %hyperini%, FPLaunch, hideCursor
 IniWrite, true, %hyperini%, FPLaunch, hideDesktop
 IniWrite, true, %hyperini%, FPLaunch, hideTaskbar
 IniWrite, false, %hyperini%, FPLaunch, useExitScreen
 IniWrite, true, %hyperini%, FPLaunch, usePauseKey
 IniWrite, true, %hyperini%, FPLaunch, useLoadScreen
 IniWrite, 25, %hyperini%, FPLaunch, fadespeed
 IniWrite, true, %hyperini%, FPLaunch, UseExitAsPause
 IniWrite, 1, %hyperini%, FPLaunch, exitEmulatorKey2
 IniWrite, Enter, %hyperini%, FPLaunch, exitEmulatorKey3
 IniWrite, RButton, %hyperini%, FPLaunch, pauseFPKey
 IniWrite, true, %hyperini%, FPLaunch, saveFPTables
exitScriptKey    = q & s
exitEmulatorKey  = Esc
toggleCursorKey  = t
pauseVPinball      = p
hideCursor       = true
hideDesktop      = true
hideTaskbar      = true
useExitScreen    = true
usePauseKey      = true
useLoadScreen    = true
fadespeed        = 25
useExitAsPause   = true
exitEmulatorKey2 = 1
exitEmulatorKey3 = Enter
pauseFPKey       = RButton
saveFPTables     = true

return

/* CaptureScreen(aRect, bCursor, sFileTo, nQuality)
 By Sean - Taken from Forum page:    http://www.autohotkey.com/forum/topic18146.html
1) If the optional parameter bCursor is True, captures the cursor too.
2) If the optional parameter sFileTo is 0, set the image to Clipboard.
  If it is omitted or "", saves to screen.bmp in the script folder,
  otherwise to sFileTo which can be BMP/JPG/PNG/GIF/TIF.
3) The optional parameter nQuality is applicable only when sFileTo is JPG. Set it to the desired quality level of the resulting JPG, an integer between 0 - 100.
4) If aRect is 0/1/2/3, captures the entire desktop/active window/active client area/active monitor.
5) aRect can be comma delimited sequence of coordinates, e.g., "Left, Top, Right, Bottom" or "Left, Top, Right, Bottom, Width_Zoomed, Height_Zoomed".
  In this case, only that portion of the rectangle will be captured. Additionally, in the latter case, zoomed to the new width/height, Width_Zoomed/Height_Zoomed.

Example:
CaptureScreen(0)
CaptureScreen(1)
CaptureScreen(2)
CaptureScreen(3)
CaptureScreen("100, 100, 200, 200")
CaptureScreen("100, 100, 200, 200, 400, 400")   ; Zoomed
*/

/* Convert(sFileFr, sFileTo, nQuality)
Convert("C:\image.bmp", "C:\image.jpg")
Convert("C:\image.bmp", "C:\image.jpg", 95)
Convert(0, "C:\clip.png")   ; Save the bitmap in the clipboard to sFileTo if sFileFr is "" or 0.
*/


CaptureScreen(aRect = 0, bCursor = False, sFile = "", nQuality = "")
{
   If    !aRect
   {
       SysGet, nL, 76
       SysGet, nT, 77
       SysGet, nW, 78
       SysGet, nH, 79
   }
   Else If    aRect = 1
       WinGetPos, nL, nT, nW, nH, A
   Else If    aRect = 2
   {
       WinGet, hWnd, ID, A
       VarSetCapacity(rt, 16, 0)
       DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt)
       DllCall("ClientToScreen", "Uint", hWnd, "Uint", &rt)
       nL := NumGet(rt, 0, "int")
       nT := NumGet(rt, 4, "int")
       nW := NumGet(rt, 8)
       nH := NumGet(rt,12)
   }
   Else If    aRect = 3
   {
       VarSetCapacity(mi, 40, 0)
       DllCall("GetCursorPos", "int64P", pt)
       DllCall("GetMonitorInfo", "Uint", DllCall("MonitorFromPoint", "int64", pt, "Uint", 2), "Uint", NumPut(40,mi)-4)
       nL := NumGet(mi, 4, "int")
       nT := NumGet(mi, 8, "int")
       nW := NumGet(mi,12, "int") - nL
       nH := NumGet(mi,16, "int") - nT
   }
   Else
   {
       StringSplit, rt, aRect, `,, %A_Space%%A_Tab%
       nL := rt1
       nT := rt2
       nW := rt3 - rt1
       nH := rt4 - rt2
       znW := rt5
       znH := rt6
   }

   mDC := DllCall("CreateCompatibleDC", "Uint", 0)
   hBM := CreateDIBSection(mDC, nW, nH)
   oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM)
   hDC := DllCall("GetDC", "Uint", 0)
   DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020)
   DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
   If    bCursor
       CaptureCursor(mDC, nL, nT)
   DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
   DllCall("DeleteDC", "Uint", mDC)
   If    znW && znH
       hBM := Zoomer(hBM, nW, nH, znW, znH)
   If    sFile = 0
       SetClipboardData(hBM)
   Else    Convert(hBM, sFile, nQuality), DllCall("DeleteObject", "Uint", hBM)
}

CaptureCursor(hDC, nL, nT)
{
   VarSetCapacity(mi, 20, 0), mi := Chr(20)
   DllCall("GetCursorInfo", "Uint", &mi)
   bShow   := NumGet(mi, 4)
   hCursor := NumGet(mi, 8)
   xCursor := NumGet(mi,12)
   yCursor := NumGet(mi,16)

   If    bShow && hCursor:=DllCall("CopyIcon", "Uint", hCursor)
   {
   VarSetCapacity(ni, 20, 0)
   DllCall("GetIconInfo", "Uint", hCursor, "Uint", ∋)
   bIcon    := NumGet(ni, 0)
   xHotspot := NumGet(ni, 4)
   yHotspot := NumGet(ni, 8)
   hBMMask  := NumGet(ni,12)
   hBMColor := NumGet(ni,16)

   DllCall("DrawIcon", "Uint", hDC, "int", xCursor - xHotspot - nL, "int", yCursor - yHotspot - nT, "Uint", hCursor)
   DllCall("DestroyIcon", "Uint", hCursor)
   If    hBMMask
   DllCall("DeleteObject", "Uint", hBMMask)
   If    hBMColor
   DllCall("DeleteObject", "Uint", hBMColor)
   }
}

Zoomer(hBM, nW, nH, znW, znH)
{
   mDC1 := DllCall("CreateCompatibleDC", "Uint", 0)
   mDC2 := DllCall("CreateCompatibleDC", "Uint", 0)
   zhBM := CreateDIBSection(mDC2, znW, znH)
   oBM1 := DllCall("SelectObject", "Uint", mDC1, "Uint",  hBM)
   oBM2 := DllCall("SelectObject", "Uint", mDC2, "Uint", zhBM)
   DllCall("SetStretchBltMode", "Uint", mDC2, "int", 4)
   DllCall("StretchBlt", "Uint", mDC2, "int", 0, "int", 0, "int", znW, "int", znH, "Uint", mDC1, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", 0x00CC0020)
   DllCall("SelectObject", "Uint", mDC1, "Uint", oBM1)
   DllCall("SelectObject", "Uint", mDC2, "Uint", oBM2)
   DllCall("DeleteDC", "Uint", mDC1)
   DllCall("DeleteDC", "Uint", mDC2)
   DllCall("DeleteObject", "Uint", hBM)
   Return    zhBM
}

Convert(sFileFr = "", sFileTo = "", nQuality = "")
{
   If    sFileTo  =
       sFileTo := A_ScriptDir . "\screen.bmp"
   SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo

   If Not    hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll")
       Return    sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo . "\" . sNameTo . ".bmp") : ""
   VarSetCapacity(si, 16, 0), si := Chr(1)
   DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)

   If    !sFileFr
   {
       DllCall("OpenClipboard", "Uint", 0)
       If     DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2))
       DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage)
       DllCall("CloseClipboard")
   }
   Else If    sFileFr Is Integer
       DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage)
   Else    DllCall("gdiplus\GdipLoadImageFromFile", "Uint", Unicode4Ansi(wFileFr,sFileFr), "UintP", pImage)

   DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize)
   VarSetCapacity(ci,nSize,0)
   DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci)
   Loop, %    nCount
       If    InStr(Ansi4Unicode(NumGet(ci,76*(A_Index-1)+44)), "." . sExtTo)
       {
           pCodec := &ci+76*(A_Index-1)
           Break
       }
   If    InStr(".JPG.JPEG.JPE.JFIF", "." . sExtTo) && nQuality<>"" && pImage && pCodec
   {
   DllCall("gdiplus\GdipGetEncoderParameterListSize", "Uint", pImage, "Uint", pCodec, "UintP", nSize)
   VarSetCapacity(pi,nSize,0)
   DllCall("gdiplus\GdipGetEncoderParameterList", "Uint", pImage, "Uint", pCodec, "Uint", nSize, "Uint", π)
   Loop, %    NumGet(pi)
       If    NumGet(pi,28*(A_Index-1)+20)=1 && NumGet(pi,28*(A_Index-1)+24)=6
       {
           pParam := π+28*(A_Index-1)
           NumPut(nQuality,NumGet(NumPut(4,NumPut(1,pParam+0)+20)))
           Break
       }
   }

   If    pImage
       pCodec    ? DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", Unicode4Ansi(wFileTo,sFileTo), "Uint", pCodec, "Uint", pParam) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pImage, "UintP", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)

   DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken)
   DllCall("FreeLibrary", "Uint", hGdiPlus)
}

CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "")
{
   NumPut(VarSetCapacity(bi, 40, 0), bi)
   NumPut(nW, bi, 4)
   NumPut(nH, bi, 8)
   NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
   NumPut(0,  bi,16)
   Return    DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
}

SaveHBITMAPToFile(hBitmap, sFile)
{
   DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
   hFile:=    DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0)
   DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0)
   DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0)
   DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0)
   DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0)
   DllCall("CloseHandle", "Uint", hFile)
}

SetClipboardData(hBitmap)
{
   DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
   hDIB :=    DllCall("GlobalAlloc", "Uint", 2, "Uint", 40+NumGet(oi,44))
   pDIB :=    DllCall("GlobalLock", "Uint", hDIB)
   DllCall("RtlMoveMemory", "Uint", pDIB, "Uint", &oi+24, "Uint", 40)
   DllCall("RtlMoveMemory", "Uint", pDIB+40, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44))
   DllCall("GlobalUnlock", "Uint", hDIB)
   DllCall("DeleteObject", "Uint", hBitmap)
   DllCall("OpenClipboard", "Uint", 0)
   DllCall("EmptyClipboard")
   DllCall("SetClipboardData", "Uint", 8, "Uint", hDIB)
   DllCall("CloseClipboard")
}

Unicode4Ansi(ByRef wString, sString)
{
   nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
   VarSetCapacity(wString, nSize * 2)
   DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize)
   Return    &wString
}

Ansi4Unicode(pString)
{
   nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int",  0, "Uint", 0, "Uint", 0)
   VarSetCapacity(sString, nSize)
   DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0)
   Return    sString
}

Edited by blur
Link to comment
Share on other sites

exitEmulatorKey= Joy8

exitEmulatorKey2= Joy7

exitEmulatorKey3= Joy6

Oh, duh. Okay, that works well. I'm now able to pause my cabinet for VP hitting Joy8, then exit it hitting my start button when the screen is paused. That works fine now.

Thanks for not giving up on me Blur! :)

Now I'm seeing that if I exit a FP game and then try to spin the HP wheel too soon after, that it freezes. If I wait a couple of seconds, everything is fine. I believe I read that through here, so I'll go back and find it.

Thanks for the help. I really appreciate it!

Link to comment
Share on other sites

here is the new version 1.295 wip 3

test it a little before i upload exe

new features are:

slamit support

winactivates removed

reduced time for exit screens (so pinball wizard should not exit)

about fps drop - i have one new gui destroy in loadscreen, but gui destroy was executed before also right after exit from loadscreen

i tested fps drop on pause window a little and main reason for fps drop is change of focus, i get same fps drop when i just go from vp to explorer many times, so this is probably due to vp, not due to fplaunch

So this is not available to download anywhere yet blur? I am using an older version of fplaunch and I am getting hangs, popup text box windows popping open when exiting a game, etc. I think I should probably just go to the latest and greatest version and give it a go.

Link to comment
Share on other sites

there is a source in a post - you just copy it to fplaunch.ahk and compile

i just wrote it and was going away so didn't have time to upload exe to megaupload

here is exe and ahk:

http://www.megaupload.com/?d=HR79NG2H

When I try to download I get this:

The file you are trying to access is temporarily unavailable. Please try again later.

I will try and figure out how to compile.

Link to comment
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
×
×
  • Create New...