I remember back in college asking a guest composer a very similar question. And for years I thought the response he gave me was just something to dodge my question.
He said that before chords, melody, rhythm etc. start with an idea.
Common sense right? But when you think about it music is a language, that we can all agree on, so what do you want to communicate?
For myself, one thing that I like to do is try to absorb some atmosphere. If I have an idea for something I'll try to find and feel anything that could be related to that. Making a chilled out piece of music? Compose at night, Think of all the times in your life that you felt relaxed. Put on some blue lights, Look at pictures of Oceans or find some abstract art that has what your looking for. Hell, go turn on the faucet and watch if you have nothing else.
As far as getting ideas when you can't put them down I think everyone knows that feeling. At work, in the car, a few times I remember suddenly getting out of bed to get something into my DAW before getting frusterated giving up and going back to sleep. Then when it comes for some scheduled studio time I get NOTHING! Sometimes your mind can shut down if you spend long amounts of time in front of the same lighted screen hour after hour. Play with the interface in your DAW, Take frequent breaks but keep what you are doing on your mind, play some different instruments. Anything that keeps you flowing goes!