There are 3 things to look at to tell IF a Gcode FILE is loaded and running. IT MAY NOT  work IF a macro (M6) is running a tool change
 GetOemLed(172) ----->  IF TRUE then a Gcode is loaded
 GetLED(4)           -----> IF TRUE then CYCLE START is active
 GetLed(5)           -----> IF  TRUE then in FEEDHOLD (pause)
Note there are instances when Mach3 is running a GCODE that you can be in FEEDHOLD and the Cycle start LED will be ON. 
AND in some instances whle in Feedhold the LED will be ON. IT just depends on what  Mach3 is doing when you FEEDHOLD.
So you have to account for that as well.
(;-) TP