Cursor Highlighter

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Joe Glines
Posts: 770
Joined: 30 Sep 2013, 20:49
Location: Dallas
Contact:

Re: Cursor Highlighter

16 Mar 2021, 11:18

@lblb Pretty cool script! I'm going to feature it in today's AutoHotkey webinar!

While I understand the desire to have a lot of functionality, I might give a try to simplify it greatly and just have the color, size, opacity options.
Sign-up for the 🅰️HK Newsletter

ImageImageImageImage:clap:
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey :ugeek:
YouTube

:thumbup: Quick Access Popup, the powerful Windows folders, apps and documents launcher!
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

16 Mar 2021, 14:17

@Joe Glines

That's great!

Indeed, as you saw in Kevin Stratvert's video, this script is mostly aimed at people who have very little AutoHotkey knowledge and who need something usable out-of-the-box and that can be easily customized. The code itself is written as simply as possible: going for clarity, not efficiency! As you hint at, the code for just a simple cursor halo function can be only a few lines, no need for all the bells and whistles.
User avatar
Joe Glines
Posts: 770
Joined: 30 Sep 2013, 20:49
Location: Dallas
Contact:

Re: Cursor Highlighter

21 Mar 2021, 07:11

lblb wrote:
16 Mar 2021, 14:17
That's great
Just we realized that in the webinar we were going to be using my screen clipping tool as an example for for developing with VS Code. I thought it made more sense to go ahead and feature that as the script highlight. So yours will make it into the next webinar.

Yeah, I hear you regarding making things for the "average person" verse for other AutoHotkey people. It's a delicate balancing act...

Joe
Sign-up for the 🅰️HK Newsletter

ImageImageImageImage:clap:
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey :ugeek:
YouTube

:thumbup: Quick Access Popup, the powerful Windows folders, apps and documents launcher!
slaterpress
Posts: 1
Joined: 20 Apr 2021, 21:03

Re: Cursor Highlighter - hightlight disappears

21 Apr 2021, 18:19

Really great script!!

It has everything I want in a SIMPLE cursor highlighter.

But, and there is ALWAYS a but, I noticed that the highlighter does not
work when it hovers over a Windows 10 Search result. :headwall:

When I use the Windows 10 Search, the results appear and bye-bye highlight. :facepalm:

Is there a way for me to change something so the highlight shows as
I use the Search function quit a bit during screencasts.

Thanks again for creating and sharing this with us!!
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

21 Apr 2021, 19:08

@slaterpress

I'm glad you like it!

Unfortunately, the Windows menu and the search results don't allow for other windows on top of them. So they don't allow the cursor halo (which is just a colored window that follows the cursor) on top of them. This is the case for every cursor highlighter program that I have tested.

Probably your best option would be to change the arrow cursor at the Windows level to a halo cursor. You can see how that can be easily done in the first part of the Kevin Stratvert video that I linked to in the top post here.

Sorry I can't be of more help with this issue!
carno
Posts: 265
Joined: 20 Jun 2014, 16:48

Re: Cursor Highlighter

26 Apr 2021, 22:52

Thanks for the script. My question is whether this script changes or modifies the Windows Registry in any shape or form?
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

26 Apr 2021, 23:06

@carno

Nope, doesn't do anything with the registry at all. In its simplest form, all it does is that it creates a colored window that follows the mouse cursor. All settings are saved in the .ini text file that is created on first use.
carno
Posts: 265
Joined: 20 Jun 2014, 16:48

Re: Cursor Highlighter

26 Apr 2021, 23:18

@IbIb
Thanks for the confirmation. Tested and it worked out of the box. Very smooth!
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

26 Apr 2021, 23:23

I'm glad it works out for you!
erwe
Posts: 4
Joined: 22 Jun 2020, 03:26

Re: Cursor Highlighter

12 May 2021, 03:56

@IbIb

Thank you for this realy nice script!

I have a small wish:
I would like to have a function that the Halo disappers after a while, when the mouse is inative.
(And the Halo will be shown again with new start of moving the mouse)

Do you have a suggestion to realize this?

Best regards, erwe
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

12 May 2021, 14:09

@erwe

I'm glad you like it! I'll be happy to add that function to the next version of the script, which should come out in the next few weeks (I hope!)
RMWilkinson
Posts: 2
Joined: 13 May 2021, 13:42

Re: Cursor Highlighter

13 May 2021, 13:48

Hello!

We downloaded and are experimenting with Cursor Highlighter. It looks very promising but when we set the HotKeys to activate/deactivate they don't work. Seems straightforward enough - for instance Ctrl+H Save should then allow Ctrl-H to turn it on and off. No luck. What may we be missing?

Thank You!
Michael
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

13 May 2021, 15:31

@RMWilkinson

I'm glad you find it promising.

What exact hotkey are you trying to set that is not working?

Also, are other changes that you make through the settings saved (i.e., when you change something and restart the script, are the changes still present)?
RMWilkinson
Posts: 2
Joined: 13 May 2021, 13:42

Re: Cursor Highlighter

13 May 2021, 16:40

Issue resolved.

Funny thing I should have learned by now. Never report on someone else's problem. When the Junior tech who was investigating brought it to me he didn't bring me all of the information. Using "Toggle Cursor Highlighter" now works fine. He was trying to use "Switch to Cursor Focus" and the hotkey he assigned wasn't doing anything (since we were using focus and this setting had focus in the name).

I think we are good to go and thank you! This will make for cleaner videos.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

13 May 2021, 16:59

I'm glad it works out for you!
As an aside, there is a tiny bug that I haven't had time to correct yet. When you save the hotkey for "Switch to Cursor Focus", some users get an error message. But even if you get an error message, the hotkey gets saved. If you then just restart the program, the hotkey will work. This will be fixed in the next version of the script.
mobsi
Posts: 3
Joined: 25 Mar 2018, 12:52

Re: Cursor Highlighter

25 Jul 2021, 06:51

Just curious, does someone have a fixed version by now? I read most of the discussion here, and seems like most bugs related to dual-monitors seem to be fixed. Can anyone a fixed version that works on single and dual monitors without problems? I am not that good in this stuff. I already tried to implement some fix codes from the first page, but I am not sure if it is really working or if I did it right.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: Cursor Highlighter

25 Jul 2021, 16:41

@mobsi

It was my intention to update the script for the last few months, but a little worldwide pandemic got in the way... But I hope to be able to upload an updated version in the next few weeks. Stay tuned!
mike2003
Posts: 15
Joined: 09 Mar 2015, 09:45

Re: Cursor Highlighter

18 Sep 2021, 17:34

Is it possible to make a ring around the cursor? Not full circle.
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Cursor Highlighter

18 Sep 2021, 18:12

mike2003 wrote:
18 Sep 2021, 17:34
Is it possible to make a ring around the cursor? Not full circle.
You can make anything you want.

Code: Select all

#Include <My Altered GDIP lib>  ;Requires the GDI+ lib by Tic

#SingleInstance, Force
SetBatchLines, -1
CoordMode, Mouse, Screen

Gdip_Startup()

Gui1 := New PopUpWindow( { WindowName: "1" , WindowOptions: " -DPIScale +AlwaysOnTop +E0x20 " , WindowSmoothing: 2 , X: "Center" , Y: "Center" , W: 200 , H: 200 } )
Gui1.DrawBitmap( HB_BITMAP_MAKER() , { X: 0 , Y: 0 , W: 200 , H: 200 } , dispose := 1 )
Gui1.UpdateWindow()
Gui1.ShowWindow( "Demo" )

gosub, DrawLoop
SetTimer, DrawLoop, 10

return

*ESC::ExitApp

NumPad3::PopUpWindow.Helper()

DrawLoop:
	MouseGetPos, x, y 
	if( x != lx || y != ly ){
		lx := x , ly := y
		Gui, 1:Show, % "x" x - 5 " y" y - 5 " NA"
	}
	return


HB_BITMAP_MAKER(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 200 , 200 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Pen := Gdip_CreatePen( "0xFFff0000" , 1 ) , Gdip_DrawEllipse( G , Pen , 2 , 2 , 10 , 10 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFFffff00" , 2 ) , Gdip_DrawEllipse( G , Pen , 12 , 12 , 20 , 20 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF00ff00" , 3 ) , Gdip_DrawEllipse( G , Pen , 32 , 32 , 30 , 30 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF00ffff" , 4 ) , Gdip_DrawEllipse( G , Pen , 62 , 62 , 40 , 40 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF0000ff" , 5 ) , Gdip_DrawEllipse( G , Pen , 102 , 102 , 50 , 50 ) , Gdip_DeletePen( Pen )
	Gdip_DeleteGraphics( G )
	return pBitmap
}

;Plain circle. Adjust x / y offset ( " Gui, Show ") from "-5" to "-25"

;~ HB_BITMAP_MAKER(){
	;~ pBitmap := Gdip_CreateBitmap( 200 , 200 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	;~ Pen := Gdip_CreatePen( "0x99ff0000" , 5 ) , Gdip_DrawEllipse( G , Pen , 2 , 2 , 50 , 50 ) , Gdip_DeletePen( Pen )
	;~ Gdip_DeleteGraphics( G )
	;~ return pBitmap
;~ }



;Layered Window class
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
class PopUpWindow	{
	;Class By: Hellbent
	;Apr 2021
	static Index := 0 , Windows := [] , Handles := [] , HelpHandles := [] , HelperEditHwnd
	__New( obj := "" ){
		This._SetDefaults()
		if( isObject( obj ) )
			This.SetWindowProperties( obj )
		This._SetupWindowGraphics()
	}
	_SetDefaults(){
		PopUpWindow.Index++
		This.WindowName := "HBLayeredWindow" PopUpWindow.Index
		This.WindowSmoothing := 2
		This.WindowOptions := " -DPIScale +AlwaysOnTop "
		This.X := 10
		This.Y := 10
		This.W := 10
		This.H := 10
	}
	PaintBackground( color := "0xFF000000" ){
		Brush := Gdip_BrushCreateSolid( color ) 
		Gdip_FillRectangle( This.G , Brush , -1 , -1 , This.W + 2 , This.H + 2 ) 
		Gdip_DeleteBrush( Brush )
	}
	_SetupWindowGraphics(){
		This.Hwnd := This._CreateGUI()
		This.hbm := CreateDIBSection( This.W , This.H )
		This.hdc := CreateCompatibleDC()
		This.obm := SelectObject( This.hdc , This.hbm )
		This.G := Gdip_GraphicsFromHDC( This.hdc )
		Gdip_SetSmoothingMode( This.G , This.WindowSmoothing )
		PopUpWindow.Handles[ This.Hwnd ] := PopUpWindow.Index
		PopUpWindow.Windows[ PopUpWindow.Index ] := This
	}
	SetWindowProperties( obj , updateG := 0 ){
		local k , v 
		for k , v in obj
			if( k != "hwnd" )
				This[k] := v
			
			
		if(updateG){	
			SelectObject( This.hdc , This.obm )
			DeleteObject( This.hbm )
			DeleteDC( This.hdc )
			
			This.hbm := CreateDIBSection( This.W , This.H )
			This.hdc := CreateCompatibleDC()
			This.obm := SelectObject( This.hdc , This.hbm )
			This.G := Gdip_GraphicsFromHDC( This.hdc )
			Gdip_SetSmoothingMode( This.G , This.WindowSmoothing )	
		}
		( This.X = "center" ) ? ( This.X := ( A_ScreenWidth - This.W ) / 2 )
		( This.Y = "center" ) ? ( This.Y := ( A_ScreenHeight - This.H ) / 2 )
	}
	ShowWindow( Title := "" ){
		Gui , % This.WindowName ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H " NA", % Title
	}
	HideWindow(){
		Gui , % This.WindowName ":Hide",
	}
	UpdateWindow(){
		UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
	}
	ClearWindow(){
		Gdip_GraphicsClear( This.G )
	}
	DrawBitmap( pBitmap , obj , dispose := 1 ){
		Gdip_DrawImage( This.G , pBitmap , obj.X , obj.Y , obj.W , obj.H )
		if( dispose )
			Gdip_DisposeImage( pBitmap )
	}
	DeleteWindow(){
		Gui, % This.WindowName ":Destroy"
		SelectObject( This.hdc , This.obm )
		DeleteObject( This.hbm )
		DeleteDC( This.hdc )
		Gdip_DeleteGraphics( This.G )
		hwnd := This.Hwnd
		for k, v in PopUpWindow.Windows[ Hwnd ]
			This[k] := ""
		PopUpWindow.Windows[ Hwnd ] := ""
	}
	_CreateGUI(){
		local hwnd
		Gui , % This.WindowName ":New" , % " +E0x80000 hwndhwnd -Caption  " This.WindowOptions
		return hwnd
	}
	Helper(){
		local List := ["New Window","SetWindowProperties","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow"]
		local hwnd, bd
		
		
		Gui, HBLWHelperGui:New, +AlwaysOnTop 
		Gui, HBLWHelperGui:Color, 62666a, 24282c
		Gui, HBLWHelperGui:Font, cWhite s10 , Segoe UI
		Gui, HBLWHelperGui:Margin, 5 , 5
		
		Gui, HBLWHelperGui:Add, Edit, xm ym w200 r1 Center hwndHwnd, Gui1
		PopUpWindow.HelperEditHwnd := Hwnd
		Gui, HBLWHelperGui:Margin, 5 , 1
		Loop, % List.Length()	{
		
			Gui, HBLWHelperGui:Add, Button, xm wp h23 -Theme hwndhwnd, % List[ A_Index ]
			PopUpWindow.HelpHandles[hwnd] := List[ A_Index ]
			bd := PopUpWindow._ClipIt.Bind( PopUpWindow )
			GuiControl , HBLWHelperGui: +G , % Hwnd , % bd
		}
		
		Gui, HBLWHelperGui:Show, 
		
	}
	_ClipIt(){
		local List := ["New Window","SetWindowProperties","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow"]
		local Output , FQ := 400
		GuiControlGet, Output , HBLWHelperGui: , % PopUpWindow.HelperEditHwnd
		Switch A_GuiControl
		{
			case List[1]:
				Clipboard := Output " := New PopUpWindow( { WindowName: ""1"" , WindowOptions: "" -DPIScale +AlwaysOnTop "" , WindowSmoothing: 2 , X: ""Center"" , Y: ""Center"" , W: 100 , H: 100 } )"
				loop 2
					SoundBeep, FQ
				return
			case List[2]:
				Clipboard := Output ".SetWindowProperties( { X: """" , Y: """" , W: """" , H: """" } )"
				loop 2
					SoundBeep, FQ
				return
			case List[3]:
				Clipboard := Output ".ShowWindow( MyWindowTitle := """" )"
				loop 2
					SoundBeep, FQ
				return
			case List[4]:
				Clipboard := Output ".HideWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[5]:
				Clipboard := Output ".UpdateWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[6]:
				Clipboard := Output ".ClearWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[7]:
				Clipboard := Output ".DrawBitmap( pBitmap := """" , { X: """" , Y: """" , W: """" , H: """" } , dispose := 1 )"
				loop 2
					SoundBeep, FQ
				return
			case List[8]:
				Clipboard := Output ".PaintBackground( color := ""0xFF000000"" )"
				loop 2
					SoundBeep, FQ
				return
			case List[9]:
				Clipboard := Output ".DeleteWindow()"
				loop 2
					SoundBeep, FQ
				return
			Default:
				ToolTip, Looks like a new case needs to be added
				return
			
		}
	}
}
Temp (1).gif
Temp (1).gif (320.18 KiB) Viewed 2666 times
likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: Cursor Highlighter

16 Dec 2021, 13:32

If I want to toggle this through another AHK, how would I do so? I set the hotkey to win+shift+m, and call it from another program with :

Code: Select all

SendLevel, 0
Send #+m
SendLevel, 1
but it doesn't work... any suggestions?

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: chinagreenelvis and 90 guests