Cursor Highlighter

Post your working scripts, libraries and tools for AHK v1.1 and older
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Cursor Highlighter

17 Jul 2020, 05:28

Last update: v. 2.2, July 27, 2020
(Previous update: v. 2.1, July 19, 2020)

Cursor Highlighter is a program that makes the mouse cursor easier to track. There are three modes: the basic function is to create a colored "halo" around the mouse cursor. It can also be set to instead have a user-defined icon follow the mouse cursor, or to act as a "cursor focus" where the screen is darkened except for a circle around the mouse cursor. The program can be useful to make the mouse cursor more obvious for example during online lectures, or when recording tutorial videos, or when people with vision disabilities need to use a computer. You can switch between the three modes by using the tray icon or hotkeys, or on the first tab of the Settings.

Here is a great video by Kevin Stratvert that highlights the program (see around the 7:55 mark)



Here is a short demo video I had previously prepared:



To use the program, you can just download the .ahk file from the following Google Drive link:

DOWNLOAD THE CURRENT VERSION: Version 2.2, uploaded July 27, 2020: https://drive.google.com/file/d/1KntxXI_hhi69G0mQ4KV-6kx3ZiaKdbc1/view

The first time you run the script, it will ask you to create a .ini settings file that will contain all the settings for the program.

The program was designed to be highly customizable by the user. The settings are saved in the .ini file that has to be kept in the same folder as the .ahk script. Basically, almost everything (such as the size and color of the highlight, to the hotkeys used to switch between different functions, to the tray icon click behavior) can be customized. To change the program's settings, you can access the settings window by right-clicking on the program's tray icon.

Let me know if you have any comments, bug reports, or suggestions for improvements!

---------------------------------------------------------------------------------------------------------------------------

Notes:

- The code for the main function to highlight the cursor is actually just a few lines. The great majority of the script's code is for the GUI to allow for the users to customize the program's settings. And because the script is designed to be used by people who don't have much familiarity with AutoHotkey, all the necessary functions and libraries have been pasted into the script (so there is no need to download or #Include any external libraries).

- I'd love to make the source code directly available here, but the source code has too many characters to be accepted here (because the icons and images were included in the script as very long hBITMAP codes using Image2Include.ahk). But let me know if you're not comfortable downloading the script from the Google Drive link above!

---------------------------------------------------------------------------------------------------------------------------
All versions:

- Version 2.2, uploaded July 27, 2020: https://drive.google.com/open?id=1KntxXI_hhi69G0mQ4KV-6kx3ZiaKdbc1
Changelog:
- The demo video above was created.
- Corrected a bug in the color selection code.

- Version 2.1, uploaded July 19, 2020: https://drive.google.com/file/d/1YUCwbaqBTEfGBDfZWLTFdJXM4p7WoSO8/view?usp=sharing
Changelog:
- Added a verification for the presence of the .ini settings file in the script's folder. Thanks daywalker for the suggestion.
- On first use, a .ini file for the settings will be created. So no need to download the ini file anymore.
- Added tray menu option to switch between different cursor options.


- Version 2.0, uploaded July 17, 2020: https://drive.google.com/file/d/1l-ZT8kNjzQM5-FzvJER85ewhdlRoEyS4/view?usp=sharing
- Many, many changes have been made since v. 1.0!
- The program now has better compatibility when using multiple monitors of different resolutions.
- There are now three modes to make the cursor more obvious (colored "halo", picture, and cursor "focus").
- The Settings window now includes extensive customization options for about everything in the program.
- The cursor highlight can now be set to show something different on left- and right-clicks.
- Hotkeys can be defined to switch between the modes and to show/hide the cursor highlight.
Last edited by lblb on 16 Aug 2020, 17:32, edited 10 times in total.
daywalker
Posts: 32
Joined: 18 Jun 2019, 01:37

Re: Cursor Highlighter

17 Jul 2020, 07:13

Nice work, only one point: when .ini file is not found (crashed network etc) script stops at line#95 . Maybe a Fileexist() check before would handle this problem.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

19 Jul 2020, 04:05

@daywalker

I'm glad you like it!

Thanks for the suggestion. I just uploaded version 2.1 in which I added a Fileexist check for the .ini file. Hopefully this will make the script more user-friendly.
gibbons6546
Posts: 31
Joined: 07 Apr 2020, 11:53

Re: Cursor Highlighter

21 Jul 2020, 22:00

Thanks for this!
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

27 Jul 2020, 18:49

@gibbons6546
I'm glad you like it!
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

27 Jul 2020, 18:50

Updated to version 2.2.
See top post for changelog. Now with a short video to showcase the main features of the script.
JTG
Posts: 1
Joined: 07 Aug 2020, 18:33

Re: Cursor Highlighter

07 Aug 2020, 18:38

Amazing little tool and VERY helpful in just the first day.
THANKS.
One quick mention: The Highlight Cursor and Picture Cursor both move between 2 screens seamlessly, however, the Focus cursor ONLY works on one monitor. Ideas to resolve?
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

07 Aug 2020, 23:11

@JTG

I'm glad you like it!

Somehow, I think I actually didn't test the cursor focus on a multi monitor setup. Thanks for reporting the issue, I'll look into it the next time I'm on my computer.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

16 Aug 2020, 17:34

Update to top post: Cursor Highlighter was discussed by Kevin Stratvert on his YouTube channel. A link to his video was added to the top post, and is repeated below (see at the 7:55 mark for a discussion of the program):

jbroceno
Posts: 2
Joined: 26 Nov 2020, 13:44

Re: Cursor Highlighter

26 Nov 2020, 14:08

JTG wrote:
07 Aug 2020, 18:38
Amazing little tool and VERY helpful in just the first day.
THANKS.
One quick mention: The Highlight Cursor and Picture Cursor both move between 2 screens seamlessly, however, the Focus cursor ONLY works on one monitor. Ideas to resolve?
Hi there, I love this tool. I've found the same issue and I needed to solve it (I manage a three monitors desktop) so let's do it. It took me a while reading the technical manual and testing but I eventually get it working.

You must edit two routines (Cursor Highlighter 2.2.ahk)

1) Routine "Crete_Focus"

On line 1605

Code: Select all

Create_Focus:
Gui, Focus: Margin , 0, 0
Gui, Focus: -Caption +AlwaysOnTop +E0x20 +LastFound +ToolWindow
Gui, Focus: Color, %General_Color_Cursor_Focus%
Gui, Focus: Show, Maximize, Mouse Spotlight
WinGetPos, , , w, h, Mouse Spotlight ahk_class AutoHotkeyGUI
WinGet, ID, ID, Mouse Spotlight ahk_class AutoHotkeyGUI
WinSet, Transparent, %General_Cursor_Opacity_Focus%, Mouse Spotlight
Return
The "Gui, Focus: Show" affects only to main monitor. To work on full desktop you you must compute position and dimmension of the VirtualScreen. The routine will look like this

Code: Select all

Create_Focus:
Gui, Focus: Margin , 0, 0
Gui, Focus: -Caption +AlwaysOnTop +E0x20 +LastFound +ToolWindow
Gui, Focus: Color, %General_Color_Cursor_Focus%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Working only on main monitor
; Gui, Focus: Show, Maximize, Mouse Spotlight
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Working on all monitors
SysGet, VirtualScreenX, 76
SysGet, VirtualScreenY, 77
SysGet, VirtualScreenWidth, 78
SysGet, VirtualScreenHeight, 79
Gui, Focus: Show,x%VirtualScreenX% y%VirtualScreenY% h%VirtualScreenHeight% w%VirtualScreenWidth%, Mouse Spotlight
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
WinGetPos, , , w, h, Mouse Spotlight ahk_class AutoHotkeyGUI
WinGet, ID, ID, Mouse Spotlight ahk_class AutoHotkeyGUI
WinSet, Transparent, %General_Cursor_Opacity_Focus%, Mouse Spotlight
Return
2) Routine "Cut"

On line 1615

Code: Select all

Cut:
CoordMode, Mouse, Screen
MousegetPos, X1, Y1
Winset, Region, % RegionNotEllipse( w, h, X1, Y1, General_Cursor_Width_Focus/2, General_Cursor_Height_Focus/2, General_Focus_Resolution ), Mouse Spotlight ahk_class AutoHotkeyGUI
Return 
X1 and Y1 must be compensated by the top, left coordinates on virtual desktop. It will look like this

Code: Select all

Cut:
CoordMode, Mouse, Screen
MousegetPos, X1, Y1
X1 := X1 - VirtualScreenX
Y1 := Y1 - VirtualScreenY
Winset, Region, % RegionNotEllipse( w, h, X1, Y1, General_Cursor_Width_Focus/2, General_Cursor_Height_Focus/2, General_Focus_Resolution ), Mouse Spotlight ahk_class AutoHotkeyGUI
Return 
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

05 Dec 2020, 20:27

@jbroceno

Sorry for the late reply. I'm glad you like the script! And it's awesome that you were able to fix it for your needs. The remote semester has been very time-consuming and I haven't had a chance to go back and revisit the script. I'll look more into what you wrote when I have more time on my hands.

Your solution works well! Just so you know, it does have an issue that was mentioned many times on this forum where the cursor tracking methods don't work well on multiple monitors with different resolutions and sizes. But if it fits for your needs, it's great!

Cheers!
jbroceno
Posts: 2
Joined: 26 Nov 2020, 13:44

Re: Cursor Highlighter

07 Dec 2020, 06:26

Hi, I'm just a newbie on ahk. Thanks for the tip, I will search about the issue. Anyhow I've not found any problem working with the patch for the meantime.

Great job, congrats!

Jesus.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

07 Dec 2020, 12:59

@jbroceno
No need to search for the issue, I know how to solve it but I just haven't had time to update the script. As long as your patch works for your needs, you should be good!
Have fun using it!
Megasoum
Posts: 2
Joined: 08 Mar 2021, 20:54

Re: Cursor Highlighter

08 Mar 2021, 21:02

Thanks for this script, I was just looking for something like this! Basically I often play games on my TV (plugged into my PC) from my couch and it can be difficult to find the cursor when I try to do stuff on my PC monitor from far away. Windows has the "Press Ctrl key to highlight the cursor" but you can't change the hotkey and CTRL is too frequently used in games so it gets really annoying to turn that on.

I have made a small edit to your script to only highlight for a short period of time since this is what I need in my case.

I have added those two lines at line 255:

Code: Select all

	Sleep 2000
	GoSub, Start_Stop
This sub now looks like this:

Code: Select all

Switch_Toggle:
Start_Stop:
If Show_Cursor = 0
	{
	Show_Cursor = 1
	Menu, Tray, Icon, %Tray_Icon_On%
	If General_Cursor_Type = 3
		{
		GoSub, Create_Focus
		SetTimer, Cut, %General_Focus_Frequency%
		}
	Else
		{
		SetTimer, CheckMouseMovement, 0
		GoSub, Update_Cursor
		}
	Sleep 2000
	GoSub, Start_Stop
	}
Else If Show_Cursor = 1
	{
	Show_Cursor = 0
	Menu, Tray, Icon, %Tray_Icon_Off%
	If General_Cursor_Type = 3
		{
		Gui, Focus: Destroy
		SetTimer, Cut, Off
		}
	Else
		{
		SetTimer, CheckMouseMovement, Off
		Gui, PresCursor: Hide
		}
	}
Return
Obviously not supported in the GUI settings but that's fine for me. Working great now!


Edit: Actually, I have just noticed that this appears to only works on the main monitor. Is there a way to get it working on any one of the monitors where the cursor is currently on?
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

08 Mar 2021, 23:58

@Megasoum

I'm glad you find it useful and were able to modify it for your needs.

The highlight should work on every monitor. What is not working exactly?
Megasoum
Posts: 2
Joined: 08 Mar 2021, 20:54

Re: Cursor Highlighter

09 Mar 2021, 00:03

lblb wrote:
08 Mar 2021, 23:58
@Megasoum

I'm glad you find it useful and were able to modify it for your needs.

The highlight should work on every monitor. What is not working exactly?
Ah, actually the highlight does work on every monitors, you are right. It's the "Focus" option that seem to only work on the main monitor. No problems for me, I have simply switched to the standard Highlight as it is just as good for my needs.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

09 Mar 2021, 00:10

@Megasoum

Yeah, indeed in the current version the focus function only works on the main monitor. But that has been fixed in the next version that I haven't shared yet as I am still testing it.

Have fun with this!
iPhilip
Posts: 791
Joined: 02 Oct 2013, 12:21

Re: Cursor Highlighter

09 Mar 2021, 15:40

Megasoum wrote:
08 Mar 2021, 21:02
Thanks for this script, I was just looking for something like this! Basically I often play games on my TV (plugged into my PC) from my couch and it can be difficult to find the cursor when I try to do stuff on my PC monitor from far away. Windows has the "Press Ctrl key to highlight the cursor" but you can't change the hotkey and CTRL is too frequently used in games so it gets really annoying to turn that on.
@Megasoum,

This is what I use for that purpose.

Code: Select all

#NoEnv
CoordMode, Mouse, Screen

Cursor := {Color        : "Aqua"  ; Cursor color (https://www.autohotkey.com/docs/commands/Progress.htm#colors)
         , Diameter     : 75      ; Diameter of cursor in pixels
         , Transparency : 50      ; Cursor transparency as a percentage - 0 is opaque, 100 is transparent
         , ShowTime     : 2000}   ; Cursor show time in milliseconds

Gui, Cursor:Default
Gui, -Caption +ToolWindow +AlwaysOnTop +LastFound
Gui, Color, % Cursor.Color
WinSet, Transparent, % (100 - Cursor.Transparency) * 255 // 100
Winset, Region, % "E 0-0 w" (Cursor.Diameter * 2) " h" (Cursor.Diameter * 2)
Gui, Show, % "Hide w" (Cursor.Diameter * 2) " h" (Cursor.Diameter * 2)
return

^`::
Gui, Cursor:Default
Start := A_TickCount
while (A_TickCount - Start < Cursor.ShowTime) {
   MouseGetPos, X, Y
   Gui, Show, % "NA x" (X - Cursor.Diameter) " y" (Y - Cursor.Diameter)
}
Gui, Hide
return
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
HuckD
Posts: 7
Joined: 16 Feb 2021, 15:27

Re: Cursor Highlighter - Thanks

13 Mar 2021, 14:25

Thanks for this program! I have macular degeneration and this helps!
HuckD
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

13 Mar 2021, 17:53

@HuckD

Excellent, I'm glad you find it useful.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 93 guests