Quoted from lexikos of AutoHotKey forums.

Following the style of the script in your previous post,
Code (Copy):
#IfWinActive World of Warcraft
~LButton:: ; ~ means don't block
CoordMode, Mouse, Relative ; this is the default, but just in case
MouseGetPos, x, y
ControlClick, X%x% Y%y%, ahk_id %wowid2%
ControlClick, X%x% Y%y%, ahk_id %wowid3%
return
For right-click, you'd use ~RButton:: and
Code (Copy):
ControlClick, X%x% Y%y%, ahk_id %wowid2%,, R

This doesn't simulate mouse drag/movement, which is more complicated since there is no built-in command.

For future reference, #IfWinActive applies to all hotkeys down to the next #IfWin. It does not need to be repeated, though there is no harm.