The problem was that scratchpad_move() didn’t check whether the source workspace was focused. Therefore, 'move scratchpad' only worked reliably interactively , but not when used with criteria.