A man who was caught on CCTV repeatedly breaching a restraining order has been jailed for six months.
Richard Kidner had already served time inside for similar matters when again went to the home of his former partner.
The 64-year-old, who was not in court for the hearing, kept knocking on the door despite being banned from contacting her or going to her house.
And although Kidner has already completed the new jail term on remand he is being detained in hospital under the Mental Health Act, Swindon Crown Court was told.
Susan Cavendish, prosecuting, said the defendant had been in a relationship with Rosemary Finney for about six years until in ended in 2008.
In March last year she said he was convicted of harassing her and put on a restraining order, which he breach five times in the following few weeks.
Last summer he was jailed for 18 weeks and the order extended but soon after his release from custody he was back at her door.
He rang the doorbell at the address in Hankerton, near Malmesbury, twice on Sunday October 13 and then drove away when there was no answer.
He did the same again on the following Tuesday and once more on the Wednesday morning.
Kidner, of Bishopsfield, Cricklade, pleaded guilty to five counts of breaching a restraining order.
Cathy Thornton, defending, said client had been inside for six months on remand and was now in a hospital.
She said he was on antipsychotic medication having been taken in for six months under the Mental Health Act and was not fit to attend court.
Miss Thornton told the court he 'Simply said he wanted to speak to the lady and ask why the relationship ended'.
Passing sentence Judge Tim Mousley QC said "I have to sentence Richard Kidner in his absence today.
"He is now 64 and until 2012 he was a hard working man of good character.
"From that period onwards he started to commit offences of harassment effectively towards a lady with whom he had a relationship, Rosemary Finney."
Jailing him for six months he said "It is plain from what is now known because of psychiatric intervention that over the period that he was behaving in this way towards Miss Finney there was a deterioration in his mental health.
"That is now under diagnosis by the psychiatric team in Bristol and he is currently detained under the Mental Health Act for these purposes and will remain detained in that way for at least six months from today."