Code:
#include <Misc.au3>
Func _MouseClickMinimized($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
Local $i = 0
Local $MK_LBUTTON = 0x0001
Local $MK_RBUTTON = 0x0002
Select
Case $Button = "left"
$Button = $MK_LBUTTON
$ButtonDown = $WM_LBUTTONDOWN
$ButtonUp = $WM_LBUTTONUP
Case $Button = "right"
$Button = $MK_RBUTTON
$ButtonDown = $WM_RBUTTONDOWN
$ButtonUp = $WM_RBUTTONUP
EndSelect
$wPos = WinGetPos($Window)
_MouseTrap($wPos[0] + $wPos[2], 0, 5000, 3000) ;keep the mouse outside of the game
For $i = 1 To $Clicks
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_SETFOCUS)
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($X, $Y))
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonDown, "int", $Button, "long", _MakeLong($X, $Y))
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonUp, "int", $Button, "long", _MakeLong($X, $Y))
Next
_MouseTrap()
EndFunc ;==>_MouseClickMinimized
Func _MakeLong($LoWord, $HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc ;==>_MakeLong
This has been posted a long time ago on the autoit forums. I modified it a bit. Its not perfect however with this you can alt tab out of the game. Not sure if it will send clicks if the game is minimized however I used so that I can surf the web on my second monitor. This method will also cause your mouse to move sometimes(usually during loading screens in Vindictus) but otherwise will leave your mouse free to move outside of the game. There is another problem with this method, it will not send clicks if you have your mouse in the game window because it will send the clicks to where the mouse is currently rather than where the script tells it to this is why I use the _mousetrap function to keep the mouse out. A small advantage of this function is that you do not need to send alt nor esc. All I really did to make this code work is add the $WM_SETFOCUS dll call and the mouse trap. Give it a try maybe it will do what you are looking for. Maybe someone better skilled with autoit could make it work properly, but for now this does what I needed.