Jump to content

Recommended Posts

Posted (edited)

Hi, i'd like a circle under the mouse pointer. Searching around i have found many version of this script, i think the orginal author is larry. I don't know if this is the besta way to do it, if exist another one suggest it:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>

HotKeySet("{ESC}", "_Bye")

Global Const $pi = 3.14159265358979

$iCircleR = 20; <=== Edit this for different circle radius (in pixels)
$iCircleD = $iCircleR * 2
Global $radius = 0 ;radius of movement of the blob mouse cursor to centre of circle blob
Global $angle = 4
Global $incr = 3
$pt = MouseGetPos()

$hGUI = GUICreate("")
$hChild = GUICreate("", $iCircleD, $iCircleD, $pt[0] - $iCircleR, $pt[1] - $iCircleR, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_TRANSPARENT), $hGUI)
$A = GUICtrlCreateLabel("A", 16, 12)
_WinAPI_SetLayeredWindowAttributes($hChild, 0xFFFFFF, 125)
GUISetBkColor(0xFFFF99)

$a = _CreateRoundRectRgn(0, 0, $iCircleD, $iCircleD, $iCircleD, $iCircleD)

_SetWindowRgn($hChild, $a)

GUISetState(@SW_SHOWNOACTIVATE, $hChild)

;~ _WinAPI_ShowCursor(False)
;~ GUISetCursor(0, 1, $hGUI)
;~ GUISetCursor(0, 1, $hChild)
;~ GUICtrlSetCursor($A, 0)

While 1
    $pt = MouseGetPos()
    If Not @error Then MoveBlob($pt)
    _WinAPI_SetWindowPos($hChild, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOSENDCHANGING))
    Sleep(10)
WEnd


Func _CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc   ;==>_CreateRoundRectRgn

Func _CombineRgn(ByRef $rgn1, ByRef $rgn2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
EndFunc   ;==>_CombineRgn

Func _SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc   ;==>_SetWindowRgn

Func MoveBlob($mousePos)
    $radAng = $angle * $pi / 180
    Local $x = $mousepos[0] + $radius * Cos($radAng) - $iCircleR
    Local $y = $mousepos[1] + $radius * Sin($radAng) - $iCircleR
    WinMove($hChild, "", $x, $y)
EndFunc   ;==>MoveBlob

Func _bye()
    Exit
EndFunc   ;==>_bye

I want to have a different mouse cursor ( or hide it, but better change it ) when i have the "circle" but the normal way to do seems not work. I don't want to change "globally" the mouse cursor but only inside this circle. Thanks for the help

Edited by MyEarth
Posted

 

Try by adding this part to your script.

_CursorSet ( 'C:\Program Files (x86)\AutoIt3\Examples\Helpfile\Extras\Lens.cur', 32512 ) ; $OCR_NORMAL

Func _CursorRemove()
    DllCall ( 'user32.dll', 'int', 'SystemParametersInfo', 'int', 0x0057, 'int', 0, 'int', 0, 'int', 0 ) ; $SPI_SetCursors
EndFunc ;==> _CursorRemove()

Func _CursorSet ( $sCursorFilePath, $iCursorType )
    Local $aNewCur, $aRet
    $aNewCur = DllCall ( 'user32.dll', 'int', 'LoadCursorFromFile', 'str', $sCursorFilePath )
    If Not @error Then
        $aRet = DllCall ( 'user32.dll', 'int', 'SetSystemCursor', 'int', $aNewCur[0], 'int', $iCursorType )
        If Not @error Then DllCall ( 'user32.dll', 'int', 'DestroyCursor', 'int', $aNewCur[0] )
    EndIf
EndFunc ;==> _CursorSet()

 

AutoIt 3.3.18.0 X86 - SciTE 4.4.6.0WIN 11 24H2 X64 - Other Examples Scripts

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
×
×
  • Create New...