In Act 3, Scene 3 of Hamlet, is there a soliloqy?
When Hamlet says...Now might I do it pat. Now he is a-praying. And now I’ll do ’t. And so he goes to heaven. And so am I revenged.—That would be scanned.... I know that Caudius is still there praying, but could it be considered a soliloqy?
I agree with rienzi that the quote you reference in your posted question is, in fact, a soliloquy by Hamlet. By this point in the play, Hamlet has proof that Claudius is truly guilty of the murder of King Hamlet, and Hamlet is finally ready to take action against him. As he is walking down the hall to go to his mother's rooms (she has requested this meeting), he happens to see Claudius while he is praying. He has no idea what Claudius is specifically saying, but he likely sees Claudius on his knees with his head bowed in the physical attitude of prayer. On one hand, Hamlet recognizes this as the perfect time to kill Claudius, but upon a bit more thinking, he justifies his not acting because he thinks that Claudius is receiving forgiveness for the sin and that his soul would go straight to heaven. He doesn't think that this would be "good" revenge seeing as his own, innocent father is burning off his small sins in purgatory right now. Hamlet decides to wait until Claudius is doing something sinful like drinking or spying so that his soul will go straight to hell upon his death. Just as Hamlet has absolutely no idea what Claudius is saying in his soliloquy, Claudius has no idea what Hamlet was just saying (thinking). A long speech that no one on stage hears is a soliloquy. If others are actively listening or secretly listening-in, then the speech is considered a monologue. There is no textual evidence that either of these characters is listening to other. In fact, if Hamlet had heard what Claudius was actually saying, he would have killed him on the spot because Claudius is actually saying he would never be forgiven for his sins because he isn't willing to give up what he has gained from his crimes: his wife and crown.
This is generally considered the 5th of Hamlet's 7 soliloquies. Even though Claudius is present this is still considered a soliloquy though some may quibble with the technicalities of a soliloquy. This is also the very problem in Hamlet's "To be" soliloquy where Ophelia is present and Claudius and Polonius are spying on Hamlet. Also in 3.3 is Claudius' soliloquy.