Cursor Highlighter

Post your working scripts, libraries and tools for AHK v1.1 and older
nyfer
Posts: 5
Joined: 26 Aug 2022, 10:20

Re: Cursor Highlighter

Post by nyfer » 27 Aug 2022, 04:42

@LAPIII Thank you for this. its helpful, but i would really appreciate if you can guide me to add the required changes for Cursor highlighter script.
The reason is, since the Cursor highlighter script is helpful for my need, but I just need to tweak the halo with the circle

nyfer
Posts: 5
Joined: 26 Aug 2022, 10:20

Re: Cursor Highlighter

Post by nyfer » 28 Aug 2022, 16:08

@LAPIII After much hardwork and references , i was able to replace the halo with the circle
I referred to this script for the circle https://autohotkey.com/board/topic/7377-create-a-transparent-circle-in-window-w-winset-region/

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Cursor Highlighter

Post by LAPIII » 28 Aug 2022, 16:41

Could you please paste what you came up with?

s_tarnow
Posts: 2
Joined: 21 Sep 2022, 20:55

Cursor Highlighter Error with Digital Pen

Post by s_tarnow » 21 Sep 2022, 21:01

I'm a teacher and I've been using this cursor highlighter for a couple years now. I use a touch screen computer, so I frequently need the highlighter to make it obvious where on the screen my pen is hovering above. It worked perfectly in June, but since trying to use it in the new school year (since the start of september), I've noticed that there is a strange bug that is making the highlighter not work properly with my computer's pen.

The highlighter will follow my pen overtop of the desktop and taskbar. However, when I try to move my pen overtop of any other window (Web browser, OneNote, Word, etc.), the highlighter no longer follows my pen.

Any thoughts on how to fix this?

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

Re: Cursor Highlighter

Post by lblb » 22 Sep 2022, 01:25

@s_tarnow

Have you changed anything on your computer since June? Are you using a new version of Windows?

It doesn't seem to be possible to use Cursor Highlighter (or any other similar program that I have tried) with a pen in so-called "UWP" apps such as the "OneNote for Windows" app. But strangely, it should work if you use a mouse in these programs. But Cursor Highlighter should work with the pen in normal desktop programs such as the regular OneNote program.

Are you using different programs from what you were using in June?

User avatar
Relayer
Posts: 160
Joined: 30 Sep 2013, 13:09
Location: Delaware, USA

Re: Cursor Highlighter

Post by Relayer » 22 Sep 2022, 14:17

Hi,

I just noticed a problem with the script today. If I go to use a picture of the pens and pencil I can get only two to work depending on which one was active when I shut down the script. Doing some debugging I found that two end up with hBitmap being 0 (zero). I found that by placing all four functions that render hBitmaps early in the script fixes the issue but I'm not sure why. It's as if the rendering of the hBitmaps works well when done early and it stores them in the static variable in each function so they are available to use. Calling those functions later after using the script for a while sets two of the pictures hBitmap to zero.

So, I placed these four lines early in the script:

Code: Select all

Create_Blue_Pen_Up_ico()
Create_Green_Pen_Up_ico()
Create_Red_Pen_Up_ico()
Create_Pencil_Up_ico()
Relayer

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

Re: Cursor Highlighter

Post by lblb » 25 Sep 2022, 05:43

@Relayer

Thanks for letting me know. I'll look into it.

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Cursor Highlighter

Post by Hellbent » 07 Oct 2022, 11:40

Cursor Path Tracer *( highly customizable )*
arrow mouse trail 1.gif
arrow mouse trail 1.gif (518.65 KiB) Viewed 1873 times

Code: Select all

;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;
;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;

#Include gdip.ahk  		;<<<<<<<------------------------------

;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;
;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;

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

;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;
;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;

Gdip_Startup()
AlphaList  := [ "F" , "E" , "D" , "C" , "B" , "A" , "9" , "8" , "7" , "6" , "5" , "4" , "3" , "2" , "1" , "0" ]
MaxIndex := AlphaList.Length()
Gui1 := New PopUpWindow( { AutoShow: 1 , X: 0 , Y: 0 , W: A_ScreenWidth , H: A_ScreenHeight , Options: " -DPIScale +AlwaysOnTop +E0x20" } )

gosub, ^y

return

;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;
;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;

*ESC::ExitApp

;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;
;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;

^y::
	if( tog := !Tog ){
		MouseGetPos, x, y 
		CurrentPosition := New Vector( x , y )
		LastPosition := New Vector( CurrentPosition )
		Index := 0
		ResetIndex := 1
		scale := 0.5
		ArrowArray := []
		SetTimer, WatchCursor , 30
	}else{
		SetTimer, WatchCursor , Off
		Gui1.ClearWindow( 1 )
	}
	return 

;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;
;|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|000---<^>---000|;
		
WatchCursor:
	MouseGetPos, x, y 
	Gui1.ClearWindow()
		loop, % ln := ArrowArray.Length() 	{
			FillPolygon( Gui1.G , ArrowArray[ ln ].ArrowPoints , "0x" AlphaList[ ArrowArray[ ln ].Alpha1 ] "FFF0000" )
			DrawPolygon( Gui1.G , ArrowArray[ ln ].ArrowPoints , "0x" AlphaList[ ArrowArray[ ln ].Alpha1 ] "F000000" , 3 )
			if( ++ArrowArray[ ln ].Alpha1 > ArrowArray[ ln ].MaxIndex )
					ArrowArray.RemoveAt(  ln  )
			ln--		
		}
	if( ++Index >= ResetIndex  && ( Abs( x - LastPosition.X ) > 30 ) || Abs( y - LastPosition.Y ) > 30 ){
		Index := 0	
		CurrentPosition := New Vector( x , y )
		Master := New Vector( LastPosition ) 
		Master.Sub( CurrentPosition )
		m := Master.GetMag() * 0.001
		Master.SetMag( m )
		Master.Add( LastPosition )
		MyArrow := New ArrowHead_2( Master , CurrentPosition , 25 * scale , 5 * scale , 15 * scale , 7 * scale )
		FillPolygon( Gui1.G , MyArrow , "0xFFFF0000" )
		DrawPolygon( Gui1.G , MyArrow , "0xFF000000" , 3 )
		
		ArrowArray.Push( { ArrowPoints: MyArrow , Alpha1: 1 , MaxIndex: MaxIndex } )
		LastPosition := New Vector( CurrentPosition )
	}
	Gui1.UpdateWindow(155)	
	return

;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;

class ArrowHead_2	{
	
	__New( Start , End , HeadLength := 30 , NeckLength := 10 , ArmLength := 30 , ElbowLength := 15 ){
		
		Master := This._NewVector( Start )
		This._SubVector( Master , End )
		
		Head := This._NewVector( Master )
		This._SetVectorMag( Head , HeadLength )
		This._AddVector( Head , End )
		
		Neck := This._NewVector( Master )
		This._SetVectorMag( Neck , NeckLength )
		This._AddVector( Neck , Head )
		
		RightArm := This._NewVector( Master , , 1 )
		This._SetVectorMag( RightArm , ArmLength )
		This._AddVector( RightArm , Neck )
		
		RightElbow := This._NewVector( Master , , 1 )
		This._SetVectorMag( RightElbow , ElbowLength )
		This._AddVector( RightElbow , Head )
		
		LeftArm := This._NewVector( Master , , 2 )
		This._SetVectorMag( LeftArm , ArmLength )
		This._AddVector( LeftArm , Neck )
		
		LeftElbow := This._NewVector( Master , , 2 )
		This._SetVectorMag( LeftElbow , ElbowLength )
		This._AddVector( LeftElbow , Head )
		
		OutputString := ""
		for k , v in [ "Start" , "RightElbow" , "RightArm" , "End" , "LeftArm" , "LeftElbow" , "Start" ]	
			OutputString .= %v%.X "," %v%.Y "|"
		return OutputString 
	}
	
	_NewVector( x , y := "" , rotate := 0 ){
		if( IsObject( x ) ){
			if( !rotate )
				return { X: x.X , Y: x.Y }
			else if( rotate = 1 )
				return { X: x.Y * -1 , Y: x.X }
			else if( rotate = 2 )
				return { X: x.Y , Y: x.X * -1 }
		}else{
			if( !rotate )
				return { X: x , Y: x }
			else if( rotate = 1 )
				return { X: y * -1 , Y: x }
			else if( rotate = 2 )
				return { X: y , Y: x * -1 }
		}
	}
	
	_SubVector( vector1 , vector2 ){
		vector1.X -= vector2.X
		vector1.Y -= vector2.Y
	}
	
	_AddVector( vector1 , vector2 ){
		vector1.X += vector2.X
		vector1.Y += vector2.Y
	}
	
	_SetVectorMag( vector , mag ){
		local m := This._GetVectorMag( vector )
		vector.X := vector.X * mag / m
		vector.Y := vector.Y * mag / m
	}
	
	_GetVectorMag( vector ){
		return Sqrt( vector.X * vector.X + vector.Y * vector.Y )
		
	}
	
}

;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;

Class Vector	{
	;Written By: HB
	;Date: Sept 23rd, 2022
	;Last Edit: Sept 24th, 2022
	;Purpose: Vector math class 
	;Credit: Rohwedder 
	;Resources: 
		;Line intercept concepts and code: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=37175
		;Create an Arrow: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92039&p=479129#p478944
		;Getting an angle: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=108760&p=483661#p483678
		;Setting an Angle: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=108760&p=483786#p483811
		;
		
	static RadToDeg := 45 / ATan( 1 ) 
		, DegToRad := ATan( 1 ) / 45 
		
	__New( x := 0 , y := 0 , rotate := 0 ){ 
		if( IsObject( x ) ){
			if( rotate = 3 ){
				This.X := x.X * -1
				,This.Y := x.Y * -1
			}else if( rotate = 2 ){
				This.X := x.Y 
				,This.Y := x.X * -1
			}else if( rotate = 1 ){
				This.X := x.Y * -1
				,This.Y := x.X 
			}else{
				This.X := x.X
				,This.Y := x.Y
			}
		}else{
			if( rotate = 3 ){
				This.X := X * -1
				,This.Y := Y * -1
			}else if( rotate = 2 ){
				This.X := Y 
				,This.Y := X * -1
			}else if( rotate = 1 ){
				This.X := Y * -1
				,This.Y := X 
			}else{
				This.X := X
				,This.Y := Y
			}
		}
	}
	
	Add( x , y := "" ){
		if( IsObject( x ) ){
			This.X += x.X
			,This.Y += x.Y
		}else if( y = "" ){
			This.X += x 
			,This.Y += x
		}else{
			This.X += x 
			,This.Y += y 
		}
	}
	Sub( x , y := "" ){
		if( IsObject( x ) ){
			This.X -= x.X
			,This.Y -= x.Y
		}else if( y = "" ){
			This.X -= X
			,This.Y -= X
		}else{
			This.X -= X
			,This.Y -= Y
		}
	}
	Div( x , y := "" ){
		if( IsObject( x ) ){
			This.X /= x.X
			,This.Y /= x.Y
		}else if( x && y = "" ){
			This.X /= x 
			,This.Y /= x 
		}else{
			This.X /= X
			,This.Y /= Y
		}
	}
	Mult( x , y := "" ){
		if( IsObject( x ) ){
			This.X *= x.X
			,This.Y *= x.Y
		}else if( x && y = "" ){
			This.X *= x 
			,This.Y *= x 
		}else{
			This.X *= X
			,This.Y *= Y
		}
	}
	Dist( x , y := "" ){
		if( IsObject( x ) )
			return Sqrt( ( ( This.X - x.X ) **2 ) + ( ( This.Y - x.Y ) **2 ) )
		else 
			return Sqrt( ( ( This.X - X ) **2 ) + ( ( This.Y - Y ) **2 ) )
	}
	GetMag(){
		return Sqrt( This.X * This.X + This.Y * This.Y )
	}
	SetMag( magnitude ){
		local m := This.GetMag()
		This.X := This.X * magnitude / m
		,This.Y := This.Y * magnitude / m
	}
	MagSq(){
		return This.GetMag()**2
	}	
	Dot( x , y := "" ){
		if( IsObject( x ) )
			return ( This.X * x.X ) + ( This.Y * x.Y )
		else
			return ( This.X * X ) + ( This.Y * Y )
	}
	Cross( x , y := "" ){
		if( IsObject( x ) )
			return This.X * x.Y - This.Y * x.X
		else
			return This.X * Y - This.Y * X
		
	}
	Norm(){
		local m := This.GetMag()
		This.X /= m
		This.Y /= m
	}
	GetAngle(){ 
		local angle 
		( (  angle := Vector.RadToDeg * DllCall( "msvcrt\atan2" , "Double" , This.Y , "Double" , This.X , "CDECL Double" ) ) < 0 ) ? ( angle += 360 )
		return angle
	}
	SetAngle( newAngle := 0 , NewVector := 0 ){
		local Angle := This.GetAngle()
		, ChangeAngle := newAngle - Angle 
		, Co := Cos( Vector.DegToRad * ChangeAngle )
		, Si := Sin( Vector.DegToRad * ChangeAngle )
		, X := This.X 
		, Y := This.Y
		, X2 := X * Co - Y * Si 
		, Y2 := X * Si + Y * Co 
		
		if( !NewVector )
			This.X := X2 , This.Y := Y2
		else 
			return New Vector( X2 , Y2 )
	}
	RotateAngle( rotationAmount := 90 , NewVector := 0 ){
		local Co := Cos( Vector.DegToRad * rotationAmount )
		, Si := Sin( Vector.DegToRad * rotationAmount )
		, X := This.X 
		, Y := This.Y
		, X2 := X * Co - Y * Si 
		, Y2 := X * Si + Y * Co 
		if( !NewVector )
			This.X := X2 , This.Y := Y2
		else 
			return New Vector( X2 , Y2 )
	}
	;********************************************
	;class methods
	TestLineInterceptPoint( interceptPoint , Line1 , Line2 ){ ; Line = { Start: { X: , Y: } , End: { X: , Y: } } , interceptPoint = { X: , Y: }
		local
		for k , v in [ "X" , "Y" ]	
			M%v%_Min := min( Line1.Start[ v ] , Line1.End[ v ] )
			,M%v%_Max := max( Line1.Start[ v ] , Line1.End[ v ] )
			,L%v%_Min := min( Line2.Start[ v ] , Line2.End[ v ] )
			,L%v%_Max := max( Line2.Start[ v ] , Line2.End[ v ] )
		if( !( interceptPoint.X < Mx_Min || interceptPoint.X > Mx_Max || interceptPoint.X < Lx_Min || interceptPoint.X > Lx_Max ) && !( interceptPoint.Y < My_Min || interceptPoint.Y > My_Max || interceptPoint.Y < Ly_Min || interceptPoint.Y > Ly_Max ) )
			return 1
		return 0
	}
	GetLineInterceptPoint( Line1 , Line2 ){ ; Line = { Start: { X: , Y: } , End: { X: , Y: } }
		local A1 := Line1.End.Y - Line1.Start.Y
		,B1 := Line1.Start.X - Line1.End.X
		,C1 := A1 * Line1.Start.X + B1 * Line1.Start.Y
		,A2 := Line2.End.Y - Line2.Start.Y
		,B2 := Line2.Start.X - Line2.End.X
		,C2 := A2 * Line2.Start.X + B2 * Line2.Start.Y
		,Denominator := A1 * B2 - A2 * B1 
		return New Vector( { X: ( ( B2 * C1 - B1 * C2 ) / Denominator )  , Y: ( ( A1 * C2 - A2 * C1 ) / Denominator ) } )
	}
	;********************************************
	
}

;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;

class PopUpWindow	{
;PopUpWindow v2.2
;Date Written: Oct 28th, 2021
;Last Edit: Feb 7th, 2022 :Changed the trigger method.
;Written By: Hellbent aka CivReborn
;SpcThanks: teadrinker , malcev 
	static Index := 0 , Windows := [] , Handles := [] , EditHwnd , HelperHwnd
	__New( obj := "" ){
		This._SetDefaults()
		This.UpdateSettings( obj )
		This._CreateWindow()
		This._CreateWindowGraphics()
		if( This.AutoShow )
			This.ShowWindow( This.Title )
	}
	_SetDefaults(){
		This.X := 10
		This.Y := 10
		This.W := 10
		This.H := 10
		This.Smoothing := 2
		This.Options := " -DPIScale +AlwaysOnTop "
		This.AutoShow := 0
		This.GdipStartUp := 0
		This.Title := ""
		
		This.Controls := []
		This.Handles := []
		This.Index := 0 
	}
	AddTrigger( obj ){
		local k , v , cc , bd
		
		This.Controls[ ++This.Index ] := { 	X:		10
										,	Y:		10
										,	W:		10
										,	H:		10	}
		for k, v in obj
			This.Controls[ This.Index ][ k ] := obj[ k ] 
		cc := This.Controls[ This.Index ]
		Gui, % This.Hwnd ":Add", Text, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd"
		This.Handles[ hwnd ] := This.Index
		This.Controls[ This.Index ].Hwnd := hwnd
		
		if( IsObject( cc.Label ) ){
			bd := cc.Label
			GuiControl, % This.Hwnd ":+G" , % hwnd , % bd
		}else{
			bd := This._TriggerCall.Bind( This )
			GuiControl, % This.Hwnd ":+G" , % hwnd , % bd
		}
		return hwnd
		
	}
	_TriggerCall(){
		MouseGetPos,,,, ctrl, 2
		Try
			;~ SetTimer, % This.Controls[ This.Handles[ ctrl ] ].Label, -0
			gosub, % This.Controls[ This.Handles[ ctrl ] ].Label
		
				
	}
	DrawTriggers( color := "0xFFFF0000" , AutoUpdate := 0 ){
		local brush , cc 
		Brush := Gdip_BrushCreateSolid( color ) 
		Gdip_SetSmoothingMode( This.G , 3 )
		loop, % This.Controls.Length()	{
			cc := This.Controls[ A_Index ]
			Gdip_FillRectangle( This.G , Brush , cc.x , cc.y , cc.w , cc.h )
		
		}
		Gdip_DeleteBrush( Brush )
		Gdip_SetSmoothingMode( This.G , This.Smoothing )
		if( AutoUpdate )
			This.UpdateWindow()
	}
	UpdateSettings( obj := "" , UpdateGraphics := 0 ){
		local k , v
		if( IsObject( obj ) )
			for k, v in obj
				This[ k ] := obj[ k ]
		( This.X = "Center" ) ? ( This.X := ( A_ScreenWidth - This.W ) / 2 ) 	
		( This.Y = "Center" ) ? ( This.Y := ( A_ScreenHeight - This.H ) / 2 ) 	
		if( UpdateGraphics ){
			This._DestroyWindowsGraphics()
			This._CreateWindowGraphics()
		}
	}
	_CreateWindow(){
		local hwnd
		Gui , New, % " +LastFound +E0x80000 hwndhwnd -Caption  " This.Options
		PopUpWindow.Index++
		This.Index := PopUpWindow.Index
		PopUpWindow.Windows[ PopUpWindow.Index ] := This
		This.Hwnd := hwnd
		PopUpWindow.Handles[ hwnd ] := PopUpWindow.Index
		if( This.GdipStartUp && !PopUpWindow.pToken )
			PopUpWindow.pToken := GDIP_STARTUP()
	}
	_DestroyWindowsGraphics(){
		Gdip_DeleteGraphics( This.G )
		SelectObject( This.hdc , This.obm )
		DeleteObject( This.hbm )
		DeleteDC( This.hdc )
	}
	_CreateWindowGraphics(){
		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.Smoothing )
	}
	ShowWindow( Title := "" ){
		Gui , % This.Hwnd ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H " NA", % Title
	}
	HideWindow(){
		Gui , % This.Hwnd ":Hide",
	}
	UpdateWindow( alpha := 255 ){
		UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H , alpha )
	}
	ClearWindow( AutoUpdate := 0 ){
		Gdip_GraphicsClear( This.G )
		if( Autoupdate )
			This.UpdateWindow()
	}
	DrawBitmap( pBitmap , obj , dispose := 1 , AutoUpdate := 0 ){
		Gdip_DrawImage( This.G , pBitmap , obj.X , obj.Y , obj.W , obj.H )
		if( dispose )
			Gdip_DisposeImage( pBitmap )
		if( Autoupdate )
			This.UpdateWindow()
	}
	PaintBackground( color := "0xFF000000" , AutoUpdate := 0 ){
		if( isObject( color ) ){
			Brush := Gdip_BrushCreateSolid( ( color.HasKey( "Color" ) ) ? ( color.Color ) : ( "0xFF000000" ) ) 
			if( color.Haskey( "Round" ) )
				Gdip_FillRoundedRectangle( This.G , Brush , color.X , color.Y , color.W , color.H , color.Round )
			else
				Gdip_FillRectangle( This.G , Brush , color.X , color.Y , color.W , color.H ) 
		}else{
			Brush := Gdip_BrushCreateSolid( color ) 
			Gdip_FillRectangle( This.G , Brush , -1 , -1 , This.W + 2 , This.H + 2 ) 
		}
		Gdip_DeleteBrush( Brush )
		if( AutoUpdate )
			This.UpdateWindow()
	}
	DeleteWindow( GDIPShutdown := 0 ){
		Gui, % This.Hwnd ":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 ] := ""
		if( GDIPShutdown ){
			Gdip_Shutdown( PopUpWindow.pToken )
			PopUpWindow.pToken := ""
		}
	}
	_OnClose( wParam ){
		if( wParam = 0xF060 ){	;SC_CLOSE ;[ clicking on the gui close button ]
			Try{
				Gui, % PopUpWindow.HelperHwnd ":Destroy"
				SoundBeep, 555
			}
		}
	}
	CreateCachedBitmap( pBitmap , Dispose := 0 ){
		local pCachedBitmap
		if( This.CachedBitmap )
			This.DisposeCachedbitmap()
		DllCall( "gdiplus\GdipCreateCachedBitmap" , "Ptr" , pBitmap , "Ptr" , this.G , "PtrP" , pCachedBitmap )
		This.CachedBitmap := pCachedBitmap
		if( Dispose )
			Gdip_DisposeImage( pBitmap )
	}
	DrawCachedBitmap( AutoUpdate := 0 ){
		DllCall( "gdiplus\GdipDrawCachedBitmap" , "Ptr" , this.G , "Ptr" , This.CachedBitmap , "Int" , 0 , "Int" , 0 )
		if( AutoUpdate )
			This.UpdateWindow()
	}
	DisposeCachedbitmap(){
		DllCall( "gdiplus\GdipDeleteCachedBitmap" , "Ptr" , This.CachedBitmap )
	}
	Helper(){
		local hwnd , MethodList := ["__New","UpdateSettings","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow" , "AddTrigger" , "DrawTriggers", "CreateCachedBitmap" , "DrawCachedBitmap" , "DisposeCachedbitmap" ]
		Gui, New, +AlwaysOnTop +ToolWindow +HwndHwnd
		PopUpWindow.HelperHwnd := hwnd
		Gui, Add, Edit, xm ym w250 r1 Center hwndhwnd, Gui1
		PopUpWindow.EditHwnd := hwnd
		loop, % MethodList.Length()	
			Gui, Add, Button, xm y+1 w250 r1 gPopUpWindow._HelperClip, % MethodList[ A_Index ]
		Gui, Show,,
		OnMessage( 0x112 , This._OnClose.Bind( hwnd ) )
	}
	_HelperClip(){
		local ClipList 
		
		GuiControlGet, out, % PopUpWindow.HelperHwnd ":", % PopUpWindow.EditHwnd	
		
		ClipList := 		{ 	__New: 					" := New PopUpWindow( { AutoShow: 1 , X: 0 , Y: 0 , W: A_ScreenWidth , H: A_ScreenHeight , Options: "" -DPIScale +AlwaysOnTop "" } )"
							,	UpdateSettings:			".UpdateSettings( { X: """" , Y: """" , W: """" , H: """" } , UpdateGraphics := 0 )"
							,	ShowWindow:				".ShowWindow( Title := """" )"
							,	HideWindow:				".HideWindow()"
							,	UpdateWindow:			".UpdateWindow()"
							,	ClearWindow:			".ClearWindow( AutoUpdate := 0 )"
							,	DrawBitmap:				".DrawBitmap( pBitmap := """" , { X: 0 , Y: 0 , W: " Out ".W , H: " Out ".H } , dispose := 1 , AutoUpdate := 0 )"
							,	PaintBackground:		".PaintBackground( color := ""0xFF000000"" , AutoUpdate := 0 )  "  ";{ Color: ""0xFF000000"" , X: 2 , Y: 2 , W: " Out ".W - 4 , H: " Out ".H - 4 , Round: 10 }"
							,	DeleteWindow:			".DeleteWindow( GDIPShutdown := 0 )"
							,	AddTrigger:				".AddTrigger( { X: """" , Y: """" , W: """" , H: """" , Value: """" , Label: """" } )"	
							,	DrawTriggers:			".DrawTriggers( color := ""0xFFFF0000"" , AutoUpdate := 0 )"	
							,	CreateCachedBitmap:		".CreateCachedBitmap( pBitmap , Dispose := 0 )"	
							,	DrawCachedBitmap: 		".DrawCachedBitmap( AutoUpdate := 0 )"	
							,	DisposeCachedbitmap:	".DisposeCachedbitmap()"	}
							
		clipboard := Out ClipList[ A_GuiControl ]
		
	}
}

;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;

FillPolygon( G , Points := "50 , 50 | 100 , 100 | 150 , 50 | 50 , 50 " , Color := "0xFFFF0000" ){
	Brush := Gdip_BrushCreateSolid( Color ) , Gdip_FillPolygon( G , Brush , Points ) , Gdip_DeleteBrush( Brush )
}

DrawPolygon( G , Points := "50 , 50 | 100 , 100 | 150 , 50 | 50 , 50 " , Color := "0xFF000000" , Thickness := 3 ){
	Pen := Gdip_CreatePen( Color , Thickness ) , Gdip_DrawLines( G , Pen , Points ) , Gdip_DeletePen( Pen )
}

;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;










s_tarnow
Posts: 2
Joined: 21 Sep 2022, 20:55

Re: Cursor Highlighter

Post by s_tarnow » 25 Oct 2022, 18:03

lblb wrote:
22 Sep 2022, 01:25
@s_tarnow

Have you changed anything on your computer since June? Are you using a new version of Windows?

It doesn't seem to be possible to use Cursor Highlighter (or any other similar program that I have tried) with a pen in so-called "UWP" apps such as the "OneNote for Windows" app. But strangely, it should work if you use a mouse in these programs. But Cursor Highlighter should work with the pen in normal desktop programs such as the regular OneNote program.

Are you using different programs from what you were using in June?
I'm using the exact same programs that I was using in June. I'm using Windows 10, though there have probably been a few updates that occurred over the summer.

Examples of programs that don't work anymore (but used to work before July): Regular desktop OneNote, OneNote for Windows 10, Microsoft Word/Excel/etc., built in camera/calculator/etc. apps, Chrome, Edge, YouTube Music Desktop App.

Examples of programs that do work: VLC media player, Zoom, ExamView Test Generator, LXR Test, Team Manager 8.0 Lite, Data Link Connect, Bulk Rename Utility

MedBooster
Posts: 54
Joined: 24 Nov 2022, 12:33

Re: Cursor Highlighter

Post by MedBooster » 06 Dec 2022, 17:10

To me it seems that changing the settings in the settings menu does not actually change them in the .ini file

Meaning that once I restart my PC all the settings are lost and everything "reverts" to the default
Not sure how the settings are even changed while the app is open without the .ini file changing, maybe some temporary settings in the .ahk file

reyn
Posts: 57
Joined: 21 Jul 2021, 18:08

Re: Cursor Highlighter

Post by reyn » 08 Feb 2023, 10:25

Thank you for providing wonderful tool for adding picture over mouse cursor - adding highlight was not that difficult to find, but picture over = quite a task.
While roaming through settings found a bug: if you select General > Picture file and in Picture Settings > check Hide Picture(for left/right clicks) = when you click, picture gets hidden, but then blue pen appears. Doesn't matter if you picked own picture or just different colour pen = after click-hide picture is always turned back to blue pen.

wysocki
Posts: 3
Joined: 13 Apr 2022, 15:56

Re: Cursor Highlighter

Post by wysocki » 17 Mar 2023, 13:12

I've been running Cursor Highlighter for a long time and love it. But lately, when I restart my Win10 computer, I get an error popup and it doesn't run. Could it be a v1/v2 issue? HELP!!!
AHK startup crash.jpg
AHK startup crash.jpg (88.28 KiB) Viewed 1395 times

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Cursor Highlighter

Post by swagfag » 17 Mar 2023, 15:17

its a v2/Dash's/Launcher's issue. the syntax-guesser regex chokes up on these hugeass embedded base64-encoded icons, most likely.
add #Requires AutoHotkey v1.1 to ur cursorhighlighter.ahk somewhere at the top

wysocki
Posts: 3
Joined: 13 Apr 2022, 15:56

Re: Cursor Highlighter

Post by wysocki » 17 Mar 2023, 16:08

Thanks for the quick reply. But adding that line gives me an error: "This line does not contain a recognized action."

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Cursor Highlighter

Post by swagfag » 17 Mar 2023, 16:44

then either update ur installed ahkv1 version or configure v2's Dash/Launcher to not try and parse scripts to guess their version(theres a checkbox for that, i forget the exact name)

xan2622
Posts: 3
Joined: 02 Jan 2020, 16:06

Re: Cursor Highlighter

Post by xan2622 » 15 Aug 2023, 04:34

Thank you @lblb for creating this script. This is exactly what I have recently been searching for.

I have noticed two things:
- It seems that it's not possible to set the opacity to 0 (to completely hide the circle), that being in Highlight settings, Highlight: left-click and Highlight: right-click.
- The circle correctly appears when I simply right-click on my desktop, but if I add a modifier key (left ALT for example) to that right click, the circle doesn't appear.

fmnijk
Posts: 2
Joined: 19 Oct 2023, 09:40

Re: Cursor Highlighter

Post by fmnijk » 10 Apr 2024, 05:09

Thanks for the script.
I use Loop statement to implement a turbo mode. By sacrifice 1 CPU thread I can get a little bit smoother highlight. I make the icon purple for turbo icon.

Code: Select all

CheckMouseMovement:
    Loop
    {
        MouseGetPos,CurrentX,CurrentY
        If General_Cursor_Type = 1
            Gui, PresCursor: Show, % "x" CurrentX-General_Cursor_Width/2 "y" CurrentY-General_Cursor_Height/2 " w" General_Cursor_Width " h" General_Cursor_Height " NoActivate"
        If General_Cursor_Type = 2
            Gui, PresCursor: Show, % "x" CurrentX-General_Picture_Width/2+General_Picture_XOffset "y" CurrentY-General_Picture_Height/2+General_Picture_YOffset " w" General_Picture_Width " h" General_Picture_Height "NoActivate"
        Winset, AlwaysOnTop, ON, ahk_id %hGui_Cursor%
        If Turbo = 0
            Break
        If Show_Cursor = 0
            Break
    }
Return

Switch_Toggle:
Start_Stop:
    If (Turbo = 0 AND Show_Cursor = 1)
    {
        Menu, Tray, Icon, %Tray_Icon_Turbo%
        Turbo = 1 ;To prevent toggle function stuck, start loop after setting tray icon.
        Return
    }
    Else
    {
        Turbo = 0
    }
    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
        }
    }
    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

Post Reply

Return to “Scripts and Functions (v1)”