I want to create layer from layer mask, like in this gif:
And i need to do this from script. Is that possible?
Record an action for it.
In the Actions panel, click the Create New Action button , or choose New Action from the Actions panel menu. Enter an action name, select an action set, and set additional options: ... Click Begin Recording. ... Perform the operations and commands you want to record.