Hi guys,
For a project i need to define the size of the working desktop ( the use of an external software ), i have try with _MouseTrap but not work if i switch the multi desktop.
So i have think to a Mouse hook:
AutoIt
#include <WinAPI.au3> HotKeySet("{ESC}", "OnAutoItExit") Local $XCenter = Int(@DesktopWidth / 2) Local $YCenter = Int(@DesktopHeight / 2) If $XCenter < $YCenter Then Local $Radius = Int($XCenter / 2) Else Local $Radius = Int($YCenter / 2) EndIf MouseMove($XCenter, $YCenter) $RadSq = $Radius * $Radius Global Const $WM_MOUSEMOVE = 0x0200 Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" $hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) While 1 Sleep(100) WEnd Func _Mouse_Proc($nCode, $wParam, $lParam) Local $info, $ptx, $pty, $mouseData, $flags, $time, $dwExtraInfo, $Res Local $xevent = "Unknown", $xmouseData = "" If $nCode < 0 Then $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) ;recommended Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) DllStructGetData($info, 1)$ ptx = DllStructGetData($info, 1) $pty = DllStructGetData($info, 2) $Res = 0 Select Case $wParam = $WM_MOUSEMOVE If ($ptx - $XCenter) ^ 2 + ($pty - $YCenter) ^ 2 > $RadSq Then $Res = 1 EndIf EndSelect If $Res = 1 Then Return 1 Else $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndIf EndFunc ;==>_Mouse_Proc Func OnAutoItExit() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 Exit EndFunc ;==>OnAutoItExit
I the example the area is a circle, how i can define an rectangle area like @desktopwidth - 200 and @desktopheight - 50?
Thanks