It uses rectangular regions to create a crosshair on the screen which follows the mouse. Fine tuning can be done with the arrow keys and pressing shift at the same time moves the crosshair in bigger increments. You can change $CROSSHAIR_SIZE and $BIG_MOVE to change the size of the "gap" in the crosshair (1 is the minimum) and also the size of the "jump" when shift is pressed down with the arrow keys. I ended up constantly updating the zoom window as otherwise it got corrupted when I tried to only update it when the mouse moved. If someone can find a better way or can find a use for this script then please amend away!
I guess you could also change the color of the crosshair by setting a different background colour.
#include <Constants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) HotKeySet("{ESC}", "_ExitApplication") Global $SIZEX = 256, $SIZEY = 256, $CROSSHAIR_SIZE = 1, $BIG_MOVE = 8 Global $GUIZoom = GUICreate("Zoom", $SIZEX, $SIZEY, 0, 0, BitOR($WS_SYSMENU, $WS_BORDER, $WS_CAPTION), $WS_EX_TOPMOST) GUISetBkColor(0xEEEEEE) GUISetState() Global $Crosshair = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0x000000) GUISetState() Global $z1 = 4 Global $zoomX = Int($SIZEX / $z1), $zoomY = Int($SIZEY / $z1), $DeskDC = _WinAPI_GetDC(0), $MyDC = _WinAPI_GetDC($GUIZoom) _WinAPI_SetBkMode($MyDC, 1) Global $UserDLL = DllOpen("user32.dll") Global $bLocked = False, $bContinue = True, $aPos, $aLast[2] = [-1, -1], $aMask, $aM_Mask, $nInc _SetZoom() While $bContinue If ($aLast[0] <> -1) Then $nInc = 1 If _IsPressed("10", $UserDLL) Then $nInc = $BIG_MOVE If _IsPressed("25", $UserDLL) Then MouseMove($aLast[0] - $nInc, $aLast[1]) If _IsPressed("27", $UserDLL) Then MouseMove($aLast[0] + $nInc, $aLast[1]) If _IsPressed("26", $UserDLL) Then MouseMove($aLast[0], $aLast[1] - $nInc) If _IsPressed("28", $UserDLL) Then MouseMove($aLast[0], $aLast[1] + $nInc) EndIf $aPos = MouseGetPos() If _IsPressed("4C", $UserDLL) Then $bLocked = Not $bLocked Do Sleep(10) Until Not _IsPressed("4C", $UserDLL) EndIf If _IsPressed("21", $UserDLL) And $z1 < 32 Then $z1 *= 2 _SetZoom() Do Sleep(10) Until Not _IsPressed("21", $UserDLL) $aLast[0] = -1 EndIf If _IsPressed("22", $UserDLL) And $z1 > 1 Then $z1 /= 2 _SetZoom() Do Sleep(10) Until Not _IsPressed("22", $UserDLL) $aLast[0] = -1 EndIf If ($aPos[0] <> $aLast[0]) Or ($aPos[1] <> $aLast[1]) Then If (Not $bLocked) Then $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", $aPos[1], "long", $aPos[0] + 1 - $CROSSHAIR_SIZE, "long", $aPos[1] + 1) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $aPos[0], "long", 0, "long", $aPos[0] + 1, "long", $aPos[1] + 1 - $CROSSHAIR_SIZE) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $aPos[0] + $CROSSHAIR_SIZE, "long", $aPos[1], "long", @DesktopWidth, "long", $aPos[1] + 1) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $aPos[0], "long", $aPos[1] + $CROSSHAIR_SIZE, "long", $aPos[0] + 1, "long", @DesktopHeight) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $Crosshair, "long", $aM_Mask[0], "int", 1) $aLast = $aPos EndIf EndIf _WinAPI_StretchBlt($MyDC, 0, 0, $SIZEX, $SIZEY, $DeskDC, $aPos[0] - ($zoomX / 2), $aPos[1] - ($zoomY / 2), $zoomX, $zoomY, $SRCCOPY) Sleep(50) WEnd GUISetState(@SW_HIDE, $Crosshair) GUISetState(@SW_HIDE, $GUIZoom) GUIDelete($Crosshair) GUIDelete($GUIZoom) DllClose($UserDLL) Exit Func OnAutoItExit() _WinAPI_ReleaseDC(0, $DeskDC) _WinAPI_ReleaseDC($GUIZoom, $MyDC) EndFunc ;==>OnAutoItExit Func _SetZoom() _WinAPI_SetWindowText($GUIZoom, "Crosshair- x" & $z1) $zoomX = Int($SIZEX / $z1) $zoomY = Int($SIZEY / $z1) EndFunc ;==>_SetZoom Func _WinAPI_StretchBlt($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iROP) Local $aResult = DllCall("GDI32.dll", "int", "StretchBlt", "hwnd", $hDestDC, "int", $iXDest, "int", $iYDest, "int", $iWidth, "int", $iHeight, _ "hwnd", $hSrcDC, "int", $iXSrc, "int", $iYSrc, "int", $iWidthSrc, "int", $iHeightSrc, "int", $iROP) If @error Then Return SetError(@error, 0, False) Return $aResult[0] <> 0 EndFunc ;==>_WinAPI_StretchBlt Func _ExitApplication() $bContinue = False EndFunc ;==>_ExitApplication
Have fun.
WBD
Edited by WideBoyDixon, 24 March 2009 - 01:15 PM.








