Bolton Crown Court heard how Gavin Sever, who is addicted to Class A drugs, went to the Cohens' pharmacy in Crescent Road, Great Lever, on August 10.
But the court was told that, while there, he saw assistant Tabia Khan counting money for the till.
Simone Flynn, prosecuting, said 29-year-old Sever took advantage of the situation, went behind the counter, grabbed the cash, which amounted to around £50, and some prescriptions and ran off.
Sever dropped the prescriptions after he was confronted by a customer.
In a victim statement Miss Khan said: "The incident has shaken me up. This the first time anything like this has happened to me and I now worry that it may happen again."
Sever pleaded guilty to burglary. At the time he was subject to a suspended prison sentence for shoplifting which has been imposed for shoplifting and breaching court orders.
Judge Graeme Smith was told that Sever had also previously been banned from entering Rowland's pharmacy.
He appeared in court via a video link from prison to be sentenced for the pharmacy theft.
Kevin Liston, defending, stressed that Sever, who has numerous previous convictions, is normally a shoplifter, not a burglar.
He added that Sever, of Tavistock Drive, Bolton, had acted impulsively when he grabbed the money.
"On this occasion he had attended, not to commit an offence, but to take his methadone. It seems this was an impulsive act," said Mr Liston, who added that Sever wass resigned to being given a jail sentence.
"He is somebody who has taken stock of his position. He has been plagued by a Class A drug addiction for a number of years now," said Mr Liston.
Judge Smith sentenced Sever to eight months in prison.
He told the defendant: "It is clear to me that you do have a tendency to resort to offending when it is either necessary, in your eyes, to be able to assist you in affording your Class A drug habit or when, as in this case, an opportunity presents itself and it is almost as if it is too good not to be taken.
"You have a particular history, it seems, in relation to offending in relation to pharmacies.
"Pharmacies perform a very important public service, like GP surgeries do.
"They are places which are particularly vulnerable and that, in my judgement, increases the seriousness of this offence albeit, it has been accepted, you didn't use