Apple has been granted a restraining order against a Virginia woman it said has been stalking Apple CEO Tim Cook for more than a year, emailing him photos of a loaded pistol and trespassing at his home, according to court filings.

In its application, Apple accused the woman of “erratic, threatening, and bizarre behavior.” The company included in the application copies of photos, emails and tweets purporting to come from the woman. Apple said in the application that it believes the woman “may be armed and is still in the South Bay Area and intends to return to (Cook’s) residence or locate him otherwise in the near future.”

The order bars the woman from possessing guns, approaching any Apple employees including Cook, entering any Apple property or going to Cook’s Palo Alto residence.

The suspected harasser is in the South Bay area and may be armed, Apple said in its application last week for a court order. The Cupertino technology giant made the request on Thursday. A judge granted it Friday, and the order was made public Monday afternoon by Santa Clara County Superior Court.

Cook first learned in late 2020 that he was the subject of the woman’s obsession because he receives alerts when he’s tagged on Twitter, the application said. The woman, using the last name “Cook,” claimed she was the Apple CEO’s wife and he was father to her twins.

She tweeted about the purported relationship a dozen times on Halloween 2020. Between late October and mid-November of that year, she emailed Cook some 200 times, the messages showing “a significant escalation in tone, becoming threatening and highly disturbing,” the application said. A series of missives contained photos of a snub-nosed revolver and cartridges. In an email expressing a desire for a sexual relationship with Cook, she said her patience was “almost done,” the application said.

The application names the subject of the restraining order as a 45-year-old woman from Virginia.

The alleged stalker’s Twitter feed also makes reference to Google CEO Sundar Pichai and Microsoft CEO Satya Nadella. Google and Microsoft did not respond to questions about the woman.

Meanwhile, she was registering fake corporations, some with “highly offensive corporate names,” in California, Virginia and New York, naming Cook as a corporate officer, director or agent, according to her application.

By September last year, the woman “became obsessed” with Cook’s Palo Alto condo and sent him an email applying to be his roommate, the application said. She is believed to have driven a Porsche Macan SUV from Virginia to Palo Alto and showed up at Cook’s home Oct. 22. When she told security she wanted to speak with Cook, they asked her to leave; she complied, but soon returned to the property, then left and waited in her car, according to the application.

Palo Alto police responded to the alleged trespassing, and the woman was stopped “after attempting to flee,” the application said. She allegedly told police she was staying in Palo Alto and “could get violent.” No weapons were found during a search of her Porsche, which police had towed because the woman’s driver’s license was expired, the application said. Palo Alto Police Lt. Con Maloney said the department had no information to release about the incident. “There is no active police investigation,” Maloney said.

She continued emailing Cook, the application said. Because she provided a San Jose address, San Jose police responded and found it to be an Airbnb where the woman was not present, according to the application. San Jose police did not respond to questions about their contact with the woman.

A week before Christmas the woman emailed Cook again with a demand for hundreds of millions of dollars, according to the application. On New Year’s Day, she tweeted, again with violent language about Cook, from a new account, the application said. The most recent email, sent a few days later, ordered Cook to move.

Neither Apple nor the lawyer who filed the application responded to questions about what the company may be doing to protect Cook, employees and the public.

Former Santa Clara County prosecutor Steven Clark said when someone applies for a restraining order, courts “tend to err on the side of caution” but the danger “has to be immediate and there has to be a perceived ability to carry out the threat.”

A hearing into the matter has been set for March 29.