Jump to content

Recommended Posts

Posted

Every now and then I come back to my two big monitors and I can't find the mouse cursor. I'm moving the mouse around but don't seem to be looking in the right place or the right screen. In a few seconds I feel like and idiot and it is very irritating. 

So finally I wrote a program that waits for 5 minutes of idletime (no keyboard or mouse movement) and draws a nice red circle around the mouse cursor. That I can spot easily, even from across the room as I walk up to the computer. :)

It works nicely coming back from sleep mode if I press a key. If I moved the mouse to come out of sleep I can press the middle mouse button to show the red ring. As soon as I move the mouse it disappears. It has a tray menu so you can change the amount of idletime before it turns on and there is another menu choice to Exit. You can compile the script and set a link in your start menu to come on every day if you like it. 

I'm attaching a circle icon for the taskbar icon and the exe icon in case want to use it.

Thanks to Bam and martin for the circle code using window regions

;circle around mouse cursor
#AutoIt3Wrapper_Icon=circle2.ico
#NoTrayIcon
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <timers.au3>
#include <misc.au3>
;Thanks to Bam and martin for the circle code using window regions https://www.autoitscript.com/forum/topic/85970-draw-a-circle-around-the-mouse/

Global $IdleTime = 5 * 60000 ;change the 5 to the number of minutes before circle appears

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.
Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu
TraySetToolTip("ms-circle")
TrayCreateItem("SetTime")
TrayItemSetOnEvent(-1, "__SetTime")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_bye")
TraySetIcon("circle2.ico")
TraySetState()

$iCircleR = 20 ; <=== Edit this for different circle radius (in pixels)
$iCircleD = $iCircleR * 2
$pt = MouseGetPos()
$GUI = GUICreate("test", $iCircleD, $iCircleD, $pt[0] - $iCircleR, $pt[1] - $iCircleR, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0xFF0000)

$a = _CreateRoundRectRgn(0, 0, $iCircleD, $iCircleD, $iCircleD, $iCircleD)
$b = _CreateRoundRectRgn(4, 4, ($iCircleD - 8), ($iCircleD - 8), ($iCircleD - 4), ($iCircleD - 4))

_CombineRgn($a, $b)
_SetWindowRgn($GUI, $a)

GUISetState(@SW_HIDE)

While 1
    Sleep(250)
    _chk_Idle()
WEnd

;*** Functions ***

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 __SetTime()
    Local $sd, $min
    $sd = "Number of minutes"
    $min = InputBox("Now " & $IdleTime / 60000 & " minutes", $sd, "", "", -1, 122 + (13.2 * UBound(StringRegExp($sd, '\R', 3))))
    if $min > 0 then $IdleTime = $min * 60000
EndFunc   ;==>__SetTime
Func _bye()
    ToolTip("Exiting")
    Sleep(1000)
    ToolTip("", 500, 300)
    Exit
EndFunc   ;==>_bye
Func _chk_Idle()
    If _Timer_GetIdleTime() > $IdleTime Or _IsPressed(04) Then     ;1 minutes idle
        Local $wh = WinGetHandle("[active]")
        $pt = MouseGetPos()
        GUISetState()
        GUISetState(@SW_DISABLE)
        If Not @error Then WinMove($GUI, "", $pt[0] - $iCircleR, $pt[1] - $iCircleR)
        WinActivate($wh)
        While 1
            $ap = MouseGetPos()
            If $ap[0] <> $pt[0] Then
                ExitLoop
            EndIf
            Sleep(1000)
        WEnd
        GUISetState(@SW_HIDE)
    EndIf
EndFunc   ;==>_chk_Idle

 

circle2.icoFetching info...

Posted (edited)

I use this setting too and never had to search my mouse pointer since.

choose-pointer-location-setting-in-pointer-options.png

https://www.isunshare.com/windows-10/show-pointer-location-with-ctrl-key-in-windows-10.html

Edited by water
Added link

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Moderators
Posted (edited)

Exit,

In Win 10 Settings open the <Devices> - <Mouse> - <Additional mouse options> - you find that option at the bottom of the <Pointer Options> tab.

M23

Edit: Just as water shows.

Edited by Melba23

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:

  Reveal hidden contents

 

Posted (edited)

Thanks for the support guys!  I found it and turned it on.  @Melba23 thanks for giving me the extra steps to get to the right place in window settings as I'd been to the mouse settings before and not gone to "Additional mouse options"

I did have fun imagining, writing and using my program even if Microsoft had the idea much earlier so it was not a really a waste of time.

I had this idea about a round thing... might call it the wheel.

Edited by wolflake
  • Moderators
Posted

wolflake,

  Quote

 not a really a waste of time

Expand  

Absolutely not! A really clever solution for doing something you needed. But your "Google-fu" perhaps needs some improvement!

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:

  Reveal hidden contents

 

Posted

I usually just right click the mouse, then the noticable context menu pops up, which the desktop and most programs have.

Some guy's script + some other guy's script = my script!

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...