I use this function to toggle autocast. Your code will be similar to this.
This function takes an number 1 to 12, and clicks the right mouse button on one of the grid.
The code will save the current mouse position, clicks on the appropriate grid position (based on the screen size), and returns to the starting position.
Code:
; AutoCast Function
AutoCast(iSpellQWERHotkey)
{
MouseGetPos, iMousePosX, IMousePosY
if (iSpellQWERHotkey == 1)
{
iMouseGotoX := A_ScreenWidth*4//5
iMouseGotoY := A_ScreenHeight*4//5
}
else if (iSpellQWERHotkey == 2)
{
iMouseGotoX := A_ScreenWidth*4//5
iMouseGotoY := A_ScreenHeight*22//25
}
else if (iSpellQWERHotkey == 3)
{
iMouseGotoX := A_ScreenWidth*4//5
iMouseGotoY := A_ScreenHeight*19//20
}
else if (iSpellQWERHotkey == 4)
{
iMouseGotoX := A_ScreenWidth*17//20
iMouseGotoY := A_ScreenHeight*4//5
}
else if (iSpellQWERHotkey == 5)
{
iMouseGotoX := A_ScreenWidth*17//20
iMouseGotoY := A_ScreenHeight*22//25
}
else if (iSpellQWERHotkey == 6)
{
iMouseGotoX := A_ScreenWidth*17//20
iMouseGotoY := A_ScreenHeight*19//20
}
else if (iSpellQWERHotkey == 7)
{
iMouseGotoX := A_ScreenWidth*9//10
iMouseGotoY := A_ScreenHeight*4//5
}
else if (iSpellQWERHotkey == 8)
{
iMouseGotoX := A_ScreenWidth*9//10
iMouseGotoY := A_ScreenHeight*22//25
}
else if (iSpellQWERHotkey == 9)
{
iMouseGotoX := A_ScreenWidth*9//10
iMouseGotoY := A_ScreenHeight*19//20
}
else if (iSpellQWERHotkey == 10)
{
iMouseGotoX := A_ScreenWidth*19//20
iMouseGotoY := A_ScreenHeight*4//5
}
else if (iSpellQWERHotkey == 11)
{
iMouseGotoX := A_ScreenWidth*19//20
iMouseGotoY := A_ScreenHeight*22//25
}
else if (iSpellQWERHotkey == 12)
{
iMouseGotoX := A_ScreenWidth*19//20
iMouseGotoY := A_ScreenHeight*19//20
}
Click, Right, %iMouseGotoX%, %iMouseGotoY%
MouseMove, %iMousePosX%, %iMousePosY%
}
If you still need more help, I can try to look at it this weekend. (It's something I'm interested in developing too.)
_________________
My AutoHotkey Program for Warcraft III:
Warkeys
http://warkeys.sourceforge.net/
Remap your hotkeys
Healthbars always on
Remap inventory