Can I use simulate_mouse_click to end the turn? Is there a better way of doing it?

I'm trying to create a script that does this:

1. Starts as faction 1.
2. Switches to faction 2, so that the AI plays the turn for faction 1.
3. Switches to faction 1 and ends the turn.
4. Loop back to 1, until the counter reaches x.

Here's the code I've got so far:

Spoiler Alert, click show to read: 

script

;This totally didn't work
;console_command control romans_julii
;console_command run_ai
;console_command halt_ai
;console_command control romans_brutii
;console_command run_ai
;console_command halt_ai
;while I_TurnNumber < 5
;end_while

;Nor did this
;console_command control egypt
;console_command halt_ai
;campaign_wait 30
;console_command control romans_julii
;console_command run_ai x

;So far, so good
console_command control romans_julii
console_command control egypt
;I can't switch it back to romans_julii without it seemingly failing to switch to egypt at all, I tried campaign_wait 60 and it didn't seem to work at all

end_script