Jump to content

Where is that mouse cursor anyway


wolflake
 Share

Recommended Posts

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

Link to comment
Share on other sites

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:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

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:

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

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

  • Moderators

wolflake,

Quote

 not a really a waste of time

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:

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