On start up of what your system, Photoshop or something else. Do you want to select a png file or process every png in a folder, path, drive or all drives? You need to describe what you want to do better.
your question is not clear.
var pngFiles = File.openDialog ("select files","*.png");
will show you the open dialog (only png)
app.activeDocument.flatten(); // or pngFiles[counter].flatten();
will flatten the active document (or the file with your loop counter).
Perhaps this helps you a little bit.
Sorry I guess its a tad unclear. I want to enable the script listener and anytime I open a file if its a PNG I want it to flatten the file. But only PNG files. I work with a ton of PNG files and every single one of them has a layer 0 (our vendor thought it was cute to do that I guess) I have to do this manually and its annoying plus sometimes I forget to flatten and it causes problems if I don't flatten. Such as Blurred edges
Basically I want to write and if statement. If its a PNG flatten else do nothing.
That is not what you want to do, The scriptlistener is a plugin that records action manager script code for what you do in Photoshop..
What I think you want to do is to enable the script event manager, Once you do you can set an open event to trigger an action or script to run when you open ad document. You would need to write a simple script to flatten png files you open. Conditional actions can not test a file type condition the list of conditions is small. The script just needs to test the document's name. However You may not want to flatten for that creates a background layer and would remove any transparency your png might have had. You may just want merge down to a single layer that may contain transparency. That script will be more complex to write then just flatten. If your pngs have no transparenct flatten away.