Jump to content

Screen Crosshairs


WideBoyDixon
 Share

Recommended Posts

I thought this might be useful for aligning controls etc. or checking alignment on, for example, a web page (or a document). Actually, I'm not sure how it might be used but I'll dump it here anyway :D

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
Link to comment
Share on other sites

Thanks for the comments. I just edited the first post with a new script which allows you to press "L" to lock the crosshair in place. Pressing "L" again unlocks it.

WBD

Link to comment
Share on other sites

Very cool. I made a slight modification to your script to suit my needs. I needed to map out screen coords X,Y for apps to click and check contents. I deleted the Zoom display on the GUI title bar and added a check, display and GUI title bar update for the mouse coords in the While...Wend.

It's still 99.99999999999999999% your code. Thanks. I needed that, badly.

#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)
    $aPos = MouseGetPos()
    _WinAPI_SetWindowText($GUIZoom, "X = " & $aPos[0] & "         Y = " & $aPos[1])
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

Angoth

Link to comment
Share on other sites

Very cool. I made a slight modification to your script to suit my needs. I needed to map out screen coords X,Y for apps to click and check contents. I deleted the Zoom display on the GUI title bar and added a check, display and GUI title bar update for the mouse coords in the While...Wend.

It's still 99.99999999999999999% your code. Thanks. I needed that, badly.

...oÝ÷ Ø à¢Øªê-y.r¥uëÞ§]rh­«­¢+Ø¥¹±Õ±Ðí
½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±ÐíU%
½¹ÍѹÑÍà¹ÔÌÐì(¥¹±Õ±Ðí5¥Í¹ÔÌÐì(¥¹±Õ±Ðí]¥¹A$¹ÔÌÐì(¥¹±Õ±Ðí]¥¹½ÝÍ
½¹ÍѹÑ̹ÔÌÐì()=ÁÐ ÅÕ½Ðí5ÕÍѱÉYÉÌÅÕ½Ðì°Ä¤()!½Ñ-åMÐ ÅÕ½ÐííM
ôÅÕ½Ðì°ÅÕ½Ðí}á¥ÑÁÁ±¥Ñ¥½¸ÅÕ½Ðì¤()±½°ÀÌØíM%i`ôÈÔØ°ÀÌØíM%idôÈÔØ°ÀÌØí
I=MM!%I}M%iôÄ°ÀÌØí   %}5=Yôà)±½°ÀÌØíU%i½½´ôU%
ÉÑ ÅÕ½Ðíi½½´ÅÕ½Ðì°ÀÌØíM%i`°ÀÌØíM%id°À°À°  ¥Ñ=H ÀÌØí]M}MeM59T°ÀÌØí]M}   =IH°ÀÌØí]M}
AQ%=8¤°ÀÌØí]M}a}Q=A5=MP¤)U%MÑ   ­
½±½È Áá¤)U%MÑMÑÑ ¤)±½°ÀÌØí
ɽÍÍ¡¥ÈôU%
ÉÑ ÅÕ½ÐìÅÕ½Ðì°Í­Ñ½Á]¥Ñ °Í­Ñ½Á!¥¡Ð°À°À°ÀÌØí]M}A=AU@°ÀÌØí]M}a}Q==1]%9=¬ÀÌØí]M}a}Q=A5=MP¤)U%MÑ   ­
½±½È ÁàÀÀÀÀÀÀ¤)U%MÑMÑÑ ¤()±½°ÀÌØíèÄôÐ)±½°ÀÌØíé½½µ`ô%¹Ð ÀÌØíM%i`¼ÀÌØíèĤ°ÀÌØíé½½µdô%¹Ð ÀÌØíM%id¼ÀÌØíèĤ°ÀÌØíÍ­ô}]¥¹A%}Ñ À¤°ÀÌØí5åô}]¥¹A%}Ñ ÀÌØíU%i½½´¤)}]¥¹A%}MÑ ­5½ ÀÌØí5å°Ä¤)±½°ÀÌØíUÍÉ10ô±±=Á¸ ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì¤)±½°ÀÌØí1½­ô±Í°ÀÌØí
½¹Ñ¥¹ÕôQÉÕ°ÀÌØíA½Ì°ÀÌØí
½±½È°ÀÌØí1ÍÑlÉtôl´Ä°´Åt°ÀÌØí5ͬ°ÀÌØí5}5ͬ°ÀÌØí¹%¹()}MÑi½½´ ¤)]¡¥±ÀÌØí
½¹Ñ¥¹Õ(% ÀÌØí1ÍÑlÁt±ÐìÐì´Ä¤Q¡¸(ÀÌØí¹%¹ôÄ(%}%ÍAÉÍÍ ÅÕ½ÐìÄÀÅÕ½Ðì°ÀÌØíUÍÉ10¤Q¡¸ÀÌØí¹%¹ôÀÌØí    %}5=Y(%}%ÍAÉÍÍ ÅÕ½ÐìÈÔÅÕ½Ðì°ÀÌØíUÍÉ10¤Q¡¸5½ÕÍ5½Ù ÀÌØí1ÍÑlÁt´ÀÌØí¹%¹°ÀÌØí1ÍÑlÅt¤(%}%ÍAÉÍÍ ÅÕ½ÐìÈÜÅÕ½Ðì°ÀÌØíUÍÉ10¤Q¡¸5½ÕÍ5½Ù ÀÌØí1ÍÑlÁt¬ÀÌØí¹%¹°ÀÌØí1ÍÑlÅt¤(%}%ÍAÉÍÍ ÅÕ½ÐìÈØÅÕ½Ðì°ÀÌØíUÍÉ10¤Q¡¸5½ÕÍ5½Ù ÀÌØí1ÍÑlÁt°ÀÌØí1ÍÑlÅt´ÀÌØí¹%¹¤(%}%ÍAÉÍÍ ÅÕ½ÐìÈàÅÕ½Ðì°ÀÌØíUÍÉ10¤Q¡¸5½ÕÍ5½Ù ÀÌØí1ÍÑlÁt°ÀÌØí1ÍÑlÅt¬ÀÌØí¹%¹¤(¹%(ÀÌØíA½Ìô5½ÕÍÑA½Ì ¤(%}%ÍAÉÍÍ ÅÕ½ÐìÑÅÕ½Ðì°ÀÌØíUÍÉ10¤Q¡¸(ÀÌØí1½­ô9½ÐÀÌØí1½­(¼(M±À ÄÀ¤(U¹Ñ¥°9½Ð}%ÍAÉÍÍ ÅÕ½ÐìÑÅÕ½Ðì°ÀÌØíUÍÉ10¤(¹%(%}%ÍAÉÍÍ ÅÕ½ÐìÈÄÅÕ½Ðì°ÀÌØíUÍÉ10¤¹ÀÌØíèıÐìÌÈQ¡¸(ÀÌØíèĨôÈ(}MÑi½½´ ¤(¼(M±À ÄÀ¤(U¹Ñ¥°9½Ð}%ÍAÉÍÍ ÅÕ½ÐìÈÄÅÕ½Ðì°ÀÌØíUÍÉ10¤(ÀÌØí1ÍÑlÁtô´Ä(¹%(%}%ÍAÉÍÍ ÅÕ½ÐìÈÈÅÕ½Ðì°ÀÌØíUÍÉ10¤¹ÀÌØíèÄÐìÄQ¡¸(ÀÌØíèļôÈ(}MÑi½½´ ¤(¼(M±À ÄÀ¤(U¹Ñ¥°9½Ð}%ÍAÉÍÍ ÅÕ½ÐìÈÈÅÕ½Ðì°ÀÌØíUÍÉ10¤(ÀÌØí1ÍÑlÁtô´Ä(¹%(% ÀÌØíA½ÍlÁt±ÐìÐìÀÌØí1ÍÑlÁt¤=È ÀÌØíA½ÍlÅt±ÐìÐìÀÌØí1ÍÑlÅt¤Q¡¸(9½ÐÀÌØí1½­¤Q¡¸(ÀÌØí5}5ͬô±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
ÉÑIÑI¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°À°ÅÕ½Ðí±½¹ÅÕ½Ðì°À°ÅÕ½Ðí±½¹ÅÕ½Ðì°À°ÅÕ½Ðí±½¹ÅÕ½Ðì°À¤(ÀÌØí5ͬô±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
ÉÑIÑI¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°À°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÅt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÁt¬Ä´ÀÌØí
I=MM!%I}M%i°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÅt¬Ä¤(±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
½µ¥¹I¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5Í­lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°È¤(ÀÌØí5ͬô±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
ÉÑIÑI¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°À°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÁt¬Ä°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÅt¬Ä´ÀÌØí
I=MM!%I}M%i¤(±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
½µ¥¹I¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5Í­lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°È¤(ÀÌØí5ͬô±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
ÉÑIÑI¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÁt¬ÀÌØí
I=MM!%I}M%i°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÅt°ÅÕ½Ðí±½¹ÅÕ½Ðì°Í­Ñ½Á]¥Ñ °ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÅt¬Ä¤(±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
½µ¥¹I¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5Í­lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°È¤(ÀÌØí5ͬô±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
ÉÑIÑI¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÅt¬ÀÌØí
I=MM!%I}M%i°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíA½ÍlÁt¬Ä°ÅÕ½Ðí±½¹ÅÕ½Ðì°Í­Ñ½Á!¥¡Ð¤(±±
±° ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½Ðí
½µ¥¹I¸ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5Í­lÁt°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°È¤(±±
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÅÕ½ÐíMÑ]¥¹½ÝI¸ÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí
ɽÍÍ¡¥È°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí5}5Í­lÁt°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°Ä¤(ÀÌØí1ÍÐôÀÌØíA½Ì(¹%(¹%(}]¥¹A%}MÑÉÑ¡   ±Ð ÀÌØí5å°À°À°ÀÌØíM%i`°ÀÌØíM%id°ÀÌØíÍ­°ÀÌØíA½ÍlÁt´ ÀÌØíé½½µ`¼È¤°ÀÌØíA½ÍlÅt´ ÀÌØíé½½µd¼È¤°ÀÌØíé½½µ`°ÀÌØíé½½µd°ÀÌØíMI

=Ad¤(M±À ÔÀ¤(ÀÌØíA½Ìô5½ÕÍÑA½Ì ¤($ÀÌØí
½±½ÈôA¥á±Ñ
½±½È ÀÌØíA½ÍlÁt°ÀÌØíA½ÍlÅt¤(}]¥¹A%}]¥¹½ÝQáÐ ÀÌØíU%i½½´°ÅÕ½Ðí`èÅÕ½ÐìµÀìÀÌØíA½ÍlÁtµÀìÅÕ½ÐìdèÅÕ½ÐìµÀìÀÌØíA½ÍlÅtµÀìÅÕ½Ðì
½±½ÈèÅÕ½ÐìµÀìÅÕ½ÐìÁàÅÕ½ÐìµÀì!à ÀÌØí
½±½È°Ø¤¤)]¹()U%MÑMÑÑ¡M]}!%°ÀÌØí
ɽÍÍ¡¥È¤)U%MÑMÑÑ¡M]}!%°ÀÌØíU%i½½´¤)U%±Ñ ÀÌØí
ɽÍÍ¡¥È¤)U%±Ñ ÀÌØíU%i½½´¤)±±
±½Í ÀÌØíUÍÉ10¤()á¥Ð()Õ¹=¹Õѽ%Ñá¥Ð ¤(}]¥¹A%}I±Í À°ÀÌØíÍ­¤(}]¥¹A%}I±Í ÀÌØíU%i½½´°ÀÌØí5å¤)¹Õ¹ìôôÐí=¹Õѽ%Ñá¥Ð()Õ¹}MÑi½½´ ¤(}]¥¹A%}]¥¹½ÝQáÐ ÀÌØíU%i½½´°ÅÕ½Ðí
ɽÍÍ¡¥È´àÅÕ½ÐìµÀìÀÌØíèĤ(ÀÌØíé½½µ`ô%¹Ð ÀÌØíM%i`¼ÀÌØíèĤ(ÀÌØíé½½µdô%¹Ð ÀÌØíM%id¼ÀÌØíèĤ)¹Õ¹ìôôÐí}MÑi½½´()Õ¹}]¥¹A%}MÑÉÑ¡    ±Ð ÀÌØí¡ÍÑ°ÀÌØí¥aÍаÀÌØí¥eÍаÀÌØí¥]¥Ñ °ÀÌØí¥!¥¡Ð°ÀÌØí¡MÉ°ÀÌØí¥aMÉ°ÀÌØí¥eMÉ°ÀÌØí¥]¥Ñ¡MÉ°ÀÌØí¥!¥¡ÑMÉ°ÀÌØí¥I=(1½°ÀÌØíIÍÕ±Ðô±±
±° ÅÕ½Ðí$Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíMÑÉÑ¡   ±ÐÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí¡ÍÑ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥aÍаÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥eÍаÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥]¥Ñ °ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥!¥¡Ð°|(ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí¡MÉ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥aMÉ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥eMÉ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥]¥Ñ¡MÉ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥!¥¡ÑMÉ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí¥I=(%ÉɽÈQ¡¸IÑÕɸMÑÉɽȡÉɽȰÀ°±Í¤(IÑÕɸÀÌØíIÍÕ±ÑlÁt±ÐìÐìÀ)¹Õ¹ìôôÐí}]¥¹A%}MÑÉÑ¡  ±Ð()Õ¹}á¥ÑÁÁ±¥Ñ¥½¸ ¤(ÀÌØí
½¹Ñ¥¹Õô±Í)¹Õ¹ìôôÐí}á¥ÑÁÁ±¥Ñ¥½

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Something like this?:

#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 $iCurrent = 0, $bContinue = True, $aPos, $aColor, $aLast[2] = [-1, -1], $aMask, $aM_Mask, $nInc, $aPoints[2][2] = [[-1, -1], [-1, -1]], $i

_SetZoom()
While $bContinue
    $bContinue = (GUIGetMsg() <> $GUI_EVENT_CLOSE)
    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 $iCurrent < 2 Then
        $aPoints[$iCurrent][0] = $aPos[0]
        $aPoints[$iCurrent][1] = $aPos[1]
    EndIf
    If _IsPressed("01", $UserDLL) Then
        If $iCurrent < 2 Then
            ToolTip("[" & $aPoints[$iCurrent][0] & "," & $aPoints[$iCurrent][1] & "]", $aPoints[$iCurrent][0], $aPoints[$iCurrent][1])
        EndIf
        $iCurrent += 1
        If $iCurrent > 2 Then $iCurrent = 0
        Do
            Sleep(10)
        Until Not _IsPressed("01", $UserDLL)
        $aLast[0] = -1
    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
        $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
        For $i = 0 To 1
            If $aPoints[$i][0] >= 0 Then
                $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", $aPoints[$i][1], "long", $aPoints[$i][0] + 1 - $CROSSHAIR_SIZE, "long", $aPoints[$i][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", $aPoints[$i][0], "long", 0, "long", $aPoints[$i][0] + 1, "long", $aPoints[$i][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", $aPoints[$i][0] + $CROSSHAIR_SIZE, "long", $aPoints[$i][1], "long", @DesktopWidth, "long", $aPoints[$i][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", $aPoints[$i][0], "long", $aPoints[$i][1] + $CROSSHAIR_SIZE, "long", $aPoints[$i][0] + 1, "long", @DesktopHeight)
                DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2)
            EndIf
        Next
        DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $Crosshair, "long", $aM_Mask[0], "int", 1)
        $aLast = $aPos
    EndIf
    _WinAPI_StretchBlt($MyDC, 0, 0, $SIZEX, $SIZEY, $DeskDC, $aPos[0] - ($zoomX / 2), $aPos[1] - ($zoomY / 2), $zoomX, $zoomY, $SRCCOPY)
    Sleep(50)
    $aPos = MouseGetPos()
    $aColor = PixelGetColor($aPos[0], $aPos[1])
    _WinAPI_SetWindowText($GUIZoom, "X: " & $aPos[0] & " Y: " & $aPos[1] & " Color: " & "0x" & Hex($aColor, 6))
WEnd

GUIDelete($Crosshair)
GUIDelete($GUIZoom)
DllClose($UserDLL)

Exit

Func OnAutoItExit()
    _WinAPI_ReleaseDC(0, $DeskDC)
    _WinAPI_ReleaseDC($GUIZoom, $MyDC)
EndFunc   ;==>OnAutoItExit

Func _SetZoom()
    $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

WBD

Link to comment
Share on other sites

  • 4 weeks later...
Link to comment
Share on other sites

  • Moderators

All,

Works on my Vista x32 Sp1 HP. Although it does flicker a bit and it occasionally misses the mouse clicks.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Love the script...could have used this a while back, saved in my archive now for future use if I so have a need.

Thanks again,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • 9 years later...
  • Moderators

tonycst,

Running code from 9 years ago I am surprised you do not get more errors!

_WinAPI_StretchBlt is now one of the standard AutoIt includes - as a quick glance at the Help file would have told you - so you no longer need it defined as a separate function in the script. Delete those few lines and the example works fine - for me at least.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...