Aaron James
01-08-2012, 01:31 PM
; FPLaunch MOD by bbb, samwyze and blur
Version := "1.295 WIP 8"
/* Check FPLaunch Manual at:
* http://www.hyperspin-fe.com/forum/showthread.php?t=10935
* You can use this script without recompile - just
* change options in %HyperPinDir%\Settings\Settings.ini
* If you want to change the script you have to recompile it
* with autohotkey BASIC version from http://www.autohotkey.com/
* Modified by dumpster.monkey (samwyze) & blur
* Based on original FPLaunch 1.2 by BadBoyBill
* Thanks to tic (Tariq Porter) for his GDI+ Library
* http://www.autohotkey.com/forum/viewtopic.php?t=32238
* Includes modified pause code from ManofWars Nuevo FPLaunch 1.2
* Includes exit png's based on jpg's from BBB's 'exit feature' thread
* Includes exit menu by Sam
* Includes support for Pause in FP by blur
* For pause to work in FP you have to define right mouse button as pause in FP
* Includes support for saving FP table position (scrolllock) on exit by blur
* VP nag screen removal by blur
* B2S backglass exe support by rosve
* different exe, sound level and hdrender flag support by bigboss:
* http://www.vpforums.org/index.php?showtopic=12906
* slamit bigscore pinball support by bigboss:
* http://www.hyperspin-fe.com/forum/showthread.php?t=12198
* ledwiz support by darkfall:
* http://www.vpforums.org/index.php?showtopic=16186&hl=
*
* All images should be placed in %HyperPinDir%\Media\HyperPin\Images
* All settings are added to %HyperPinDir%\Settings\Settings.ini
* 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 badboybill@hyperspin-fe.com
* CursorHide by Lazlo
*
* 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
*
* Supports Future Pinball and Visual Pinball
*
CODE MAP
This is short list of all sections and functions in this script
so that you can find and customize them quickly
GET PARAMATERS AND SET HOTKEYS
- reads input parameters from command line
GET AND CHECK PATHS
- gets settings from ini files
- calculates window coordinates
- hides taskbar, cursor and desktop
RUN SYSTEM
FUTURE PINBALL
VISUAL PINBALL
- commands for launching vp and fp
KILL COMMANDS
- this is where all the procedures are
Procedures:
CloseProcess kills process - not used
QuickLaunch launching gui
rosve rosve support for B2S active backglasses
rosveClose kills B2S backglass
bigboss bigboss support for different exe, sound levels and hdrender off
bigbossClose returns sound and hdrender settings
SlamitBigScore big boss slamit bigscore support
CloseSlam close slamit pinball
PauseFP fp pausing - executed on exit key
PauseVP vp pausing - executed on exit key
ShowFP close player and show editor - edit key
ShowVP close player and show editor - edit key
SetSaveFPNeeded set flag to save fp table on exit
CloseFP closes fp
CloseVP closes vp
CreateLoadScreen loading screen loop with slider, closes nag messages
PrintScreen saves screenshot in media directory
CreateBlackScreen does print screen of fp table and shows it on the screen
CreatePauseScreen shows blue PAUSED image
CreateExitScreen creates exiting in 321 screens
ExitScreen exit screen loop, draws pause or exit screens and exits from fp/vp
ExitScript kills all gui's, activates hyperpin
REST OF SCRIPT
- scripts for enabling/disabling cursor and reading ini files
CaptureScreen - scripts for screen capture
HISTORY
1.295 wip 2
+ add sleep after printscreen
+ add sleep during winactivate of vpinball, dmd and backglass
+ put winactivate outside of loading screen
+ enable other exe names
+ read logical and phyisical key state
+ win activate of secondary fp window (backglass) - doesn't help
+ put version in usage - double click on fplaunch.exe to get version
+ bigboss additions (more exe files, sound mods ...)
+ support for slamit pinball
1.295 wip 3
+ winactivates removed (you have to set exe to nt4sp5 comp mode)
+ fix runtime error on close (you have to 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 so it's not script related
+ shorter time for esc screens
+ win activate on nag screens brings them to focus and closes them
1.295 wip 4
+ fix dmd not visible behind playfield
+ put all rosve and bigboss code to functions
+ write a code map
+ winactivate of fp after pause and printscreen
+ fix winactivate on z screen buffer message (msg stays in back)
+ fgi keys mapped to enter for slamit bigscore pinball
if you don't use slamit you can remove them
1.295 wip 5
+ save printscreen-a under name taken from description
+ quick launch gui from HL 2.0
+ options do not get overwritten
+ menus from sam
+ show instructions and flyer on pause
+ fix slow down after close (when vp is still closing) - fixed -
you have to wait a little till windows free memory
1.295 wip 6
+ pauseVPinball key changed to pauseKey since it is not just for VP
+ pauseKey acts exactly the same as exitEmulatorKey (long press also)
so now you can have two keys for opening and exiting menus (Esc and p)
and two keys for menu items activation (1 and enter)
or you can use some gamepad keys Joy1, 2Joy3, ...
+ instructions are much, much bigger
+ flyer is bigger, and if works with different dimensions images for same table
+ loading menu is merged from sam's version
+ some parts of the code are optimized (draw image by the book), some are not
+ lots of work and testing so that you can always use exit, enter, flyer and instr keys
for example you can press flyer to open flyer directly or go through menus with enter
same with instructions
you can also switch from flyer to instructions
you can close flyer with exit, enter or flyer key, same for instructions
all of this will work in vp and fp
+ ... what else, uhmmmmm let me think - yes loading menu - something was hiding
loading slider (probably vp) and unhiding taskbar - this is both fixed
so taskbar is hidden every few secs and slider is unhiden
+ focus problem with loading screen - while slider is on the screen
every few seconds we try to activate vp (avoiding dmd hack)
also after aprox. 25 secs. we just close loading screen unconditionally
also on exit key (or pause key) we close loading screen unconditionally
and after close of loading screen there is a one sec sleep and
winactivate in a loop so now you should get perfect focus on every vp game
+ debug mode - lot's of things was written to log file, I also added tool tip
on top of the screen - but nothing is written anywhere by default
only if you enable it with this option in settings.ini
1.295 wip 7
+ fixed memory leak
+ swf draws in same resolution, not double, faster, better image
+ support for many instructions cards swf, bmp, png, jpg, gif format
1.295 wip 8
+ fixed b2s close bug
+ ledwiz support added, for more info check:
http://www.vpforums.org/index.php?showtopic=16186&hl=
+ support for different names for hyperpin.exe
TO DO:
- change key names to exitkey exitkey1 and startkey startkey1 for simlicity
- remove usepause useexitasapuse useexitmenu options for simplicitiy
- use prerotated menu images for simplicity
- always use draw image by the book function for simplicity
- put every repeating code to subroutines for simplicity
- change instruction card menu item to instructions
- enable png instructions
- compile a set of png instructions and replay score cards
and helps for setting replay levels, and tactics help, and ...
(hopefully somebody will do this eventually)
- test service menu
- fix late printscreen in fp
- fp auto positioning
*/
SoundPlay menu.wav
#SingleInstance force ;Prevent multiple instances
#InstallKeybdHook
SetTitleMatchMode 2 ;Use relaxed title matching
;#InstallMouseHook
;#UseHook ; this one breaks long press functionality for gamepad button mapped to Esc!!!
;#KeyHistory 500
#MaxThreadsPerHotkey 1
;#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
#Include, Gdip.ahk
#Include, Com.ahk
;------------------------------------------------------------------------------;
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus Error!, Gdiplus failed to start. Please ensure you have GDip.ahk In HyperFPLaunch dir
ExitApp
}
toLog("GDI+ Initialised")
; start com
COM_Init()
COM_AtlAxWinInit()
Log("COM Standard Library Initialised")
;************************************************* ******************************
;* EDIT BELOW THIS POINT AT YOUR OWN RISK *
;************************************************* ******************************
;------------------------------------------------------------------------------;
; GET PARAMATERS AND SET HOTKEYS ;
;------------------------------------------------------------------------------;
hyperini = %A_ScriptDir%\Settings\Settings.ini
picDir = %A_ScriptDir%\Media\HyperPin\Images\
IniRead, lastSystem, %hyperini%, LastLoad, system
IniRead, lastTable, %hyperini%, LastLoad, table
;CHECKING FOR 2 PARAMS, IF NOT THEN OPEN QuickLaunch dialog box
if 0 < 2
{
GoSub QuickLaunch
} Else {
systemName = %1%
tableName = %2%
}
If (systemName != lastSystem OR tableName != lastTable) {
IniWrite, %systemName%, %hyperini%, LastLoad, system
IniWrite, %tableName%, %hyperini%, LastLoad, table
}
databaseFile = %A_Scriptdir%\Databases\%systemName%\%systemName%. xml
;------------------------------------------------------------------------------;
; 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
IniRead, iniTableImagePath, %hyperini%, %systemName%, Table_Image_Path
tableImagePath := GetFullName(iniTableImagePath)
IniRead, iniBackglassImagePath, %hyperini%, %systemName%, Backglass_Image_Path
backglassImagePath := GetFullName(iniBackglassImagePath)
if (systemName = "Future Pinball")
romExtension = fpt
else
romExtension = vpt
GoSub, CheckPaths
iniKeys =
(
[FPLaunch]
; default settings, if you don't have them they will be added to your settings.ini file
; ***** don't change them here - edit your settings.ini file!!!!! *****
exitScriptKey = q & s ; kill script key
exitEmulatorKey = Esc ; main exit key, can be joy key also (Joy1)
hideCursor = true
hideDesktop = true
hideTaskbar = true
toggleCursorKey = t
useExitScreen = true ; show exit321 countdown on long press
usePauseKey = true
useLoadScreen = true ; show loading slider
pauseKey = p ; former pauseVPinball key, works same as exit key
fadespeed = 25
useExitAsPause = true
exitEmulatorKey2 = 1 ; key for entering into menus
exitEmulatorKey3 = Enter ; and another one
pauseFPKey = RButton ; pause in FP
saveFPTables = true
editTableKey = !F4 ; close table and go to vp/fp editor
printScreenKey = o
pfScreenNum = 1 ; playfield Screen Number (used for print screen)
bgScreenNum = 2 ; backglass Screen Number (used for print screen)
useExitMenu = true
upKey = LShift
downKey = RShift
instructionsKey = i
flyerKey = f
hyperScale = 0.75
debugMode = false
ledwiz = false
hyperpinexe = hyperpin.exe
)
Loop, parse, iniKeys, `n,`r`t" "
{
StringSplit, iniKey, A_LoopField, =;, %A_Space%%A_Tab%
if (iniKey0 > 1 And iniKey1 != "") {
IniRead, %iniKey1%, %hyperini%, FPLaunch, %iniKey1%
If (%iniKey1% = "ERROR" Or %iniKey1% = "") {
%iniKey1% = %iniKey2%
IniWrite, %iniKey2%, %hyperini%, FPLaunch, %iniKey1%
}
}
}
toLog("Ini files parsed")
Hotkey, %exitScriptKey%, ExitScript
Playfield_Rotation := 270
StrX( H, BS="",BO=0,BT=1, ES="",EO=0,ET=1, ByRef N="" ) { ; | by Skan | 19-Nov-2009
Return SubStr(H,P:=(((Z:=StrLen(ES))+(X:=StrLen(H))+StrLe n(BS)-Z-X)?((T:=InStr(H,BS,0,((BO
<0)?(1):(BO))))?(T+BT):(X+1)):(1)),(N:=P+((Z)?((T:= InStr(H,ES,0,((EO)?(P+1):(0))))?(T-P+Z
+(0-ET)):(X+P)):(X)))-P) ; v1.0-196c 21-Nov-2009 www.autohotkey.com/forum/topic51354.html
}
q = "
FileRead, XML, %databaseFile% ;load database xml for parsing
temptableDescription := StrX( XML, q . tableName . q ,1,0,"</description>",1,14)
tableDescription := StrX( temptableDescription, "<description>" ,1,13,"",1,1)
shortDescription := StrX( tableDescription, "" ,1,1,"(",1,0)
pfName = %tableImagePath%%tableDescription%.png
bgName = %backglassImagePath%%tableDescription%.png
loadspeed := fadespeed * 10
if (ledwiz = "true")
Run, "%A_ScriptDir%\ledclear.bat",,hide
; we use loading screeen dimensions for all screens (load, exit, pause)
gui, 99:add,picture,hwndloadpic, %picDir%loading.png
controlgetpos,,,hLoad,wLoad,,ahk_id %loadpic%
gui, 99:destroy
wLoad := Round(wLoad*A_ScreenWidth/1920)
xLoad := Round(A_ScreenWidth/2-(wLoad/2))
hLoad := Round(hLoad*A_ScreenHeight/1080)
yLoad := Round(A_ScreenHeight/2-(hLoad/2))
wLoadProgress := Round(20*A_ScreenWidth/1920)
xLoadProgress := Round(145*A_ScreenWidth/1920)
hLoadProgress := Round(194*A_ScreenHeight/1080)
yLoadProgress := Round(288*A_ScreenHeight/1080)
; old flags
ProgBar = 0
Paused = 0
Exiting = 0
; new flags
menuOn = 0
menuItem = 1
serviceMenuOn = 0
instructionsOn = 0
flyerOn = 0
loading = 1
; flyer images
flyerpages = 0
Loop, %A_ScriptDir%\Media\HyperPin\Flyer Images\%shortDescription%*, ,1
{
flyerpages++
flyerPic%A_Index% := A_LoopFileFullPath
}
If (flyerpages > 1) {
flyerPic := flyerPic2
flyer = 2
} Else If (flyerpages = 1) {
flyerPic := flyerPic1
flyer = 1
} Else {
flyerPic1 := picDir . "FlyerMissing.png"
flyerPic := flyerPic1
flyer = 1
flyerpages = 1
}
toLog("Flyer Pages Parsed")
; instructions images
instrpages = 0
Loop, %A_ScriptDir%\Media\HyperPin\Instruction Cards\%shortDescription%*, ,1
{
instrpages++
instrPic%A_Index% := A_LoopFileFullPath
}
If (instrpages > 0) {
instrPic := instrPic . instrpages
instr := instrpages
} Else {
instrPic1 := picDir . "instructMissing.png"
instrPic := instrPic1
instr = 1
instrpages = 1
}
toLog("Instruction Pages Parsed")
if (hideCursor = "true") {
;MouseMove 960, 540
MouseMove %A_ScreenWidth%/2, %A_ScreenHeight%/2
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 ; what is this for?
; if somebody needs it uncomment it
;------------------------------------------------------------------------------;
; RUN SYSTEM ;
;------------------------------------------------------------------------------;
;**********************************FUTURE PINBALL***********************************
if (systemName = "Future Pinball") {
if(tableName = "BigScore") { ; bigboss slamit bigscore support
GoSub SlamitBigScore
} else {
if (useExitScreen = "true")
exitmeth = ExitScreen
else if (useExitAsPause = "true")
exitmeth = PauseFP
else
exitmeth = CloseFP
; fp needs $ or it will not get the key
; * enables any modifier (shift, ctrl, alt)
; * breaks long press functionality - removed
Hotkey $%exitEmulatorKey%, %exitmeth%
if (usePauseKey = "true")
Hotkey, $%pauseKey%, %exitmeth%
Hotkey, $%editTableKey%, ShowFP
Hotkey, $%printScreenKey%, printScreen
Hotkey, $%instructionsKey%, Instructions
Hotkey, $%flyerKey%, Flyer
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
}
loading = 0
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")
{
GoSub bigboss ; bigboss support for different exe, sound levels and hdrender off
GoSub rosve ; rosve support for B2S active backglasses
Run, "%emuPath%\%executable%" /play -"%tablePath%%tableName%.vpt",, Min UseErrorLevel
;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 sometimes
If (useExitScreen = "true") ; * breaks long press functionality
exitmeth = ExitScreen
Else If (useExitAsPause = "true")
exitmeth = PauseVP
Else
exitmeth = CloseVP
Hotkey, $%exitEmulatorKey%, %exitmeth%
If (usePauseKey = "true")
Hotkey, $*%pauseKey%, %exitmeth%
Hotkey, $%editTableKey%, ShowVP
Hotkey, $%printScreenKey%, printScreen
Hotkey, $%instructionsKey%, Instructions
Hotkey, $%flyerKey%, Flyer
If (useLoadScreen = "true") ; draw the loading Gui with wrapped Progress bar
Gosub CreateLoadScreen
Else {
WinWait, ahk_class VPinball
; winhide doesn't work sometimes
WinHide, ahk_class VPinball
}
loading = 0
;wait one more sec
WinActivate, ahk_class VPPlayer,,DMD
Sleep 100
;dj loop
Loop {
IfWinActive, ahk_class VPPlayer,,DMD
Break
WinActivate, ahk_class VPPlayer,,DMD
Sleep, 100
}
WinWaitActive, ahk_class VPPlayer,,,DMD
;bring cursor away from taskbar
DllCall("SetCursorPos", int, A_ScreenWidth//2, int, A_ScreenHeight//2)
;bring dmd to front
;don't detect dmd if it is hidden
DetectHiddenWindows off
WinActivate, ahk_class MAME
WinWaitActive, ahk_class MAME,,0
Sleep 100
;dj click on dmd
SetControlDelay -1
ControlClick,, ahk_class MAME
WinWaitActive, ahk_class MAME,,0
Sleep 100
DetectHiddenWindows on
WinActivate, ahk_class VPPlayer,,DMD
Sleep 100
;dj loop again
Loop {
IfWinActive, ahk_class VPPlayer,,DMD
Break
WinActivate, ahk_class VPPlayer,,DMD
Sleep, 100
}
WinWaitActive, ahk_class VPPlayer,,,DMD
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
; You should never come here
; bigboss Slamit support remaps
; - this has to be here, not in procedures, not in normal code
; - ahk stops on first #ifwinactive command
; Remap keys:
; enter to down arrow for plunger
; 1 to s for start, 5 to 1 for insert coin
; magnasave, flyer, genre or instructions to enter for menus
; change it to what you have on your cab and recompile
; or remove it if you don't use slamit pinball
#IfWinActive ahk_class SlamIt Pinball - Big Score
RControl::Enter
LControl::Enter
f::Enter
g::Enter
i::Enter
Enter::down
5::1
1::s
#IfWinActive
;------------------------------------------------------------------------------;
; KILL COMMANDS ;
;------------------------------------------------------------------------------;
;************PROBABLY DO NOT NEED TO EDIT THIS AREA*************
CloseProcess:
Hotkey, %exitScriptKey%, Off
Process, Close, %executable%
Process, WaitClose, %executable%
return
;------------------- QuickLaunch functions -------------------
QuickLaunch:
Gui, Add, ComboBox, x12 y100 w266 gsetSystem vsystemName, Visual Pinball|Future Pinball
Gui, Add, ComboBox, x12 y150 w266 h20 r10 vtableName
Gosub getSystem
Gui, Add, Text, x12 y10 w430 h20 , Usage: FPLaunch.ahk/exe "System Name" "Rom Name"
Gui, Add, Text, x12 y40 w350 h30 , Select system name and table name and click the Run button.
Gui, Add, Text, x12 y80 w80 h20 , System Name:
Gui, Add, Text, x12 y130 w220 h20 , Table Name (file name without extension):
Gui, Add, Button, x290 y100 w60 h70 gtestdone vrun, Run
Gui, Show, Center h185 w365, %Version%
GuiControl, Focus, run
While (Test != "done")
{
sleep 500
}
Return
GuiClose:
Gosub exitScript
testdone:
Gui, Submit
Test = done
Return
getSystem:
GuiControl, ChooseString, systemName, %lastSystem%
Gui, Submit, NoHide
Gosub getTables
Return
setSystem:
Gui, Submit, NoHide
Gosub getTables
Return
getTables:
Tables =
ArrayCount = 1
systemsFile := A_ScriptDir . "\Databases\" . systemName . "\" . systemName . ".xml"
Loop, Read, %systemsFile%
{
Pos := RegExMatch(A_LoopReadLine,"name=""(.*)""", SubPat)
If(Pos > 1){
Tables%ArrayCount% := SubPat1
ArrayCount += 1
}
}
ArrayCount -= 1
elements := "|"
Loop %ArrayCount%
{
elements .= Tables%A_Index% . "|"
}
GuiControl,, tableName, %elements%
If (systemName = lastSystem And lastTable != "")
GuiControl, ChooseString, tableName, %lastTable%
Else
GuiControl, Choose, tableName, 1
GuiControl, Focus, run
Gui, Submit, NoHide
Return
;------------------- End of QuickLaunch functions -------------------
; rosve support for B2S active backglasses
rosve:
;--------------------------------------------------------------
;------ check if an active backglass shall be started -----
;--------------------------------------------------------------
StringRight, ending, tableName, 3
if (ending = "B2S")
{
Run, %tablePath%%tableName%.exe, %tablePath%
sleep 200
}
return
rosveClose:
; rosve
; --------------------------------------------------------------
; --- Close the animated backglass -----------------------
; --------------------------------------------------------------
; b2s close bug fix
StringRight, ending, tableName, 3
if (ending = "B2S")
{
WinKill, Form1
}
return
; bigboss support for different exe, sound levels and hdrender off
bigboss:
; 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
}
}
return
bigbossClose:
; 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%}
return
; big boss slamit bigscore support
SlamitBigScore:
Hotkey, $%exitEmulatorKey%, CloseSlam
;setworkingdir, "..\SlamIt\BigScore.exe"
Run, "..\slamit\go.bat", "..\SlamIt"
WinWait, ahk_class SlamIt Pinball - Big Score
Gui, destroy
Process, WaitClose, BigScore.exe
goto ExitScript
return
CloseSlam:
WinClose, ahk_class SlamIt Pinball - Big Score
goto ExitScript
return
PauseFP:
if (Paused = 0) { ; we are enetering pause menu
Paused = 1
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
WinWaitActive, ahk_class FuturePinballOpenGL
Gosub CreateBlackScreen ; we draw printscreen first
if (useExitMenu = "true") {
Gosub ExitMenu ; draw menus - nothing else!
Hotkey, %UpKey%, MoveUp, On
Hotkey, %DownKey%, MoveDown, On
Hotkey, %exitEmulatorKey2%, selectItem, On
Hotkey, %exitEmulatorKey3%, selectItem, On
} else {
Gosub CreatePauseScreen
Hotkey, $%exitEmulatorKey2%, CloseFP, On
Hotkey, $%exitEmulatorKey3%, CloseFP, On
}
} else { ; we are exiting pause menu
Paused = 0
if (useExitMenu = "true") {
Gosub ExitMenu ; close menus or flyer or instr.
Hotkey, %UpKey%, Off
Hotkey, %DownKey%, Off
Hotkey, %exitEmulatorKey2%, Off
Hotkey, %exitEmulatorKey3%, Off
} else {
Gui 1: Destroy
Gui 5: Destroy
Hotkey, $%exitEmulatorKey2%, Off
Hotkey, $%exitEmulatorKey3%, Off
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
}
}
return
PauseVP:
If (Paused = 0) { ; entering pause menu
Paused = 1
if (useExitMenu = "true") {
Gosub ExitMenu ; draw menus
Hotkey, %UpKey%, MoveUp, On
Hotkey, %DownKey%, MoveDown, On
Hotkey, %exitEmulatorKey2%, selectItem, On
Hotkey, %exitEmulatorKey3%, selectItem, On
} else {
Gosub CreatePauseScreen
Hotkey, $%exitEmulatorKey2%, CloseVP, On
Hotkey, $%exitEmulatorKey3%, CloseVP, On
}
} Else { ; exiting pause menu
Paused = 0
if (useExitMenu = "true") {
Gosub ExitMenu ; close menus
Hotkey, %UpKey%, Off
Hotkey, %DownKey%, Off
Hotkey, %exitEmulatorKey2%, Off
Hotkey, %exitEmulatorKey3%, Off
} else {
Gui, Destroy
Hotkey, $%exitEmulatorKey2%, Off
Hotkey, $%exitEmulatorKey3%, Off
}
WinActivate, ahk_class VPPlayer,,DMD
}
return
PauseGame:
toLog("PauseGame Called")
if (systemName = "Visual Pinball")
GoSub, PauseVP
else if (systemName = "Future Pinball")
GoSub, PauseFP
Return
;----------------------------------Exit Menu-----------------------------------;
ExitMenu:
toLog("ExitMenu Called")
If (instructionsOn = 1) ; close instruction card
Gosub Instructions
Else If (flyerOn = 1) ; close flyer
Gosub Flyer
Else If (Paused = 1) { ; show menus
SoundPlay menu.wav
menuOn = 1
menuItem = 1
serviceMenuOn = 0
DMDon = 0
Gui, 2: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 2: Show, Hide
hwExitInfo := WinExist()
Gui, 2: +Lastfound
WinActivate
exitInfoPic = %picDir%exitMenu1b.png
iBitmap := Gdip_CreateBitmapFromFile(exitInfoPic)
iWidth := Gdip_GetImageWidth(iBitmap), iHeight := Gdip_GetImageHeight(iBitmap)
;If (Playfield_Rotation = 90) Or (Playfield_Rotation = 270) {
iscale := A_ScreenHeight/iWidth
sWidth := A_ScreenHeight+1, sHeight := iHeight*iscale
yExitInfo := -1
;}
Gdip_GetRotatedDimensions(sWidth, sHeight, Playfield_Rotation, brWidth, brHeight)
Gdip_GetRotatedTranslation(sWidth, sHeight, Playfield_Rotation, xTranslation, yTranslation)
xExitInfo := A_ScreenWidth-brWidth+1
ihbm := CreateDIBSection(brWidth, brHeight)
ihdc := CreateCompatibleDC()
iobm := SelectObject(ihdc, ihbm)
iG := Gdip_GraphicsFromHDC(ihdc)
Gdip_TranslateWorldTransform(iG, xTranslation, yTranslation)
Gdip_RotateWorldTransform(iG, Playfield_Rotation)
Gdip_SetCompositingMode(iG, 1)
Gdip_SetInterpolationMode(iG, 7)
Gdip_DrawImage(iG, iBitmap, -1, -1, sWidth+2, sHeight+2, 0, 0, iWidth, iHeight)
Gdip_DisposeImage(iBitmap)
UpdateLayeredWindow(hwExitInfo, ihdc, xExitInfo, yExitInfo, brWidth, brHeight)
Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 1: Show, Hide, ExitMenu
hwExit := WinExist()
Gui, 1: +Lastfound
Winactivate
exitmenuPic = %picDir%exitMenu1.png
pBitmap := Gdip_CreateBitmapFromFile(exitMenuPic)
pWidth := Gdip_GetImageWidth(pBitmap), pHeight := Gdip_GetImageHeight(pBitmap)
pscale := ((A_ScreenHeight*hyperScale)/pWidth)
dWidth := pWidth*pscale, dHeight := pHeight*pscale
Gdip_GetRotatedDimensions(dWidth, dHeight, Playfield_Rotation, rWidth, rHeight)
Gdip_GetRotatedTranslation(dWidth, dHeight, Playfield_Rotation, xMTranslation, yMTranslation)
xExitM := (A_ScreenWidth-rWidth)/2, yExitM := (A_ScreenHeight-rHeight)/2
hbm := CreateDIBSection(rWidth, rHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_TranslateWorldTransform(G, xMTranslation, yMTranslation)
Gdip_RotateWorldTransform(G, Playfield_Rotation)
Gdip_SetCompositingMode(G, 1)
Gdip_SetInterpolationMode(G, 7)
Gdip_DrawImage(G, pBitmap, 0, 0, dWidth, dHeight, 0, 0, pWidth, pHeight)
Gdip_DisposeImage(pBitmap)
UpdateLayeredWindow(hwExit, hdc, xExitM, yExitM, rWidth, rHeight)
Gui, 1:Show
Gui, 2:Show
}
Else ; close menus
{
SoundPlay menu.wav
menuOn = 0
serviceMenuOn = 0
DMDon = 0
GoSub closeMenus
Gui, 3:Destroy
Gui, 2:Destroy
Gui, 1:Destroy
if (systemName = "Future Pinball") {
Gui, 5: Destroy
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
}
}
Return
closeMenus:
Gdip_SetCompositingMode(G, 0)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pBitmap)
Gdip_SetCompositingMode(iG, 0)
SelectObject(ihdc, iobm)
DeleteObject(ihbm)
DeleteDC(ihdc)
Gdip_DeleteGraphics(iG)
Gdip_DisposeImage(iBitmap)
return
MenuSwap:
toLog("MenuSwap Called")
;SoundPlay menu.wav
If menuItem = 0
menuItem = 5
If menuItem = 6
menuItem = 1
If (serviceMenuOn = 0) { ; main menu
exitmenuPic = %picDir%exitMenu%menuItem%.png
exitInfoPic = %picDir%exitMenu%menuItem%b.png
toLog("Exit Menu Swapped - Item " . menuItem)
} Else If (serviceMenuOn = 1) { ; service menu
exitmenuPic = %picDir%serviceMenu%menuItem%.png
exitInfoPic = %picDir%serviceMenu%menuItem%b.png
toLog("service Menu Swapped - Item " . menuItem)
}
pBitmap := Gdip_CreateBitmapFromFile(exitMenuPic)
iBitmap := Gdip_CreateBitmapFromFile(exitInfoPic)
Gdip_DrawImage(G, pBitmap, 0, 0, dWidth, dHeight, 0, 0, pWidth, pHeight)
Gdip_DrawImage(iG, iBitmap, 0, 0, sWidth, sHeight, 0, 0, iWidth, iHeight)
Gdip_DisposeImage(pBitmap)
Gdip_DisposeImage(iBitmap)
UpdateLayeredWindow(hwExit, hdc, xExitM, yExitM, rWidth, rHeight)
UpdateLayeredWindow(hwExitInfo, ihdc, xExitInfo, yExitInfo, brWidth, brHeight)
clear("exitmenuPic,exitInfoPic")
Return
selectItem:
toLog("selectItem Called")
If (serviceMenuOn = 0) { ; main menu
If (menuItem = 1) { ; close menu
Gosub %exitmeth%
} Else If (menuItem = 2) { ; instructions
;Gosub %exitmeth%
toLog("Exit Menu Closed - Instructions")
Gosub Instructions
} Else If (menuItem = 3) { ; flyer
;Gosub %exitmeth%
toLog("Exit Menu Closed - Flyer")
Gosub Flyer
} Else If (menuItem = 4) { ; service menu
SoundPlay menu.wav
serviceMenuOn = 1
menuItem = 1
toLog("Exit Menu Swapped - Service")
Gosub MenuSwap
} Else If (menuItem = 5) { ; exit
Gosub %exitmeth%
toLog("Exit Menu Closed - CloseGame")
Goto CloseGame
}
} Else If (serviceMenuOn = 1) { ; service menu
If (menuItem = 1) { ; back
serviceMenuOn = 0
toLog("Service Menu Swapped - Exit")
Gosub MenuSwap
} Else If (menuItem = 2) { ; reset vp - send f3
Gosub %exitmeth%
toLog("Service Menu Closed - F3")
toLog("Attempting to reset Visual Pinball")
If (systemName = "Visual Pinball") {
Send {F3 down}
Sleep 100
Send {F3 up}
}
} Else If (menuItem = 3) { ; resize fp - send scroll lock in case you don't have one :)
Gosub %exitmeth%
toLog("Service Menu Closed - Size FP")
If (systemName = "Future Pinball") {
Send {ScrollLock down}
Sleep 100
Send {ScrollLock up}
}
} Else If (menuItem = 4) {
; focus - not tested!!! wip wip wip wip - should be a function
; should be executed on every exit from menu - not just here
Gosub %exitmeth%
toLog("Service Menu Closed - Focus Windows")
If (systemName = "Visual Pinball") {
toLog("Attempting to Focus Visual Pinball")
DetectHiddenWindows off
IfWinExist, Ahk_Class MAME
{
WinActivate, Ahk_Class MAME
WinWaitActive, Ahk_Class MAME,,2
ControlClick,, Ahk_Class MAME
toLog("Attempting to Focus Visual Pinball DMD")
}
DetectHiddenWindows on
WinSet, Bottom, ,Form1
WinSet, Bottom, ,HGlass1
WinActivate, Ahk_Class VPPlayer,,DMD
WinWaitActive, Ahk_Class VPPlayer,,2
ControlClick, X5 Y5, Ahk_Class VPPlayer,,,,,DMD
} Else If (systemName = "Future Pinball") {
toLog("Attempting to Focus Future Pinball")
WinActivate, Ahk_Class FuturePinballOpenGLSecondary
WinWaitActive, Ahk_Class FuturePinballOpenGLSecondary,,2
toLog("Attempting to Focus Future Pinball DMD")
WinActivate, Ahk_Class FuturePinballOpenGL
WinWaitActive, Ahk_Class FuturePinballOpenGL,,2
}
} Else If (menuItem = 5) { ; go to editor
Gosub %exitmeth%
toLog("Service Menu Closed - Drop to Editor")
If (systemName = "Visual Pinball")
Gosub ShowVP
Else If (systemName = "Future Pinball")
Gosub ShowFP
}
}
Return
;------------------------------End of exitmenu -------------------------------;
;----------------------------------Flyer---------------------------------------;
Flyer:
SoundPlay menu.wav
toLog("Flyer Called")
If (flyerOn = 0) { ; show flyer
If (menuOn = 0) And (instructionsOn = 0) And (systemName = "Future Pinball") {
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
WinWaitActive, ahk_class FuturePinballOpenGL
Gosub CreateBlackScreen ; we draw printscreen first
}
If (menuOn = 1)
Gosub closeMenus
flyerOn = 1
paused = 1
instructionsOn = 0
toLog("Flyer Create")
; put hotkeys in sub !!!
Hotkey, %UpKey%, MoveUp, On
Hotkey, %DownKey%, MoveDown, On
; start and plunger will close flyer
Hotkey, %exitEmulatorKey2%, %exitmeth%, On
Hotkey, %exitEmulatorKey3%, %exitmeth%, On
; show footer first, then flyer
; show footer image in gui 2
flyerInfoPic = %picDir%flyerb.png
iBitmap := Gdip_CreateBitmapFromFile(flyerInfoPic)
Gdip_ImageRotateFlip(iBitmap,3) ; rotate image for 270°
iWidth := Gdip_GetImageWidth(iBitmap)
iHeight := Gdip_GetImageHeight(iBitmap)
iScale := A_ScreenHeight/iHeight
tWidth := iWidth*iScale
tHeight := A_ScreenHeight
Gui, 2: Show,, Footer
DrawImageBTB(2, iBitmap, iWidth, iHeight, tWidth, tHeight, A_ScreenWidth-tWidth+1, 0, 1)
; show flyer in gui 1
Gosub flyerSwap
;msgbox
} Else { ; kill flyer
flyerOn = 0
menuOn = 0
serviceMenuOn = 0
paused = 0
toLog("Flyer Close")
Hotkey, %UpKey%, Off
Hotkey, %DownKey%, Off
Hotkey, %exitEmulatorKey2%, Off
Hotkey, %exitEmulatorKey3%, Off
Gui, 2: Destroy
Gui, 1: Destroy
; wip wip wip wip !!!!! one unique focus function!!!
IfWinExist, Visual Pinball Player,, DMD
{
WinActivate
ControlClick,, Ahk_Class VPPlayer
;WinSet, Bottom, ,Form1 ;send to back b2s backglass so mame dmd is on top ;ahk_class is impossibly long!
;WinSet, Bottom, ,HGlass1 ;then backglass image from hyperpin as above ;ahk_class ThunderRT6FormDC clashes with HyperPin
} Else IfWinExist, Ahk_Class FuturePinballOpenGL
{
If (systemName = "Future Pinball") {
Gui, 5: Destroy
WinActivate, Ahk_Class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
}
}
toLog("Flyer Closed")
}
Return
MoveUp: ; used for exitmenu as well, probably will be used for instr. also
SoundPlay menu.wav
toLog("MoveUp Called")
If (flyerOn = 1) {
flyer--
Gosub flyerSwap
;Gui, 1: Show
} Else If (instructionsOn = 1) {
instr--
Gosub instrSwap
} Else If (menuOn = 1) {
menuItem--
Gosub MenuSwap
}
Return
MoveDown: ; used for exitmenu as well, probably will be used for instr. also
SoundPlay menu.wav
toLog("MoveDown Called")
If (flyerOn = 1) {
flyer++
Gosub flyerSwap
;Gui, 1: Show
} Else If (instructionsOn = 1) {
sleep 1
instr++
Gosub instrSwap
} Else If (menuOn = 1) {
menuItem++
Gosub MenuSwap
}
Return
flyerSwap:
toLog("flyerSwap Called")
If (flyer = 0) {
flyer := flyerpages
if (flyerpages = 1)
return
}
If (flyer > flyerpages) {
flyer = 1
if (flyerpages = 1)
return
}
flyerPic := flyerPic%flyer%
pBitmap := Gdip_CreateBitmapFromFile(flyerPic)
Gdip_ImageRotateFlip(pBitmap,3) ; rotate image for 270°
OriginalWidth := Gdip_GetImageWidth(pBitmap)
OriginalHeight := Gdip_GetImageHeight(pBitmap)
Ratio := OriginalWidth/OriginalHeight
; we want flyer to be as big as possible
if (OriginalWidth/(A_ScreenWidth*0.8) >= OriginalHeight/(A_ScreenHeight*0.96)) {
Width := A_ScreenWidth*0.8
Height := Width*(1/Ratio)
} else {
Height := A_ScreenHeight*0.96
Width := Height*Ratio
}
xCoo := (A_ScreenWidth*0.85-Width)//2
yCoo := (A_ScreenHeight-Height)//2
Gui, 1: Show,, Flyer
DrawImageBTB(1, pBitmap, OriginalWidth, OriginalHeight, Width, Height, xCoo, yCoo, 0)
;Gui, 2: Show
;Gui, 1: Show
toLog("Flyer Page Turned")
Return
;--------------------------------End of flyer----------------------------------;
;-----------------------------Instruction Cards--------------------------------;
Instructions:
SoundPlay menu.wav
toLog("Instructions Called")
If (instructionsOn = 0) { ; show instructions
If (menuOn = 0) And (flyerOn = 0) And (systemName = "Future Pinball") {
; no menus, print screen and send pause
; put this in sub !!!
WinActivate, ahk_class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
WinWaitActive, ahk_class FuturePinballOpenGL
Gosub CreateBlackScreen ; we draw printscreen first
}
If (menuOn = 1)
Gosub closeMenus
instructionsOn = 1
paused = 1
flyerOn = 0
toLog("Instruction Card Create")
;Gui, 2: Destroy
Hotkey, %UpKey%, MoveUp, On
Hotkey, %DownKey%, MoveDown, On
; start and plunger will close instructions
Hotkey, %exitEmulatorKey2%, %exitmeth%, On
Hotkey, %exitEmulatorKey3%, %exitmeth%, On
; show footer first, then instructions
; show footer image in gui 2
flyerInfoPic = %picDir%instructb.png
iBitmap := Gdip_CreateBitmapFromFile(flyerInfoPic)
Gdip_ImageRotateFlip(iBitmap,3) ; rotate image for 270°
iWidth := Gdip_GetImageWidth(iBitmap)
iHeight := Gdip_GetImageHeight(iBitmap)
iScale := A_ScreenHeight/iHeight
tWidth := iWidth*iScale
tHeight := A_ScreenHeight
Gui, 2: Show,, Footer
DrawImageBTB(2, iBitmap, iWidth, iHeight, tWidth, tHeight, A_ScreenWidth-tWidth+1, 0, 1)
; show instr in gui 1
Gosub instrSwap
} Else { ; hide instructions
instructionsOn = 0
menuOn = 0
serviceMenuOn = 0
paused = 0
toLog("Instruction Card Close")
; up and down not needed for now (it will be after we extend instructions)
Hotkey, %UpKey%, Off
Hotkey, %DownKey%, Off
Hotkey, %exitEmulatorKey2%, Off
Hotkey, %exitEmulatorKey3%, Off
Gui, 2: Destroy
Gui, 1: Destroy
; wip wip wip wip wip focus code should be subroutine !!!
IfWinExist, Visual Pinball Player,, DMD
{
WinActivate ; winactivate what???
WinWaitActive, Ahk_Class VPPlayer,,2
ControlClick, X5 Y5, Ahk_Class VPPlayer,,,,,DMD
} Else IfWinExist, Ahk_Class FuturePinballOpenGL
{
If (systemName = "Future Pinball") {
Gui, 5: Destroy
WinActivate, Ahk_Class FuturePinballOpenGL
WinWaitActive, ahk_class FuturePinballOpenGL
Send {%pauseFPKey%}
}
WinActivate, Ahk_Class FuturePinballOpenGL
}
toLog("Instruction Card Closed")
}
Return
instrSwap:
toLog("instrSwap Called")
If (instr = 0) {
instr := instrpages
if (instrpages = 1)
return
}
If (instr > instrpages) {
instr = 1
if (instrpages = 1)
return
}
instrPic := instrPic%instr%
StringRight, ending, instrPic, 3
if (ending = "swf") { ; we have swf image
Width := A_ScreenHeight*0.95
Height := A_ScreenHeight*0.95
SysGet, VirtualWidth, 78
SysGet, VirtualHeight, 79
;Gui, 1: Destroy
Gui, 1: +LastFound -Caption +AlwaysOnTop -SysMenu +E0x80000
Gui, 1: Show, w%Width% h%Height% x%VirtualWidth% y%VirtualHeight%, Instruction Card
;Gui, 1: Margin, 0 ,0
;Gui, 1: Color, EEAA99
;Gui, 1: Add, ActiveX, w%Width% h%Height% vpwb, ShockwaveFlash.ShockwaveFlash
Gui, 1: +LastFound
WinActivate
getInstructFromDisk = %instrPic%
;pwb.wmode := "direct" ;window/opaque/direct/transparent/gpu
;pwb.scale := "Default" ;noborder/default/exactfit/noscale
;pwb.bgcolor := "#EEAA99"
;pwb.Movie := "file:///" . getInstructFromDisk
SwfWnd := WinExist()
hCtrl := COM_AtlAxCreateContainer(SwfWnd, 0, 0, Width, Height)
COM_AtlAxAttachControl(psf := COM_ActiveXObject("{D27CDB6E-AE6D-11cf-96B8-444553540000}"), hCtrl)
COM_Invoke(psf, "Menu=", "0")
COM_Invoke(psf, "Movie=", "file:///" . getInstructFromDisk)
COM_Invoke(psf, "bgcolor=", "#EEAA99")
pBitmap := Gdip_BitmapFromHWND(SwfWnd)
;Gdip_GetRotatedDimensions(Width, Height, Playfield_Rotation, rWidth, rHeight)
Gdip_GetRotatedTranslation(Width, Height, Playfield_Rotation, xTranslation, yTranslation)
hbm := CreateDIBSection(Width,Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc), Gdip_SetInterpolationMode(G, 7)
Gdip_TranslateWorldTransform(G, xTranslation, yTranslation)
Gdip_RotateWorldTransform(G, Playfield_Rotation)
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, Width, Height)
pBitmapOut := Gdip_CreateBitmap(Width, Height)
E := Gdip_BitmapReplaceColor(pBitmap, pBitmapOut, 0xFFEEAA99, 0x00000000, 1)
Gdip_GraphicsClear(G) ;make note of this - prob needs to be added to Menu And countdown
Gdip_DrawImage(G, pBitmapOut)
Gdip_DisposeImage(pBitmap)
Gdip_ResetWorldTransform(G)
Gdip_DisposeImage(pBitmapOut)
UpdateLayeredWindow(SwfWnd, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
COM_Release(psf)
} Else { ; show instructions not found or some other image
; new flyer code
pBitmap := Gdip_CreateBitmapFromFile(instrPic)
Gdip_ImageRotateFlip(pBitmap,3) ; rotate image for 270°
OriginalWidth := Gdip_GetImageWidth(pBitmap)
OriginalHeight := Gdip_GetImageHeight(pBitmap)
Ratio := OriginalWidth/OriginalHeight
; we want instr to be as big as possible
if (OriginalWidth/(A_ScreenWidth*0.8) >= OriginalHeight/(A_ScreenHeight*0.96)) {
Width := A_ScreenWidth*0.8
Height := Width*(1/Ratio)
} else {
Height := A_ScreenHeight*0.96
Width := Height*Ratio
}
xCoo := (A_ScreenWidth*0.85-Width)//2
yCoo := (A_ScreenHeight-Height)//2
Gui, 1: Show,, instr
DrawImageBTB(1, pBitmap, OriginalWidth, OriginalHeight, Width, Height, xCoo, yCoo, 0)
;Gui, 2: Show
;Gui, 1: Show
/*
; old code
Gui, 1: Destroy
Gui, 1: +LastFound -Caption +AlwaysOnTop -SysMenu +E0x80000
Gui, 1: Show,, Instruction Card
SwfWnd := WinExist()
Gui, 1: +LastFound
WinActivate
instructPic := instrPic
pBitmap := Gdip_CreateBitmapFromFile(instructPic)
OriginalWidth := Gdip_GetImageWidth(pBitmap), OriginalHeight := Gdip_GetImageHeight(pBitmap)
Ratio := OriginalWidth/OriginalHeight
If (OriginalWidth >= A_ScreenWidth*hyperScale) || (OriginalHeight >= A_ScreenHeight*hyperScale)
{
If (OriginalWidth >= OriginalHeight)
Width := A_ScreenWidth*hyperScale, Height := Width*(1/Ratio)
Else
Height := A_ScreenHeight*hyperScale, Width := Height*Ratio
}
Else
Width := OriginalWidth, Height := OriginalHeight
Gdip_GetRotatedDimensions(Width, Height, Playfield_Rotation, RWidth, RHeight)
Gdip_GetRotatedTranslation(Width, Height, Playfield_Rotation, xTranslation, yTranslation)
hbm := CreateDIBSection(RWidth, RHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc), Gdip_SetInterpolationMode(G, 7)
Gdip_TranslateWorldTransform(G, xTranslation, yTranslation)
Gdip_RotateWorldTransform(G, Playfield_Rotation)
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight)
Gdip_DisposeImage(pBitmap)
Gdip_ResetWorldTransform(G)
UpdateLayeredWindow(SwfWnd, hdc, (A_ScreenWidth-RWidth-300)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
Gdip_DeleteGraphics(G)
*/
}
toLog("instr Page Turned")
Return
;---------------------------End of instruction card----------------------------;
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
MouseMove 200,200
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,,DMD
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
MouseMove 200,200
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
GoSub rosveClose
;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
GoSub bigbossClose
GoSub, ExitScript
return
CloseGame:
toLog("CloseGame Called")
if (systemName = "Visual Pinball")
GoSub, CloseVP
else if (systemName = "Future Pinball")
GoSub, CloseFP
Return
; draw image by the book - destroys bitmap also
DrawImageBTB(guiNum, pBitmap, origWidth, origHeight, tgtWidth, tgtHeight, xCoo=0, yCoo=0, CompMode=0) {
;Gui, %guiNum%: Show, Hide, Flyer
Gui, %guiNum%: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, %guiNum%: Show
hwnd1 := WinExist()
; why is this ???
;Gui, 1: +LastFound
;WinActivate
; no need for bitmap since we have it already
; if we need to rotate bitmap calling script can to it also
;pBitmap := Gdip_CreateBitmapFromFile("background.png")
;Width := Gdip_GetImageWidth(pBitmap), Height := Gdip_GetImageHeight(pBitmap)
hbm := CreateDIBSection(tgtWidth, tgtHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetCompositingMode(G, CompMode)
Gdip_SetInterpolationMode(G, 7)
Gdip_DrawImage(G, pBitmap, 0, 0, tgtWidth, tgtHeight, 0, 0, origWidth, origHeight)
UpdateLayeredWindow(hwnd1, hdc, xCoo, yCoo, tgtWidth, tgtHeight)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pBitmap)
}
CreateLoadScreen:
SetTitleMatchMode 2 ;Use relaxed title matching
Gui, Destroy ; kill Gui blackScreen
toLog("LoadScreen Called")
Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 1: Show,, Loading
hwLoad := WinExist()
loadPic = %picDir%loading.png
pBitmap := Gdip_CreateBitmapFromFile(loadPic)
pWidth := Gdip_GetImageWidth(pBitmap)
pHeight := Gdip_GetImageHeight(pBitmap)
scale := ((A_ScreenHeight*hyperScale)/pWidth)
sWidth := Round(pWidth*scale), sHeight := Round(pHeight*scale)
Gdip_GetRotatedDimensions(sWidth, sHeight, Playfield_Rotation, rWidth, rHeight)
Gdip_GetRotatedTranslation(sWidth, sHeight, Playfield_Rotation, xTranslation, yTranslation)
xLoad := Round((A_ScreenWidth-rWidth)/2), yLoad := Round((A_ScreenHeight-rHeight)/2)
hbm := CreateDIBSection(rWidth, rHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(G, 7)
Gdip_TranslateWorldTransform(G, xTranslation, yTranslation)
Gdip_RotateWorldTransform(G, Playfield_Rotation)
Gdip_DrawImage(G, pBitmap, 0, 0, sWidth, sHeight, 0, 0, pWidth, pHeight)
Gdip_DisposeImage(pBitmap)
Gdip_ResetWorldTransform(G)
UpdateLayeredWindow(hwLoad, hdc, xLoad, yLoad, rWidth, rHeight)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gui, 2: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 2: Show, NA, Loading
hwLoadprog := WinExist()
progPic = %picDir%loadProgress.png
pBitmap := Gdip_CreateBitmapFromFile(progPic)
pLWidth := Gdip_GetImageWidth(pBitmap), pLHeight := Gdip_GetImageHeight(pBitmap)
sLWidth := Round(pLWidth*scale), sLHeight := Round(pLHeight*scale)
Gdip_GetRotatedDimensions(sLWidth, sLHeight, Playfield_Rotation, rLWidth, rLHeight)
Gdip_GetRotatedTranslation(sLWidth, sLHeight, Playfield_Rotation, xTranslation, yTranslation)
xLoadProgress := Round(rWidth/6*5+xLoad-rLWidth),yLoadProgress := Round(rHeight/3*2+yLoad-rLHeight)
pinend := Round(rHeight/3*2+yLoad-rLHeight),pinstart := Round(rHeight/3+yLoad)
hbm := CreateDIBSection(rLWidth, rLHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(G, 7)
dir = 2
pinrot := Playfield_Rotation
DetectHiddenWindows Off
;;;Gui, 99:Destroy ??? no need for this
SetTimer, MoveProgress, %fadespeed%
Loop {
Sleep %loadspeed%
; nag screens removal
toLog("Loading Loop "A_Index)
ifWinExist, Please
{ ; first time run nag screen
WinActivate, Please
IfWinActive, Please
{ ; dj
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
{
WinActivate, Game Info
IfWinActive, Game Info
{
Send {Enter}
Send {Enter}
}
} else ifWinExist, Notice
{ ; sound warnings (antar)
WinActivate, Notice
IfWinActive, Notice
{
Send {Enter}
Send {Enter}
}
} else ifWinExist, VBScript
{ ; errors in vb script
WinActivate, VBScript
IfWinActive, VBScript
{
Send {Enter}
}
; following ifs break focus on start so had to be removed
; } else ifWinExist, UltraVP
; { ; ultra vp warning - error in xml
; WinActivate, UltraVP
; IfWinActive, UltraVP
; {
; Send {Enter}
; }
; } else ifWinActive, ahk_class TBackglass
; { ; uvp stole focus
; msgbox 1
; WinActivate, ahk_class VPPlayer
; msgbox 2
; next if works but removed just in case (made problems for dj on win7)
; if you have some errors open table directly
; } else ifWinExist, Error
; { ; serious error (z buffer)
; ; we have some error and we want to see it so we don't send Enter
; ;Send {Enter}
; Gui, Destroy
; WinActivate, Error
; WinWaitActive, Error
; SystemCursor("On")
; WinWaitClose, Error
; WinClose, ahk_class VPinball
; WinClose, ahk_class FuturePinball
; Process, WaitClose, %executable%
; ExitApp
}
if (systemName = "Visual Pinball") {
IfWinActive, Visual Pinball Player,,DMD
Break
} else {
IfWinActive, ahk_class FuturePinballOpenGL
Break
}
; try to get focus every ~five seconds
if (Mod(A_Index, 20) = 0) {
WinActivate, ahk_class VPPlayer,,DMD
WinActivate, ahk_class FuturePinballOpenGL
}
; after ~25 seconds close unconditionally
if (Mod(A_Index, 100) = 0)
Break
; close loading slider unconditionally on exit key
if (loading = 0)
Break
; hide taskbar again (vp unhides taskbar!!!)
if (hideTaskbar = "true")
{
WinHide, ahk_class Shell_TrayWnd
WinHide, Start ahk_class Button
}
}
SetTimer, MoveProgress, Off
SelectObject(hdc, obm)
DeleteObject(hbm), DeleteDC(hdc), Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pBitmap)
Gui, 2:Destroy
Gui, 1:Destroy
Return
MoveProgress:
yLoadProgress := (yLoadProgress - dir)
If (yLoadProgress > pinend) Or (yLoadProgress < pinstart)
dir := -(dir)
Gdip_TranslateWorldTransform(G, xTranslation, yTranslation)
Gdip_RotateWorldTransform(G, pinrot)
Gdip_DrawImage(G, pBitmap, 0, 0, sLWidth, sLHeight, 0, 0, pLWidth, pLHeight)
Gdip_DisposeImage(pBitmap)
Gdip_ResetWorldTransform(G)
dif := (rLHeight-sLHeight)/2
dif := -dif
movedyLoadProgress := Round(yLoadProgress+dif)
movedxLoadProgress := Round(xLoadProgress+dif)
UpdateLayeredWindow(hwLoadProg, hdc, movedxLoadProgress+1, movedyLoadProgress, rLWidth, rLHeight)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
Gdip_DeleteGraphics(G)
pinrot := pinrot + dir*5
Gdip_GetRotatedTranslation(sLWidth, sLHeight, pinrot, xTranslation, yTranslation)
Gdip_GetRotatedDimensions(sLWidth, sLHeight, pinrot, rLWidth, rLHeight)
pBitmap := Gdip_CreateBitmapFromFile(progPic)
hbm := CreateDIBSection(rLWidth, rLHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(G, 7)
; this had to be added cause vp would hide loading slider during load
; remember we are waiting for vp to take focus so slider must not take focus
Gui, 2: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 2: Show, NA, Loading
Return
PrintScreen:
pBitmap := Gdip_BitmapFromScreen(pfScreenNum)
Gdip_ImageRotateFlip(pBitmap, 2) ;rotate 180, flip 0
Gdip_SaveBitmapToFile(pBitmap, pfName)
Gdip_DisposeImage(pBitmap)
if (systemName = "Future Pinball") {
pBitmap := Gdip_BitmapFromScreen(bgScreenNum)
Gdip_SaveBitmapToFile(pBitmap, bgName)
Gdip_DisposeImage(pBitmap)
}
return
CreateBlackScreen:
pBitmap := Gdip_BitmapFromScreen(pfScreenNum)
Gdip_SaveBitmapToFile(pBitmap, "screen.bmp")
WinActivate, ahk_class FuturePinballOpenGL
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
/*
CaptureScreen(3)
;Sleep 100
WinActivate, ahk_class FuturePinballOpenGL
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
Gui, Color, EEAA99
Gui, Margin, 0, 0
Gui, Add, Picture, w%wLoad% h%hLoad% vPausePic, %picDir%pause.png
Gui +AlwaysOnTop -Caption +Lastfound
Gui, Show, AutoSize Center, pauseScreen
WinSet, TransColor, EEAA99
;Gui, Show
Return
CreateExitScreen: ; exit countdown
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: ; exit countdown
toLog("ExitScreen called")
if (loading = 1) ; just close loading slider
loading = 0
else if (Exiting = 0) { ; check for long press
Exiting = 1
LoopVal = 0
Loop {
;Sleep, 10 ; check if we need this - nope
state = 0
; check for logical and physical state of the exit key
GetKeyState, statel, %exitEmulatorKey%
if statel = D
state = 1
GetKeyState, statep, %exitEmulatorKey%, P
if statep = D
state = 1
; also check for state of the pause key
GetKeyState, statel, %pauseKey%
if statel = D
state = 1
GetKeyState, statep, %pauseKey%, P
if statep = D
state = 1
if (state) {
if (loopVal = 10) {
if (Paused = 1) { ; close pause window before going to countdown
Gosub PauseGame
}
Gosub CreateExitScreen
if (systemName = "Future Pinball")
GoSub CreateBlackScreen
Gui, 3:Show
} else if loopVal = 25
Gui, 2:Show
else if loopVal = 40
Gui, 1:Show
Sleep, %fadespeed%
if (loopVal = 60) {
Gosub CloseGame
break
}
} else {
Exiting = 0
if (LoopVal < 10 && useExitAsPause = "true") { ; short press
Gosub PauseGame
} else { ; long press but not long enough
Loop, 5
Gui, %A_Index%: Destroy
WinActivate, Visual Pinball Player,, DMD
WinActivate, ahk_class FuturePinballOpenGL
}
Transvalue = 0
LoopVal = 0
break
}
LoopVal += 1
}
}
Return
; not used, doesn't work - if hglass is on top uvp and dmd are not visible
ShowHGlass:
WinSet, Region, , ahk_class Shell_TrayWnd
WinSet, AlwaysOnTop, Off, ahk_class Shell_TrayWnd
WinSet, AlwaysOnTop, On, HGlass1
WinActivate, HGlass1
WinActivate, HyperPin
return
ExitScript:
toLog("exitScript Called")
if (ledwiz = "true")
Run, "%A_ScriptDir%\ledset.bat",,hide
Gdip_Shutdown(pToken)
toLog("GDI+ Unloaded")
COM_AtlAxWinTerm()
COM_CoUninitialize()
COM_Term()
Log("COM Standard Library Unloaded")
Loop, 5
Gui, %A_Index%: Destroy
Process, Exist, %hyperpinexe%
PID := errorLevel
;no need to show taskbar on exit, it can only cause problems
;ahk automatically shows taskbar after exit
;it was already commented in 1.10
;if (hideTaskbar = "true") {
;WinShow ahk_class Shell_TrayWnd
;WinShow Start ahk_class Button
;}
if (hideCursor = "true")
SystemCursor("On")
if (PID) {
;WinSet, AlwaysOnTop, Off, ahk_class Shell_TrayWnd
;WinSet, AlwaysOnTop, On, HGlass1
;WinActivate, HGlass1
WinActivate, ahk_pid %PID%
;SetTimer, ShowHGlass, -200
;WinWaitActive, ahk_pid %PID%
}
;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,32 645,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
}
ini_getValue(ByRef _Content, _Section, _Key, _PreserveSpace = False)
{
If (_Section = "")
_Section = (?:\[.*])?
Else
{
_Section = \[\s*?\Q%_Section%\E\s*?]
}
; Note: The RegEx of this Function was rewritten by Mystiq.
RegEx = `aiU)(?:\R|^)\s*%_Section%\s*(?:\R\s*|\R\s*.+\s*=\ s*.*?\s*(?=\R)|\R\s*[;#].*?(?=\R))*\R\s*\Q%_Key%\E\s*=(.*)(?=\R|$)
If RegExMatch(_Content, RegEx, Value)
{
If Not _PreserveSpace
{
Value1 = %Value1% ; Trim spaces.
FirstChar := SubStr(Value1, 1, 1)
If (FirstChar = """" And SubStr(Value1, 0, 1)= """"
Or FirstChar = "'" And SubStr(Value1, 0, 1)= "'")
{
StringTrimLeft, Value1, Value1, 1
StringTrimRight, Value1, Value1, 1
}
}
ErrorLevel = 0
}
Else
{
ErrorLevel = 1
Value1 =
}
Return Value1
}
;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%\%hyperpinexe%
{
MsgBox,48,Error, Must be in same directory as %hyperpinexe%,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
}
IfNotExist, %EmuPath%%Executable%
{
MsgBox,48,Error,Cannot Find %EmuPath%%Executable%,6
Goto ExitScript
}
IfNotExist, %tablePath%%tableName%.%romExtension%
{
MsgBox,48,Error,Cannot Find %tablePath%%tablename%.%romExtension%,6
Goto ExitScript
}
return
toLog(data, filename="log.txt", dtype="string")
{
Global debugMode, paused, menuon, flyeron, instructionson
if (debugMode = "true") {
FormatTime, timenow ,, hh:mm:ss tt |
If dtype=uint
FileAppend, %timenow% %data%, %filename%
If dtype=string
FileAppend, %timenow% %data% p%paused% m%menuon% f%flyeron% i%instructionson%, %filename%
If dtype=uchar
{
y := Chr(%data%)
FileAppend, %timenow% %y%,%filename%
}
FileAppend, `n, %filename%
CoordMode ToolTip
ToolTip %data%, 10, 40, 3
}
}
Clear($) ; Clear("VarName1, VarName2,...")
{
Loop Parse, $, `,, %A_Space%%A_Tab%
%A_LoopField% := ""
}
Gdip_BitmapReplaceColor(pBitmap, ByRef pBitmapOut, Color, ReplaceColor, Variation)
{
global G
global Width
global Height
global SwfWnd
global hdc
static BitmapReplaceColor
If !BitmapReplaceColor
{
MCode_BitmapReplaceColor := "83EC248B4424388B4C243C995683E2038BF103C28B542438C1 FE10C1F90881E6FF00000081E1FF000000C1F8028"
. "9742408894C244085D20F8E0A010000538B5C2430558B6C245 033C903C0578B7C243C03C0894C241C89442430897C2418895 42420837C2440000F8"
. "EB90000008D43018BD32BD083C202895424282BF5894C24440 3C88BD32BD08B442440897424248954242C89442410EB0B8DA 424000000008B74242"
. "48B5424280FB6140A0FB6013BD67E0A8B74241403F53BD67C2 68B74244C2BF53BC67E248B5C244C03DD3BC38B5C24387C0E3 BC67E128B74244C03F"
. "53BC67D088B4424508907EB228B7424440FB6741E03C1E6080 BF28B54242CC1E6080BF00FB6040AC1E6080BF089378344244 40483C10483C704FF4"
. "C241075828B4C241C8B7424148B7C2418037C2430034C2448F F4C2420897C2418894C241C0F851EFFFFFF5F5D5BB80100000 05E83C424C3"
VarSetCapacity(BitmapReplaceColor, StrLen(MCode_BitmapReplaceColor)//2)
Loop % StrLen(MCode_BitmapReplaceColor)//2 ;%
NumPut("0x" SubStr(MCode_BitmapReplaceColor, (2*A_Index)-1, 2), BitmapReplaceColor, A_Index-1, "char")
}
If (Variation > 255 || Variation < 0)
Return -2
E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
If (E1 || E2)
Return -3
E := DllCall(&BitmapReplaceColor, "uint", Scan01, "uint", Scan02, "int", Width, "int", Height, "int", Stride1, "int", Color, "int", ReplaceColor, "int", Variation)
Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
Return 0
}
/* 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 := CreateDIBSection2(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", &ni)
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 := CreateDIBSection2(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", &pi)
Loop, % NumGet(pi)
If NumGet(pi,28*(A_Index-1)+20)=1 && NumGet(pi,28*(A_Index-1)+24)=6
{
pParam := &pi+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)
}
CreateDIBSection2(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
}