I am having this issue at work, and have throughout my career, come to think of it.
Give me a challenge, AND all the tools to conquer it, and I can get it done. Give me a lab environment with the servers and scripting tools I need to automate something, and I'll put it all together.
Hamstring me by not giving me the tools I need, make the barrier to accomplishment too much, or give me really boring work without some kind of clear path, and I lock up.
I can play Factorio for 12 hours a day when I get my yearly mood for it. When I am assigned a cool automation task with the tools available to BUILD it, I can run with it. Too bad my current job, a multi-billion dollar software company, can't spare me a few VM licenses without me jumping through hoops.
Oh, and Adderall can help, but it makes me so anxious and even more impulsive once I'm done with work.