Okay, my first thought was to iterate to the top window:
win = system.gui.getParentWindow(event)
parent = win
while parent is not None:
win = parent
parent = win.getParent()
projectName = win.getTitle()
In the long run. it's not any different than what you have, the main problem being the dash separating the project title from the window title. If you have more than one dash, it gets problematic.
I was able to do it using the Power Scripting Module, since we can query the internal database:
projectName = system.tag.read('[System]Client/System/ProjectName').value
query = "SELECT title FROM PROJECTS WHERE name = '"+projectName+"'"
result = pa.ignition.db.runPrepInternalDBQuery(query)
if result != None:
projectName = result
Since PerfectChat is dependent on the module, it should'nt be too problematic to build it in.
I say shouldn't be, but then, I'm not the one who has to do it!