I am looking for a free script to do the above. This is the activity in question: I have a multilayered document open and I drag in another image (a texture) which forms a new layer on top of the stack. I accept it but the dimensions don't match the canvas, so I press Ctrl-T to transform it. I drag the top right corner to snap into the top right corner of the canvas and then drag the bottom left corner to snap into the bottom left corner of the canvas - so my texture layer now exactly covers the canvas. Of course the aspect ratio has changed but as it is a texture that doesn't matter.
So what I would like is that, after placing the texture image and with its layer selected, I could run a script to achieve that simple task. I'm guessing it would only be 3 or 4 lines of code.
Has anyone come across such a script? Or failing that could you help me write it - I've never tried to write a Photoshop script.