Author Topic: Detecting if program running?  (Read 1436 times)

Bumble B

  • Jr. Member
  • **
  • Posts: 64
    • Bumble B Gaming
Detecting if program running?
« on: December 08, 2021, 12:02:49 AM »
Ok I've been playing iRacing alot of late and in VR. (RiftS)

What I would like is when iRacing Simulator is running (actully driving) for my Oculus Mirror software to run and when iRacing program (not driving, looking at iRacing UI) isnt running for Oculus Mirror NOT to run or be killed/stop. is this possible?

iRacing when actually racing is called iRacing Simulator (i think) but when the iRacing UI is a diferent window but doesn't look so good to people watching my stream
--
CMDR Bumble B ö7
ASUS P6TD Deluxe, Intel i7 960 @ 3.2GHz, 12Gb G.Skill, Windows 7 SP1 (64bit), ASUS Geforce GTX 970 Strix (4Gb), ThrustMaster T-Flight HOTAS X, Cosair Void RGB USB Gaming Headset, TrackIR, EDDI, Voice Attack, ED Engineer

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Detecting if program running?
« Reply #1 on: December 08, 2021, 12:17:06 AM »
You can use tokens like "{PROCESSEXISTS:}" or "{WINDOWEXISTS:}", to check whether a given application is running.

If you do that in a loop, you can monitor that and perform the actions you need when the state changes.

Bumble B

  • Jr. Member
  • **
  • Posts: 64
    • Bumble B Gaming
Re: Detecting if program running?
« Reply #2 on: December 09, 2021, 04:18:50 AM »
Code: [Select]
Set text [iRacing] to 'iRacing Simulator.exe'
Begin Text Compare : [{PROCESSEXISTS:iRacing}] Equals '1'
    Write [Green] 'GREEN' to log
    Run application 'C:\Program Files\Oculus\Support\oculus-diagnostics\OculusMirror.exe' - wait until it starts
Else
    Write [Red] 'RED' to log
End Condition

Came up with this but still cant get VA to tell if the program is running or not.

Any pointers ?
--
CMDR Bumble B ö7
ASUS P6TD Deluxe, Intel i7 960 @ 3.2GHz, 12Gb G.Skill, Windows 7 SP1 (64bit), ASUS Geforce GTX 970 Strix (4Gb), ThrustMaster T-Flight HOTAS X, Cosair Void RGB USB Gaming Headset, TrackIR, EDDI, Voice Attack, ED Engineer

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Detecting if program running?
« Reply #3 on: December 09, 2021, 04:28:22 AM »
Search results suggest the process name for "iRacing" may be "Iracingsim64dx11.exe"

The "Processes" tab of task manager, counterintuitively, does not necessarily show actual process names. Look in the "Details" tab instead.

Bumble B

  • Jr. Member
  • **
  • Posts: 64
    • Bumble B Gaming
Re: Detecting if program running?
« Reply #4 on: December 09, 2021, 04:56:21 AM »
Damn its been so long since I've been tinkering with VA scripting and totally fell in love with it again.

I guess I can just add to the top line Set Text with a list of programs I would like Oculus Mirror to always run whenever they are active?

American Truck Simulator, Euro Truck Simulator 2  (with the right detailed process name ofcourse)

and then just put the whole thing in a loop to continuously be checking for those processes?
--
CMDR Bumble B ö7
ASUS P6TD Deluxe, Intel i7 960 @ 3.2GHz, 12Gb G.Skill, Windows 7 SP1 (64bit), ASUS Geforce GTX 970 Strix (4Gb), ThrustMaster T-Flight HOTAS X, Cosair Void RGB USB Gaming Headset, TrackIR, EDDI, Voice Attack, ED Engineer

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Detecting if program running?
« Reply #5 on: December 09, 2021, 05:01:00 AM »
You'd need to set different variables, one for each process you want to check, and use the condition builder to actually add a check using the "{PROCESSEXISTS:}" token for each one.

Otherwise, yes.

Bumble B

  • Jr. Member
  • **
  • Posts: 64
    • Bumble B Gaming
Re: Detecting if program running?
« Reply #6 on: December 18, 2021, 01:08:06 PM »
Code: [Select]
Set text [iRacing] to 'iRacingSim64DX11.exe'
Set text [DiRT2] to 'dirtrally2.exe'
Set text [Oculus] to 'Oculus Mirror.exe'
Begin Condition : ([{PROCESSEXISTS:iRacing}] Equals '1' AND [{PROCESSEXISTS:Oculus}] Equals '0') OR ([{PROCESSEXISTS:DiRT2}] Equals '1' AND [{PROCESSEXISTS:Oculus}] Equals '0') OR ([{PROCESSEXISTS:iRacingUI}] Equals '0' AND [{PROCESSEXISTS:Oculus}] Equals '0')
    Write [Green] 'iRacing / Dirt2 / ATS / ETS2  & Miror are Running' to log
    Run application 'C:\Program Files\Oculus\Support\oculus-diagnostics\oculcusbatch.bat' - wait until it starts
Else
    Begin Condition : [{PROCESSEXISTS:iRacing}] Equals '0' OR [{PROCESSEXISTS:DiRT2}] Equals '0'
        Write [Red] 'Listed programs NOT running' to log
        Write [Red] 'RED Oculus not needed' to log
        Execute command, 'kill oculus' (and wait until it completes)
    End Condition
End Condition - Exit when condition met

Above is as far as I've got when I've had the time. I know something isn't quiet right as in its current state it will just keep starting the Oculus mirror everytime its run.

Basically want if certain programs are running then it starts Oculus Mirror and then closes Oculus Mirror if any of those programs stop running. Maybe a loop of every 5 seconds it checks
--
CMDR Bumble B ö7
ASUS P6TD Deluxe, Intel i7 960 @ 3.2GHz, 12Gb G.Skill, Windows 7 SP1 (64bit), ASUS Geforce GTX 970 Strix (4Gb), ThrustMaster T-Flight HOTAS X, Cosair Void RGB USB Gaming Headset, TrackIR, EDDI, Voice Attack, ED Engineer

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Detecting if program running?
« Reply #7 on: December 18, 2021, 02:00:50 PM »
Code: [Select]
Set text [iRacing] to 'iRacingSim64DX11.exe'
Set text [DiRT2] to 'dirtrally2.exe'
Set text [Oculus] to 'Oculus Mirror.exe'
Start Indefinite Loop
    Begin Condition : [{PROCESSEXISTS:iRacing}] Equals '1' OR [{PROCESSEXISTS:DiRT2}] Equals '1'
        Begin Text Compare : [{PROCESSEXISTS:Oculus}] Equals '0'
            Write [Green] 'iRacing / Dirt2 / ATS / ETS2  & Miror are Running' to log
            Run application 'C:\Program Files\Oculus\Support\oculus-diagnostics\oculcusbatch.bat' - wait until it starts
        End Condition
    Else
        Begin Text Compare : [{PROCESSEXISTS:Oculus}] Equals '1'
            Write [Red] 'Listed programs NOT running' to log
            Write [Red] 'RED Oculus not needed' to log
            Execute command, 'kill oculus' (and wait until it completes)
        End Condition
    End Condition
    Pause 5 seconds
End Loop

Take the time to think through the logic you're setting up.