I got this working. In my setup I'm using MaLa to launch CPV2 and needed a way to close it. I created a 2-line batch file which MaLa calls as "mycpv2.bat -r=%parent%". The batch file looks like this:
mycpv2.bat:
---------------
start test.ahk
cpv2 %1=%2
Test.ahk is an AHK script file that waits for my P2 start button to be pressed (I'm using Joystick 2 Button 7). Once pressed, the script checks to see if CPV2 is the active window. If so, it sends a keypress (I used "_") to CPV2 and loops to make sure CPV2 closes. Once closed, the script kills itself.
Here's my AHK script. The part labelled "2Joy7::" is the relevant part. The other part labelled "`::" just allowed me to find out the title of the CPV2 window and is not necessary.
I tested this out a lot with MaLa tonight and it appears to be stable.
Hope this helps.
-D
test.ahk:
-----------
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
2Joy7::
WinGetActiveTitle, Title
if (Title = "CPV2 Viewer") {
Loop, 100 {
Send _
WinGetActiveTitle, Title
if (Title <> "CPV2 Viewer") {
ExitApp
}
}
}
Return
`::
WinGetActiveTitle, Title
Run Notepad
WinWait Untitled - Notepad
WinActivate
Send %Title%
Return