I've been playing electric guitar for some time. I know the basics of improvising, some scale and chord theory and enough technique for now. But I have a horrible problem in my playing, specially improvising.

When I listen to a backing track (or even a song) I imagine soloing, phrases and licks over it but when I grab the guitar and try to play them, it looks like my imagination turns off and can't pass to my guitar what I hear/heard before in my head. When I start playing and concentrating, I play how I'm used to play all the time and the imagination starts lacking, almost nothing new comes out... Any advice?
I've heard a lot of people say sing whats in your head while you play? might help get whats in your head out onto the fretboard
you have two problems.

1) your ears are untrained.
2) the guitar is playing you, rather than the opposite.

to fix these:

1) start training your ear. internalize the sounds of keys, chords, intervals, and the like.
2) use the abilities you gained from 1) in tandem with your knowledge of theory to play the guitar without relying on the patterns and licks that you always default to.
Anfangen ist leicht, Beharren eine Kunst.
AeolianWolf nailed it (of course).

It's easy to imagine - when your ears are untrained - lines that sound cool. But it turns out that you're not really thinking of specific notes, you're almost thinking of like the idea of notes. Ear training helps you learn to think in terms of specific pitches, so those ideas you get start being something you can actually play.
Whenever you practice scales, licks, etc, try singing along. This helps both build a connection between you're fingers and ears, plus, I find singing when improvising helps me cut down the b.s. since the ideas that I sing tend to be more concise, melodic, and less "pattern-y" then the ones that come just from my fingers. You'll have all your senses synchronized and working for the same goal.
Quote by bearded_monkey
Everytime I go into the guitar shop and ask for a G-String the shopkeeper always makes that TERRIBLE joke about it not being an underwear shop

So next time I go in I'm gonna ask for a thong