As far as lack of attentiveness or stray thoughts in prayer is concerned one should endeavor to identify whether these are the result of our “continued thinking to ourself” or just incoming automatic thoughts. Those thoughts that we bring to mind ourselves can also be stopped by an act of will. An easy way of doing this is to focus upon the meaning of the words one is saying or focus on the image of the Kaaba, for the heart can only focus on one thing at a time. The moment we focus we are delivered from inattentiveness and stray thinking.
As for those random incoming thoughts the best way to deal with them is not to pay any attention to them at all. Rather one should allow them to pass through like water passes through a sieve. It is worth remembering that consciously trying to rid oneself of these wasawas (whisperings) is itself a waswasa. This is a mental quicksand in which one can easily get stuck. One should never lose hope due to being afflicted with such automated whisperings in the prayer. The human heart is rather like a super-highway: royal carriages pass on it as well as poor wayfarers, the handsome as well as the ugly, the religious and the irreligious and the pure hearted as well as the sinful. Safety lies is allowing whatever type of traffic comes of its own accord to simply pass through for there is no red light on this highway. If one attempts to stop the flow of traffic or change its direction one is likely to cause an accident.
Even apart from prayer times the secret of life lies in keeping the heart free of worldly distractions. It is alright for one’s hand to possess the world but not one’s heart for that is a place reserved for God. Therefore one should be careful to keep it clear at all times, who knows when the light and grace of God might alight there.