The man was wearing headphones as he worked in his home in Westfield Street in Heckmondwike, West Yorkshire, when the attacker struck on Wednesday.
He managed to call police when he regained consciousness and nothing was taken from the house.
Police said he was hit on the back of the head and treated in hospital for a minor head injury.
Any witnesses are urged to contact police.

The Scottish Gamekeepers' Association said the latest employment figures showed the sector was outperforming other areas of the economy.
North Highland College in Thurso reported that every one of this year's Higher National Certificate students has secured a job on a sporting estate.
Country sports are thought to be worth Â£240m a year to the Scottish economy.
The gamekeeping and wildlife management course was designed to provide students with training in conservation as well as traditional gamekeeping skills, including snaring and the use of firearms.
North Highland College gamekeeping lecturer Richard MacNicol said: "The modern gamekeeper has to have a rounded, balanced approach to land management.
"Our graduates are helping to support the rural economy and a diverse, well managed countryside."
Borders College and Scotland's Rural University College in Fife also said the skills obtained by their students were proving valuable to landowners.
The Scottish Gamekeepers' Association has welcomed the news.
SGA chairman Alex Hogg said: "This is a major success story and the three colleges deserve immense credit.
"We are creating youth jobs at a time when the economy is faltering and young people, especially in remote areas, have few other opportunities."
There is real frustration amongst landowners and the gamekeepers they employ about the profession's image.
Political and media attention often focuses on cases of wildlife crime, most notably the illegal persecution of birds of prey.
Gamekeepers believe they do not get the credit they deserve for the stewardship of our countryside, while landowners argue the economic benefit of country sports is often overlooked.
They are hoping the new generation of gamekeepers being trained by Scotland's colleges will help change that.
Angus McNicol, of Cawdor Estates near Nairn, told BBC Scotland: "It's a highly-trained profession these days. It's very different to how things were in the past."

Of the 2,007 people polled 27% had seen a hate crime, with 20% witnessing abuse based on religion and 25% on race or ethnicity.
The questionnaire was carried out by Censuswide to coincide with Holocaust Memorial Day on Wednesday.
More than 3,000 events are taking place across the UK to mark the event, which has taken place each year since 2001.
Ceremonies are also being held around the world, including at former death camp Auschwitz, which was liberated 71 years ago.
In separate figures, the Everyday Antisemitism Project - a scheme where Jewish people share experiences of discrimination - reported a surge in submissions, with 303 received in the last three months of 2015, compared to a monthly average of 32 in the preceding 14 months.
Olivia Marks-Woldman, chief executive of the Holocaust Memorial Day Trust, which commissioned the questionnaire, said: "The theme for the thousands of Holocaust Memorial Day events taking place across the country today is 'Don't stand by', and these figures show just how important that message is.
"Today is about remembering the atrocities of the Holocaust and subsequent genocides, but it's also about finding ways to make sure they can never happen again.
"We know that silence and indifference in the face of discrimination and hatred allows persecution to take root, so we want to encourage people to stand up and speak out, in the way many brave souls have in the past."
The most common form of hate crime reported was verbal abuse.
Of the incidents witnessed 28% were online on platforms such as Facebook and Twitter.
More than three quarters of those asked [77%] said there was no difference between bullying or "trolling" someone online and shouting abuse at them in the street.
Some 300 people polled said they had been victim of a hate crime, with 61% saying no-one intervened while the incident was happening.
Censuswide surveyed the over-16s in Britain between 2 and 7 December last year.
Holocaust Memorial Day also remembers atrocities in countries such as Cambodia, Bosnia and Rwanda.
The main UK memorial ceremony will take place at the Guildhall in London and will be broadcast on BBC Two at 19:00 GMT.
A man knocked unconscious while he was doing DIY at his home came round to find racist graffiti on the wall.
[NEXT_CONCEPT]
Colleges across Scotland are reporting strong demand from sporting estates for newly-trained gamekeepers.
[NEXT_CONCEPT]
More than a quarter of people in the UK have witnessed a hate crime in the last year, a new poll suggests.