like Logitech spotlight

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Gurkentoepfer
Posts: 49
Joined: 24 Feb 2014, 14:52

like Logitech spotlight

17 Nov 2017, 08:52

I would like to have a semi-transparent window where a hole appears at the current mouse position.
The mouse function should be still work (clickable buttons of windows which can bee seen throught the "hole").

https://www.youtube.com/watch?v=ojcoSzjiG3o

I've started with a code like that ... (but it it's not a spotlight its a dark spot).
Any idea to improve?

Code: Select all

SetTitleMatchMode, 2
#Persistent
#SingleInstance Force
if !(A_iscompiled)
	Hotkey, ESC, Beenden

Spot:=0

#o::
	if (Spot=0)
	{
		Gui, dark: Color, black, black
		Gui, dark: +ToolWindow +Lastfound -Caption
		WinSet, Region, 0-0 W%A_ScreenWidth% H%A_ScreenHeight%
		WinSet, Transparent, 150
		Gui, dark: Show, W%A_ScreenWidth% H%A_ScreenHeight%, darkwin
		WinMaximize, A
		WinGetPos, WinPosX, WinPosY, WinWidth, WinHeight		
		SetTimer, Spotlight, 10
		Spot:=1
	}
	else
	{
		SetTimer, Spotlight, off
		Gui, dark: Destroy
		Spot:=0
	}
	
return

Spotlight:
	Diameter := 200
	MouseGetPos, xPos, yPos
	xPos -= Diameter/2
	yPos -= Diameter/2	
	WinSet, Region, %xPos%-%yPos% w%Diameter% h%Diameter% E, darkwin	
return

Beenden:
	ExitApp
return
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: like Logitech spotlight

17 Nov 2017, 09:05

I found this which I think does what you want, but it isn't a good circle.

Maybe you can alter it's region to be more circular, like your dark one?
https://autohotkey.com/board/topic/3303 ... et-region/
User avatar
Gurkentoepfer
Posts: 49
Joined: 24 Feb 2014, 14:52

Re: like Logitech spotlight

17 Nov 2017, 14:30

Thank you.
Based on your hint ... a shape which looks more like a circle ...

Code: Select all

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       WinXP
; Author:         LiquidGravity <[email protected]>
;
; Script Function:
;	Mouse Spotlight Example Using WinSet Region
;
#SingleInstance force
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

Hotkey, ESC, Beenden

Gui, Margin , 0, 0
Gui, -Caption +AlwaysOnTop
Gui, Color, 000000
Gui, Show, Maximize, Mouse Spotlight
WinSet, Transparent, 180, Mouse Spotlight
WinSet, Region, 0-85 0-%A_ScreenHeight% %A_ScreenWidth%-%A_ScreenHeight% %A_ScreenWidth%-0 0-0 0-85, Mouse Spotlight
SetTimer, Alert2, 50
Return


Alert2:
    Radius := 200
    CoordMode,Mouse, Screen
    MouseGetPos, X3, Y3, OutputVarWin, OutputVarControl
    region:=""
    loop, 37
    {
        x := x3 + Round(Radius*sin(ATan(1)*A_index*2/9),0)
        y := y3 + Round(Radius*cos(ATan(1)*A_index*2/9),0)
        Region .= " " . x . "-" . y
    }    
    WinSet, Region, 0-85 0-%A_ScreenHeight% %A_ScreenWidth%-%A_ScreenHeight% %A_ScreenWidth%-0 0-0 0-85 %Region%, Mouse Spotlight
Return


GuiClose:
2GuiClose:
Beenden:
ExitApp


iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: like Logitech spotlight

17 Nov 2017, 21:02

I simplified/optimized the code a little in the version below:

Code: Select all

#NoEnv

Transparency := 150

Radius := 200
Vertices := 40
Angle := 8*ATan(1)/Vertices

Gui, -Caption +Hwndhwnd
Gui, Color, Black
Gui, Show, Maximize
WinSet, Transparent, %Transparency%, ahk_id %hwnd%
SetTimer, DrawHole, 10
Return

DrawHole:
   MouseGetPos, X, Y
   Loop, %Vertices%
      Hole .= Floor(X + Radius * Cos(A_Index * Angle)) "-" Floor(Y + Radius * Sin(A_Index * Angle)) " "
   Hole .= Floor(X + Radius * Cos(Angle)) "-" Floor(Y + Radius * Sin(Angle))
   WinSet, Region, 0-0 0-%A_ScreenHeight% %A_ScreenWidth%-%A_ScreenHeight% %A_ScreenWidth%-0 0-0 %Hole%, ahk_id %hwnd%
   Hole =
Return

^=::Radius += 10
^-::Radius -= 10
^0::Radius := 200

!=::
Transparency -= 10
WinSet, Transparent, %Transparency%, ahk_id %hwnd%
Return
!-::
Transparency += 10
WinSet, Transparent, %Transparency%, ahk_id %hwnd%
Return
!0::
Transparency := 150
WinSet, Transparent, %Transparency%, ahk_id %hwnd%
Return

Esc::ExitApp
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: like Logitech spotlight

18 Nov 2017, 08:41

Really cool! If changed it to support multiple monitors and added some hotkeys (F1 in config part) to enable/disable the spotlight and using that hotkey in combination with the arrow keys to change the spotlight size and contrast.

Code: Select all

#NoEnv
#SingleInstance,Force

Hotkey=F1
Radius := 200
Vertices := 40
Angle := 8*ATan(1)/Vertices
TransparencyTarget:=150
FadeAmount:=10
SysGet, XVirtualScreen, 76
SysGet, YVirtualScreen, 77
SysGet, CXVirtualScreen, 78
SysGet, CYVirtualScreen, 79
CoordMode,Mouse, Screen
Transparency:=0


Fade:
   If (Transparency=0){
      Gui, -Caption +Hwndhwnd +AlwaysOnTop +ToolWindow
      Gui, Color, Black
      Gui, Show, x%XVirtualScreen% y%YVirtualScreen% w%CXVirtualScreen% h%CYVirtualScreen% NA,
      WinSet, Transparent, 0, ahk_id %hwnd%
      Hotkey,%Hotkey%,Hotkey
      Hotkey,%Hotkey% & Up,HotkeyUp,On
      Hotkey,%Hotkey% & Down,HotkeyDown,On
      Hotkey,%Hotkey% & Left,HotkeyLeft,On
      Hotkey,%Hotkey% & Right,HotkeyRight,On
      SetTimer, DrawHole, 10, On
      SetTimer, Fade, 10, On
   }
   
   Transparency+=FadeAmount
   
   If (Transparency<=0){
      Transparency:=0
      SetTimer,Fade,Off
      SetTimer,DrawHole,Off
      Hotkey,%Hotkey% & Up,Off
      Hotkey,%Hotkey% & Down,Off
      Hotkey,%Hotkey% & Left,Off
      Hotkey,%Hotkey% & Right,Off
      Gui,Destroy
   }Else If (Transparency>=TransparencyTarget){
      Transparency:=TransparencyTarget
      SetTimer,Fade,Off
   }
   
   WinSet, Transparent, %Transparency%, ahk_id %hwnd%
Return

DrawHole:
   MouseGetPos, X, Y
   X-=XVirtualScreen
   Y-=YVirtualScreen
   Loop, %Vertices%
      Hole .= Floor(X + Radius * Cos(A_Index * Angle)) "-" Floor(Y + Radius * Sin(A_Index * Angle)) " "
   Hole .= Floor(X + Radius * Cos(Angle)) "-" Floor(Y + Radius * Sin(Angle))
   WinSet, Region, %XVirtualScreen%-%YVirtualScreen% %XVirtualScreen%-%CXVirtualScreen% %CXVirtualScreen%-%CYVirtualScreen% %CXVirtualScreen%-%YVirtualScreen% %XVirtualScreen%-%YVirtualScreen% %Hole%, ahk_id %hwnd%
   Hole =
Return



Hotkey:
   FadeAmount*=-1
   SetTimer,Fade,10
Return

HotkeyUp:
HotkeyDown:
   Direction:=InStr(A_ThisLabel,"Up") ? 1 : -1
   TransparencyTarget+=10*Direction
   If (TransparencyTarget<20)
      TransparencyTarget:=20
   Else If (TransparencyTarget>255)
      TransparencyTarget:=255
   Transparency:=TransparencyTarget
   ;FadeAmount:=TransparencyTarget//10
   WinSet, Transparent, %Transparency%, ahk_id %hwnd%
Return
HotkeyLeft:
HotkeyRight:
   Direction:=InStr(A_ThisLabel,"Right") ? 1 : -1
   Radius+=20*Direction
   If (Radius < 20)
      Radius:=20
Return

Esc::ExitApp
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: like Logitech spotlight

18 Nov 2017, 13:51

Great job Nextron! I appreciate you making this even cooler. :thumbup:
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: like Logitech spotlight

06 Feb 2022, 10:59

This is a fantastic tool! I want to be able to zoom in and out with the scroll wheel in increments of 25%. I also think that a toggle for this tool would be great.
User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: like Logitech spotlight

06 Feb 2022, 11:07

LAPIII wrote: I also think that a toggle for this tool would be great.
There is a toggle if you use Nextron's version. Press F1 to toggle. Hold F1 and use arrow keys to resize and change contrast.
amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: like Logitech spotlight

06 Feb 2022, 11:37

Cursor Highlighter
Spoiler
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, jameswrightesq and 274 guests