The gunman who killed Cook County Judge Raymond Myles had followed a female acquaintance of the judge for weeks before shooting the woman and the judge during a botched stickup attempt, prosecutors said at a court hearing Thursday for the alleged getaway driver.

Joshua T. Smith, 37, told police he drove an unnamed accomplice to Myles’ house in the West Chesterfield neighborhood before dawn Monday, intending to hold-up the 52-year-old woman described as a “close associate” of the judge, as she left the house to go to the gym, Assistant State’s Attorney Guy Lisuzzo said.

The Sun-Times has identified the woman as Myles’ girlfriend.

“(Smith) admitted that the male co-offender had surveilled the female for two or three weeks prior to (the robbery) for the purpose of learning her schedule and that the male co-offender made him aware of his observations,” Lisuzzo said at the bond hearing for Smith.

The other man apparently learned the woman’s habits included early-morning workouts. Monday morning, around 5 a.m., the man crept up on the woman as she left Myles’ house, took her gym bag and shot her in the leg.

Hearing the gunshot, Myles came out of the house and confronted the gunman, who shot Myles four times, killing the 66-year-old judge, Lisuzzo said.

Judge Robert Miller, a DuPage County judge appointed to preside at the hearing, ordered Smith held without bail on charges of first-degree murder, aggravated battery and obstructing police.

Miller was asked to handle Smith’s bond hearing because all judges at the Leighton Criminal Courthouse know Myles.

Smith’s unnamed accomplice, who remains at large, “grew upset” as he rifled through the bag and couldn’t find anything, Lisuzzo said. The man eventually tossed the bag from the car window and into a trash can. Police on Wednesday said the shootings had nothing to do with Myles’ position as a judge.

Wearing a black T-shirt and sweats, the beefy Smith stood before the judge in a courtroom  filled with reporters and courthouse staff. Standing along the wall were two sheriff’s deputies and a clerk who had worked with Myles. As Lisuzzo read a summary of the evidence against Smith, the clerk wiped tears from her face. Outside the courtroom, the clerk and the deputies embraced.

Prosecutors said surveillance cameras scattered around Myles’ neighborhood recorded a burnt orange Pontiac Sunfire circling Myles’ block around the time of the robbery. Smith dropped his accomplice off in an alley near the house and waited, Lisuzzo said. In his statement, Smith said he heard gunshots, then picked up his fleeing accomplice as he ran down the alley.

Smith, who told the judge he owns a business installing car stereos and alarms, drove back to his garage and told his girlfriend to lie and say that her car had been stolen if she was questioned by police.

Cook County Associate Judge Raymond Myles | Cook County Circuit Court photo

Smith drove himself to the Area South Detectives division later that day “to speak with detectives” and has been in custody ever since.

It appears Smith had fleeting contact with Myles about 16 years ago. In 2001, he appeared before Myles on a charge of failing to have a title for a vehicle, but the case was dismissed, court records show.

The next year, Smith was charged in a carjacking at River Oaks Mall, Lisuzzo said. He was convicted in 2003 and sentenced to six years in prison, records show.

Smith was released in 2005 and was on probation until 2008, Lisuzzo said.

Evidence against Smith is either circumstantial or from his statement, said Assistant Public Defender Kristina Yi, who said Smith was now asserting his 5th Amendment rights and did not want to talk to investigators. Smith is the “sole provider” for two teenage children, Yi said, and had no criminal convictions since his 2002 arrest.

“He has been a positive, contributing member of society since his release for that conviction,” she said.