Why not make it keep pressing space until your "Specific dialog" appears by detecting the widget, and interact with the option you are looking for? You don't have to make a pos for the mouse to click on. Since the API has an option do that for you in a dialog.
Also, upon starting the script, it should automatically disable user input in the client.
Since afaik, if the user laggs out, it might fuck up if you are using static x amount of space presses. So it's better to use conditional sleep I guess.