>>>Thanks but I already said I can get all the processes. If you know which keyword and\or flag I should use to get applications from ps then that is fine.
>>
>>One of the links I provided for you explains which flags to look for. Using the ps command allows for those flags to be conveyed on each process line, which can then be parsed so only the subset you seek is there.
>>
>>I do not have a Mac machine to code or test it for you or I would.
>>
>>>PS: I can get them using an applescript, I would prefer doing programmatically instead if I can rather than parsing output of a shell command.
>
>Which link is that. I think I have already read what is in those links + the ps man page included in Mac, still cannot figure how.
>
>PS: Currently I can get what I want with an apple script, instead of ps. I would like to have a way doing all these programmatically (I can use "ps" without actually using shell ps BTW via low level libraries) but anyway, looks like I will live with calling and parsing applescript output.
If I'm reading it correctly, it was the superuser link. It showed the [RDS][s]+ flags would indicate a foreground process:
R+
Rs+
D+
Ds+
S+
Ss+
The man pages may show additional detail. You might be able to coordinate the flags seen in a snapshot with what you see in the Apple tool and apply some filters to figure out what you're looking for.