Highlighter tool

Post your working scripts, libraries and tools for AHK v1.1 and older
WatchingTheWheels
Posts: 3
Joined: 23 Feb 2021, 23:01

Highlighter tool

Post by WatchingTheWheels » 23 Feb 2021, 23:10

Hi,

I am new to this board but I made a script I would like to share. It's an onscreen highlighter with 6 color options and variable transparency, using F1 to F6 plus mouse click.
Obviously, it is impossible to add highlights to an actual file, so this is not about highlighting a document for reading later, but rather, highlighting "on the fly" while you are reading a difficult section of text.
It's ideal for students, proofreaders, translators - anyone who reads difficult texts frequently. It's also nice stress relief just to make patterns on your screen :D

Hold down an F key (F1 to F6) then click once for the start point of the highlight, move the mouse then click a second time for the end point. You can go left to right or right to left.
Escape clears the highlights

Would welcome any comments,

Code: Select all

#NoEnv
#SingleInstance, force ; edited - thank you DataLife
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Screen

global t := true
global startxpos
global startypos


F1 & Lbutton::
drawhighlight("fff100", 75) ;yellow
return

F2 & Lbutton::
drawhighlight("ff8c00", 75) ;orange
return

F3 & Lbutton::
drawhighlight("e81123", 75) ;pink
return

F4 & Lbutton::
drawhighlight("00bcf2", 75) ;cyan
return

F5 & Lbutton::
drawhighlight("68217a", 75) ;purple
return

F6 & Lbutton::
drawhighlight("009e49", 75) ;green
return




drawhighlight(color, trans){
if t{
	MouseGetPos, startxpos, startypos
	boxy:=startypos-10
	Gui, New
	Gui, +LastFound +AlwaysOnTop +Owner
	WinSet, Transparent, %trans%
	Gui, +LastFound -Caption
	Gui, Color, %color%
	Gui, Show, W10 H20 X%startxpos% Y%boxy%
	t := !t
}
else{
	MouseGetPos, endxpos, endypos
	boxy:=startypos-10
		if (endxpos > startxpos){
			boxx:=startxpos+10
			boxw:=(boxw:=endxpos-startxpos-10)
		}
		if (endxpos < startxpos){
			boxx:=endxpos
			boxw:=(startxpos-endxpos)
		}
		if (endxpos = startxpos){
			boxx:=startxpos+10
			boxw:=10
		}
	Gui, New
	Gui, +LastFound +AlwaysOnTop +Owner
	WinSet, Transparent, %trans% ;Set the transparency
	Gui, +LastFound -Caption
	Gui, Color, %color%
	Gui, Show, W%boxw% H20 X%boxx% Y%boxy%
	t := !t
	}
return
}

~Esc::reload
Last edited by WatchingTheWheels on 24 Feb 2021, 13:52, edited 3 times in total.
User avatar
rommmcek
Posts: 1475
Joined: 15 Aug 2014, 15:18

Re: Highlighter tool

Post by rommmcek » 24 Feb 2021, 04:04

Maybe you could look at this thread to possibly get some new ideas.
WatchingTheWheels
Posts: 3
Joined: 23 Feb 2021, 23:01

Re: Highlighter tool

Post by WatchingTheWheels » 24 Feb 2021, 07:25

Thank you! That's very interesting and gives me a lot of possibilities to think about.
User avatar
DataLife
Posts: 449
Joined: 29 Sep 2013, 19:52

Re: Highlighter tool

Post by DataLife » 24 Feb 2021, 09:28

It took me a little while to figure out how to use this.

I was pressing and holding the F key then click and dragging the L button.
Maybe the opening post should say "F key and click to start then F key and click to stop at the desired position".

Also, I suggest using #SingleInstance, force to avoid...
---------------------------
Screen Text Highlighter.ahk
---------------------------
An older instance of this script is already running. Replace it with this instance?
Note: To avoid this message, see #SingleInstance in the help file.
---------------------------
Yes No
---------------------------
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
kunkel321
Posts: 1061
Joined: 30 Nov 2015, 21:19

Re: Highlighter tool

Post by kunkel321 » 24 Feb 2021, 13:40

Clever -- I like it!
ste(phen|ve) kunkel
WatchingTheWheels
Posts: 3
Joined: 23 Feb 2021, 23:01

Re: Highlighter tool

Post by WatchingTheWheels » 24 Feb 2021, 13:41

Thank you for the feedback, Sorry if my explanation was not clear enough,

Hold down an F key (F1 to F6) then click once for the start point of the highlight, move the mouse then click a second time for the end point. You can go left to right or right to left.
Escape clears the highlights

Thanks to the code that rommmcek shared I will have a go at making a "hold down the mouse button and drag" version now which is great.
Post Reply

Return to “Scripts and Functions (v1)”