Jump to content

Duplicate cursors with transparent image


Recommended Posts

So i borrowed this code and made some adjustments to fit my needs. Basically i am wanting to mimic the main windows cursor and create a duplicate cursor at a different location of the monitor. So on code line 18, "ToolTip("^", $mouse[0] + GUICtrlRead($xDistanceInput) - 100, $mouse[1] + GUICtrlRead($yDistanceInput))" i want that to be a transparent PNG image. That image will be a cursor image

#include <Misc.au3>

HotKeySet("{ESC}", "_exit")
$mouse = MouseGetPos()

$xDistanceInput = GUICtrlCreateInput("", 128, 0, 49, 21)
$yDistanceInput = GUICtrlCreateInput("", 128, 24, 49, 21)
_secondMouse()

While 1
    Sleep(10)
WEnd

Func _secondMouse()
    While 1
        Sleep(5)
        $mouse = MouseGetPos()
        ToolTip("^", $mouse[0] + GUICtrlRead($xDistanceInput) - 100, $mouse[1] + GUICtrlRead($yDistanceInput))
        If _IsPressed("01") Then _mouseClick()
        If _IsPressed("78") Then ;HotKeySet{F9}
            ToolTip("")
            ExitLoop
        EndIf
    WEnd
EndFunc   ;==>_secondMouse

Func _mouseClick()
    ToolTip("")
    MouseUp("left")
    MouseMove($mouse[0] + GUICtrlRead($xDistanceInput), $mouse[1] + GUICtrlRead($yDistanceInput), 0)
    MouseDown("left")
    Sleep(50)
    MouseUp("left")
    MouseMove($mouse[0], $mouse[1], 0)
    ToolTip("^", $mouse[0] + GUICtrlRead($xDistanceInput), $mouse[1] + GUICtrlRead($yDistanceInput))
EndFunc   ;==>_mouseClick

Func _exit()
    Exit
EndFunc   ;==>_exit
Link to comment
Share on other sites

Here is an idea, using a transparent GUI and an icon control with a Windows cursor :

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

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

Local $sCursorPic = @WindowsDir & "\Cursors\aero_arrow.cur"
Local $distanceX = 100
Local $distanceY = -10
Local $aPos, $aOldPos


Local $hCursorGUI = GUICreate("DUPLICATE CURSOR", 48, 48, Default, Default, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST) )
Local $picture = GUICtrlCreateIcon($sCursorPic, -1,  0, 0, 48, 48)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hCursorGUI, 0xABCDEF, 255)

GUISetState()

While 1
    $aPos = MouseGetPos()
    If IsArray($aPos) Then
        If $aPos <> $aOldPos Then
            $aOldPos = $aPos
            WinMove($hCursorGUI, "", $aPos[0] + $distanceX, $aPos[1] + $distanceY)
        EndIf
    EndIf

    Sleep(10)
WEnd

Func _Quit()
    Exit
EndFunc
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

×
×
  • Create New...