Jump to content

Highlight Mouse Cursor - do you have an idea?


Recommended Posts

Hi there,

i'm writing a little Screenshot-Tool to capture the Screen on any mouse click. It's used to document Software-Installations (every click = 1 screenshot).

Now i'm trying to highlight the Mouse-Cursor, so that it's more present in the screenshots (with an 50% transparent yellow circle, for example). I didn't find anything related to this in the Forums/Google, so i tried a little bit around.

1) SplashScreenOn: Show a Picture at the Mouse-Position, updated every 100ms. It works, but it's flickering and use a high CPU-Load.
2) _WinAPI_SetSystemCursor: Could be possible; but i don't want to change anything on the PCs, on which the tool is executed. So maybe a Plan B.
3) ...

Maybe, someone has an idea how to solve this? As i wrote, i don't want to change things on the System, where the tool is exectuted. Also, a lightweight 3rd-Party Tool (without installation) could be a solution, bit i also didn't find something "light". 

Thanks in advance,

Bastian

Link to post
Share on other sites

Found this from something i put together years ago. Not well written but seems to work ok. 

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#AutoIt3Wrapper_Icon=HL.ico
#AutoIt3Wrapper_Outfile=HL.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <ColorConstants.au3>
#include <TrayConstants.au3>
#include <Misc.au3>


;$COLOR_AQUA = 0x00FFFF
; $COLOR_BLACK
;$COLOR_BLUE
; $COLOR_CREAM
;$COLOR_FUCHSIA
;Global Const $COLOR_GRAY
;Global Const $COLOR_GREEN
;Global Const $COLOR_LIME
;Global Const $COLOR_MAROON
;Global Const $COLOR_MEDBLUE
;Global Const $COLOR_MEDGRAY
;Global Const $COLOR_MONEYGREEN
;Global Const $COLOR_NAVY
;Global Const $COLOR_OLIVE
;Global Const $COLOR_PURPLE
;Global Const $COLOR_RED
;Global Const $COLOR_SILVER
;Global Const $COLOR_SKYBLUE
;Global Const $COLOR_TEAL
;Global Const $COLOR_WHITE
;Global Const $COLOR_YELLOW


Global $aPos, $aOldPos
Global $hCursorGUI, $picture
Global $ValueTransparency=IniRead("HighlightCursor.ini","Settings","Transparency","90")
Global $ValueRadius=IniRead("HighlightCursor.ini","Settings","Radius","50")
Global $ValueColour=IniRead("HighlightCursor.ini","Settings","Colour",$COLOR_RED)
Global $ValueBorder=IniRead("HighlightCursor.ini","Settings","Border","True")


#Region Tray
Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
$TrayOnOff = TrayCreateItem("Turn off")
TrayCreateItem("") ; Create a separator line.
$TraySetColour = TrayCreateItem("Set Colour")
$TrayToggleShowBorder=TrayCreateItem("Hide Border")
$TraySetRadius = TrayCreateItem("Set Radius ("&$ValueRadius&")")
TrayCreateItem("") ; Create a separator line.
$TraySetTransparency = TrayCreateItem("Set Transparency ("&$ValueTransparency&"%)")
TrayCreateItem("") ; Create a separator line.
$TrayExit = TrayCreateItem("Exit")
TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
#EndRegion Tray




Func SetupHighlight($ValueRadius,$ValueColour,$ValueTransparency)
GUIDelete($hCursorGUI)
$hCursorGUI = GUICreate("DUPLICATE CURSOR", $ValueRadius, $ValueRadius, Default, Default, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST) )
_WinAPI_SetWindowLong($hCursorGUI, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hCursorGUI, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))
$picture = GUICtrlCreateGraphic (0, 0, $ValueRadius, $ValueRadius)
GUICtrlSetStyle($picture, $SS_NOTIFY)
GUICtrlSetBkColor($picture, 0xffffff)
;GUICtrlSetColor ($picture, $ValueColour )
;GUICtrlSetGraphic($picture,$GUI_GR_PENSIZE,0.5)
if $ValueBorder = "True" then
GUICtrlSetGraphic($picture, $GUI_GR_COLOR, 0, $ValueColour)
Else
    GUICtrlSetGraphic($picture, $GUI_GR_COLOR, $ValueColour, $ValueColour)
EndIf

GUICtrlSetGraphic($picture, $GUI_GR_ELLIPSE,0,0,$ValueRadius,$ValueRadius)
_WinAPI_SetLayeredWindowAttributes($hCursorGUI, 0xffffff, 100-$ValueTransparency)
GUISetState()
EndFunc


SetupHighlight($ValueRadius,$ValueColour,$ValueTransparency)

#include <WinAPI.au3>

GUIRegisterMsg(0x024B, "WM_POINTERACTIVATE")

Func WM_POINTERACTIVATE($hWnd, $iMsg, $wParam, $lParam)
    Local $nNotifyCode = _WinAPI_HiWord($wParam)
    Local $iId = _WinAPI_LoWord($wParam)
    Local $hCtrl = $lParam

    If $iId <> 2 And $nNotifyCode = 0 Then ; Check for IDCANCEL - 2

            Local $hFocus = _WinAPI_GetFocus()
            Local $idControl = _WinAPI_GetDlgCtrlId($hFocus)
            MsgBox($MB_SYSTEMMODAL, "WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @CRLF & _
                    "MsgId" & @TAB & ":" & $iMsg & @CRLF & _
                    "wParam" & @TAB & ":" & $wParam & @CRLF & _
                    "lParam" & @TAB & ":" & $lParam & @CRLF & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlId" & @TAB & ":" & $iId & @CRLF & _
                    "CtrlHWnd" & @TAB & ":" & $hCtrl)
;            PostButtonClick($hWnd, $idControl)

        Return 0 ; Only workout clicking on the button
    EndIf

    ; On exit the default AutoIt3 internal message handler will run
    ; It will also run if "Return" returns $GUI_RUNDEFMSG as below
    ; Using "Return" with any other value (or no value at all) means the AutoIt handler
    ; will not run
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND


While 1
    consolewrite("--> "&_WinAPI_GetSystemMetrics(86)&" -- ")
    $aPos = MouseGetPos()
    If IsArray($aPos) Then
        If $aPos <> $aOldPos Then
            $aOldPos = $aPos
            WinMove($hCursorGUI, "", $aPos[0] + -$ValueRadius/2, $aPos[1] + -$ValueRadius/2)
        EndIf
    EndIf

    Switch TrayGetMsg() ;do things based on tray selections
        case $TrayOnOff
            if TrayItemGetText($TrayOnOff)="Turn off" Then
                GUIDelete($hCursorGUI)
                TrayItemSetText($TrayOnOff,"Turn on")
            Else

                TrayItemSetText($TrayOnOff,"Turn off")
            SetupHighlight($ValueRadius,$ValueColour,$ValueTransparency)
            EndIf




        Case $TrayExit
            Exit
        Case $TraySetColour
            $oldC = $ValueColour
                $ValueColour = _ChooseColor(2,$ValueColour,2)

                IniWrite("HighlightCursor.ini","Settings","Colour",$ValueColour)


            ;GUICtrlSetGraphic($picture, $GUI_GR_ELLIPSE,0,0,$ValueRadius,$ValueRadius)
            SetupHighlight($ValueRadius,$ValueColour,$ValueTransparency)

        Case $TrayToggleShowBorder
            if TrayItemGetText($TrayToggleShowBorder)="Show border" Then
                $ValueBorder="True"
                TrayItemSetText($TrayToggleShowBorder,"Hide Border")
            Else
                TrayItemSetText($TrayToggleShowBorder,"Show Border")
                $ValueBorder="False"
            EndIf
            IniWrite("HighlightCursor.ini","Settings","Border",$ValueBorder)
            SetupHighlight($ValueRadius,$ValueColour,$ValueTransparency)


        Case $TraySetRadius
            $oldR=$ValueRadius
            $ValueRadius = InputBox("Radius","Enter Radius - any text will result in a radius not changing", $ValueRadius)
            if not StringIsDigit($ValueRadius) then
                msgbox(0,"Error","not an integer")
                $ValueRadius = $oldR
            Else
                IniWrite("HighlightCursor.ini","Settings","Radius",$ValueRadius)
            EndIf


            ;GUICtrlSetGraphic($picture, $GUI_GR_ELLIPSE,0,0,$ValueRadius,$ValueRadius)
            SetupHighlight($ValueRadius,$ValueColour,$ValueTransparency)
            TrayItemSetText($TraySetRadius,"Set Radius ("&$ValueRadius&")")

        case $TraySetTransparency
            $oldT = $ValueTransparency
                $ValueTransparency = InputBox("Transparency","Enter Transparency (0=solid to 100=invisible) - any text will result transparency not changing", $ValueTransparency)
            if not StringIsDigit($ValueTransparency) then
                msgbox(0,"Error","not an integer")
                $ValueTransparency = $oldT
            Else
                IniWrite("HighlightCursor.ini","Settings","Transparency",$ValueTransparency)
            EndIf

            ;GUICtrlSetGraphic($picture, $GUI_GR_ELLIPSE,0,0,$ValueRadius,$ValueRadius)
            SetupHighlight($ValueRadius,$ValueColour,$ValueTransparency)
            TrayItemSetText($TraySetTransparency,"Set Transparency ("&$ValueTransparency&"%)")




    EndSwitch

    Sleep(10)
WEnd

 

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...