This could probably also go in Software, but the threads I found were in Hardware so I'll post it here....

I searched the forums for an hour or so when I was trying to implement this and didn't find a "good" answer, so I'll share my idea.

I wanted my power antenna to raise when my FM app was launched and lower when it closed. I was planning on using a serial relay board anyway to control my Strobe Lights, so I was already part way there in controlling an electro-mechanical with the computer.... I'm using an R85Pro

(http://www.controlanything.com/Merch...ct_Code=R85PRO)

because I needed the 8 relays for my strobes, amps, etc., but a single relay is available.

Because I was writing my own app, controlling the relay was pretty simple if I just wanted to raise with a click and lower with a click, but I wanted to be able to lower the antenna no matter HOW the FM app was closed. This meant I needed to get my app to "watch" for the FM app to close and then lower the antenna.

I'm using the Axife FM software, but this would work with any software and could easily be built as a plug-in for any of the other software out there...

There is freeware .dll out there (dsWatch.dll)

(http://www.it-berater.org/ThueDownloads/index.shtml)

that can be used (I'm using it in a VB app) to watch for a window to close by finding the window by name, and waiting for it to "do something". When it "sees" the window close, it can then execute a command. It is extremely simple, works extremely well, and would work with just about any app.

For all the real "dweebs", here's the sub I use to turn on / watch for the app to close;

------Declarations-----

Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName$, _
ByVal lpWindowName$)

Private Declare Function StartWatch& Lib "dswatch" _
(ByVal PID&, ByVal Address&, _
Optional ByVal ID& = 0, _
Optional ByVal Path$ = "", _
Optional ByVal Stay& = 0)

------Choosing the FM app button-----

Case 2 'FM
'# Load and Get the Axife FM Player Handle
hExpl = Shell("C:\Program Files\Axife FM Player Deluxe\FMEngine.exe", 1)
hExpl = FindWindow("AxifeFMPlayerWndClass", vbNullString)
'# You can ignore this If statement Just some of my debug stuff
If hExpl = 0 Then
MsgBox "Please launch FMEngine!", 64, " DSWATCH:"
Exit Sub
End If
'# Watch for closing Axife
Call StartWatch(hExpl, AddressOf Callback, 33)

'If Antenna is down put it up.
If AntennaState = 0 Then
AntennaState = 1
If MSComm1.PortOpen = True Then
MSComm1.Output = Chr$(254) 'Enter Command Mode on the R85Pro
MSComm1.Output = Chr$(5 + 8) 'Switch relay 6 ON by sending characters to the R85Pro
End If

Here's the process I use with DsWatch to lower the antenna when the app closes.

-----Watch For Process Closing-----

Public Function Callback&(ByVal PID&, ByVal AppID&)
'Debug.Print PID, AppID
Select Case AppID
Case 33: Form1.AntennaOFF
End Select
End Function

----- Lower Antenna-----

Public Sub AntennaOFF()
AntennaState = 0
If MSComm1.PortOpen = True Then
MSComm1.Output = Chr$(254) 'Enter Command Mode on the R85Pro
MSComm1.Output = Chr$(5) 'Switch relay 6 OFF by sending characters to the R85Pro
End If
TextCOMM(5).Text = TextCOMM(5).Text & vbCrLf & "sending antenna ON command...5"
End Sub


There is some pretty good documentation with the .dll, so you can pretty easlily figure it out for your app or whatever app you're using....

There are probably several dozen other ways to do this, I just didn't find them in my search here....

Later!