Check if Grasshopper is active using Python script

Is there a way to see if Grasshopper is active using pythonscript? And if it’s not active, to launch Grasshopper?
I’d assume it would be by checking if the grasshopper plug in is loaded or something but just have no idea where the right code to do this.

I think you’re looking for GH_RhinoScriptInterface.IsEditorLoaded:

import rhinoscriptsyntax as rs
gh = rs.GetPlugInObject("Grasshopper")
if gh.IsEditorLoaded():
    print "Grasshoppper is loaded"
    print "Grasshopper is not loaded" (177 Bytes)


That’s it, thanks!