How do I get better at complex automation and scripting?
You have already crossed the hardest line, which is going from doing things by hand to scripting most of them. The complex automation trips you not because you lack ability, but because it is genuinely the next level, where the pieces interact and the edge cases multiply. Being stuck here means you have run out of easy problems, which is a good sign. Complex automation gets learned by taking it apart. Do not try to build the whole intricate thing at once. Break it into small pieces you already understand, get each one working alone, then connect them slowly. When something breaks, that is not failure, it is the exact information you needed. Read it, fix one thing, run it again. That loop is how mastery is built. Study the work of people better than you. Read their scripts, notice the patterns they reuse, and steal the ones that fit. You do not have to invent every technique yourself. Keep taking on automation that is slightly beyond you, one project at a time, and the complex will slowly become the routine. That is simply what the next rung feels like while you are climbing it.