Here is a little tip that has been working for me, for almost 6 months now. It starts with having someone like a Rav, who you'll really feel ashamed revealing this behaviour to. Second, make a list of things to do if you feel the urge before acting out (the goal being not to act-out, of course). Then, take a vow that if you act out without first doing these things, you'll report your actions to the Rav, each and every time. However, if you do these things from your list first and then c"v act out, you don't have to report yourself. The vow should be time limited, say, renewed every Sunday for a week. The "things to do" must be things you can do and that you normally love to do, but they should include some things of kedusha like reading the weekly parasha, a few chapters of tehillim, studying halachot or reading midrashim. In total, the list should be designed to keep you busy for at least an hour.
While the above method does seem to leave an option for acting out after completing the list, my experience has been that I have not acted out in close to 6 months with this method. In fact, the urge seems to dissipate while thinking of doing something from the list. So I haven't yet had to even do anything from the list.
Now I know that Hashem is the one Who is really helping, but He does expect us to do our hishtadlut, and the above method is hishtadlut. One should be honest with Hashem that he does desire these unholy things and he knows it's wrong, and that he needs Hashem's help. And also tell Hashem what you are doing for his hishtadelut, no matter how small.
Vows are serious business, so if heaven forbid one falls without doing the things on the list, he must report himself to the Rav.
I have found that this is also helpful for shmirat eynayim when I'm in the city. What I tell myself is, that there is no difference between looking at the attractive partially dressed woman on the street and the even more revealing images on the internet. In fact, the former will lead to the latter. However, as I know that I've vowed to do some stuff from my list first, I might as well not start looking!
I hope this works for you.