@markifi: callasync calls an external application/binary/script but you can't place bash commands in there! I would recommend to place that all in a ready bash script and use the callsync method to execute it. for example
Code:
#!/bin/bash
if [ ! $(pgrep xdotool) ]; then xdotool getactivewindow sleep 10 windowactivate; else echo "it's running"; fi;
chmod +x it and then use callSync for that script