A man who stabbed his former girlfriend after forcing his way into her home had earlier been spared jail for harassing her, a jury was told.
Paul Henry left Claire Boswell with life-threatening injuries when he attacked her in her home.
He had previously received a suspended jail sentence after he threatened to kill her, Lincoln Crown Court heard.
But after he was freed he allegedly phoned her saying "I'm out", then broke into her house and tried to kill her.
Henry, 46, formerly of Lea Place, Gainsborough, denies attempted murder. He also denies an alternative charge of wounding with intent to cause Miss Boswell, 44, grievous bodily harm.
Robert Underwood, prosecuting, said Miss Boswell, a mother-of-three, had been harassed by Mr Henry for three or four years before he stabbed her on September 15, last year.
The jury was told Henry smashed the front window of Miss Boswell's home in Glentham Road, Gainsborough, and after climbing in, grabbed a large kitchen knife.
Miss Boswell retreated into a bedroom but Henry clambered over the bed and thrust the knife into the right side of her chest, the court heard.
Henry went to her home the previous weekend, Mr Underwood said, and climbed on to her roof before saying he intended to kill her.
Henry was then arrested on September 14, for breaching a restraining order preventing him from harassing Miss Boswell, and appeared before magistrates in Lincoln the following day.
He was given an eight-week sentence but this was suspended. Jurors heard Mr Henry went to Miss Boswell's house at about 5.15pm the same day.
Mr Underwood said: "He went into the bedroom where Claire Boswell was. She was pressing an alarm button that the authorities had provided for her."
Miss Boswell then dialled 999 and was heard shouting during the call: "Help! Get out!"
"Mr Henry was simply not deterred," said Mr Underwood. "He clambered over the bed towards Claire Boswell, knife still in hand, and he thrust that knife to the right side of her chest."
Mr Underwood said it penetrated her breast tissue and injured her liver, causing her life-threatening injuries.
She was taken to Lincoln County Hospital, then transferred to Queen's Medical Centre in Nottingham where she remained for five days.
The jury was told Miss Boswell had called the police to complain about Henry on "around 40 occasions" since 2005.
Giving evidence from behind a screen, Miss Boswell insisted she had never hit Henry.
"I have never been violent towards Mr Henry. I only did whatever I had to do to defend myself.
The jury heard that after Henry was arrested at a flat in Fillingham Close, Gainsborough, he told police: "I think it was an accident. I didn't do it on purpose.
"I was just frustrated. I was just upset with everything. I didn't want to kill her or anything like that. I can't believe I've done it."
The trial continues.