I don't have the best equipment for photos. My phone is okay, and my SLR is 20 years old. So there is a process to increase my chances.
I often photograph a few hours after water changes. It's no use taking photos if the glass is dirty, so first, I clean it inside and outside. That rattles the fish, so I wait a while. I don't have a proper flash system, so I compensate with strong light from above. I'll often move a spot onto a tank. I have a bunch of screw in shoplights I can use. The fish get used to them.
Then I place the camera in front of the tank. Wary fish get frightened of it, so I let it become normal.
I set up a chair and take my time. The result is a lot of bad photos, most of which I trash. Every once in a while I get a good one.
I'd like to get a better camera, but with the type of photos I take (of fish and not a lot else...) I find it hard to justify the cost. My phone will do travel pics no one really wants to see if they weren't there, and the now outmoded digital SLR can create the images I post here.
When is usually if I see something going on, with the things I mentioned in the previous post. Fish get into show off moods sometimes, and I try to take advantage. I think the biggest "when" is when I retired! It's hard to find free time when you're working.