Posting my solution which is currently working.
I dont know why, but i had a ton of problems trying to use the ControlClick, from my experimentation it would appear it is not affected by CoordMode and it resulted in just doing the click wherever the mouse last exited that window regarless of coordenades, even if using optional flags like NA or pos or both.
I added some additional functions since I also wanted to do partial clicks so I can move the direction a character is facing on another instance.
In general the code is not optimized or pretty, but it works for
dualboxing, some tweaking would be needed for using more instances of the game though.
ClonesClickPush(mKeys)
{
global WowWinId1
global WowWinId2
global WowWinHeightId1
global WowWinHeightId2
global WowWinWidthId1
global WowWinWidthId2
olddelay := A_MouseDelay
oldspeed := A_DefaultMouseSpeed
CoordMode, Mouse, Rel
MouseGetPos, xpos, ypos, ,1
; *** Every click will be sent to both instances, we just want to know if this window was active
; *** Because I havent been able to send clicks to inactive windows, so we will cicle through all
; *** of the boxes to send the click and then return to the originating window
; *** If using more than two instances, this might need to be changed for a loop
; *** But im unsure of the delay of moving the cursor and making multiple windows active if using a higher number
IfWinNotActive, ahk_id %WowWinId1%
if ((xpos < WowWinWidthId2 && ypos < WowWinHeightId2)&& (xpos > 0 && ypos > 0) )
flow1 := 0
IfWinNotActive, ahk_id %WowWinId2%
if ((xpos < WowWinWidthId1 && ypos < WowWinHeightId1) && (xpos > 0 && ypos > 0) )
flow1 := 1
if(flow1 == 0)
{
WinActivate, ahk_id %WowWinId1%
CoordMode, Mouse, Rel
; *** this is just to make an offset so the click happens at aprox the same place in both windows
; *** even if the sizes of the windows is different, they have to be the same aspect ratio though
finalX := xpos * (WowWinWidthId1/WowWinWidthId2)
finalY := ypos * (WowWinHeightId1/WowWinHeightId2)
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
MouseMove, %finalX%, %finalY%
Click, %finalX%, %finalY%, %mKeys%
WinActivate, ahk_id %WowWinId2%
Click, %xpos%, %ypos%, %mKeys%
SetMouseDelay, %olddelay%
SetDefaultMouseSpeed, %oldspeed%
}
if(flow1 == 1)
{
WinActivate, ahk_id %WowWinId2%
CoordMode, Mouse, Rel
finalX := xpos * (WowWinWidthId2/WowWinWidthId1)
finalY := ypos * (WowWinHeightId2/WowWinHeightId1)
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
MouseMove, %finalX%, %finalY%
Click, %finalX%, %finalY%, %mKeys%
WinActivate, ahk_id %WowWinId1%
Click, %xpos%, %ypos%, %mKeys%
SetMouseDelay, %olddelay%
SetDefaultMouseSpeed, %oldspeed%
}
}
ClickDragPush(mKeys)
{
global WowWinId1
global WowWinId2
global WowWinHeightId1
global WowWinHeightId2
global WowWinWidthId1
global WowWinWidthId2
olddelay := A_MouseDelay
oldspeed := A_DefaultMouseSpeed
CoordMode, Mouse, Rel
MouseGetPos, xpos, ypos, ,1
IfWinNotActive, ahk_id %WowWinId1%
if ((xpos < WowWinWidthId2 && ypos < WowWinHeightId2)&& (xpos > 0 && ypos > 0) )
flow1 := 0
IfWinNotActive, ahk_id %WowWinId2%
if ((xpos < WowWinWidthId1 && ypos < WowWinHeightId1) && (xpos > 0 && ypos > 0) )
flow1 := 1
if(flow1 == 0)
{
WinActivate, ahk_id %WowWinId1%
CoordMode, Mouse, Rel
finalX := xpos * (WowWinWidthId1/WowWinWidthId2)
finalY := ypos * (WowWinHeightId1/WowWinHeightId2)
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
MouseMove, %finalX%, %finalY%
Click, %finalX%, %finalY%, %mKeys%
SetMouseDelay, %olddelay%
SetDefaultMouseSpeed, %oldspeed%
}
if(flow1 == 1)
{
WinActivate, ahk_id %WowWinId2%
CoordMode, Mouse, Rel
finalX := xpos * (WowWinWidthId2/WowWinWidthId1)
finalY := ypos * (WowWinHeightId2/WowWinHeightId1)
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
MouseMove, %finalX%, %finalY%
Click, %finalX%, %finalY%, %mKeys%
SetMouseDelay, %olddelay%
SetDefaultMouseSpeed, %oldspeed%
}
}
ClickDragRelease(mKeys)
{
global WowWinId1
global WowWinId2
global WowWinHeightId1
global WowWinHeightId2
global WowWinWidthId1
global WowWinWidthId2
olddelay := A_MouseDelay
oldspeed := A_DefaultMouseSpeed
CoordMode, Mouse, Rel
MouseGetPos, xpos, ypos, ,1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
Click, %xpos%, %ypos%, %mKeys%
IfWinNotActive, ahk_id %WowWinId1%
if ((xpos < WowWinWidthId2 && ypos < WowWinHeightId2)&& (xpos > 0 && ypos > 0) )
flow1 := 0
IfWinNotActive, ahk_id %WowWinId2%
if ((xpos < WowWinWidthId1 && ypos < WowWinHeightId1) && (xpos > 0 && ypos > 0) )
flow1 := 1
if(flow1 == 0)
{
WinActivate, ahk_id %WowWinId1%
CoordMode, Mouse, Rel
finalX := xpos * (WowWinWidthId1/WowWinWidthId2)
finalY := ypos * (WowWinHeightId1/WowWinHeightId2)
MouseMove, %finalX%, %finalY%
SetMouseDelay, %olddelay%
SetDefaultMouseSpeed, %oldspeed%
}
if(flow1 == 1)
{
WinActivate, ahk_id %WowWinId2%
CoordMode, Mouse, Rel
finalX := xpos * (WowWinWidthId2/WowWinWidthId1)
finalY := ypos * (WowWinHeightId2/WowWinHeightId1)
MouseMove, %finalX%, %finalY%
SetMouseDelay, %olddelay%
SetDefaultMouseSpeed, %oldspeed%
}
}
; *** Grab unique window ID's ***
WinGet, WowWinId, List, World of Warcraft
WinGetPos, , , WowWinWidthId1, WowWinHeightId1, ahk_id %WowWinId1%
WinGetPos, , , WowWinWidthId2, WowWinHeightId2, ahk_id %WowWinId2%
; *******************************
; *** Only if WoW is in focus ***
; *******************************
#IfWinActive, World of Warcraft
; *** Mouse clicks ***
XButton1::ClonesClickPush("XButton1")
XButton2::ClonesClickPush("XButton2")
; *** This allows you to control the direction a character in the other account is facing.
MButton::ClickDragPush("down Right")
MButton Up::ClickDragRelease("up Right")