I got it to work.
The solution is to reference the item in the window and to stick a couple of small delays in at the end.
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags: