Hi,
Im teacher, creating educational videos to teach my students how to work properly in different software. And one problem students has is that they don't know when I clicked my mouse. And if I clicked left, right or middle mouse button. I am trying to learn AutoHotkey for creating image that will follow my cursor and change If I click on my mouse. So they will know when and what i clicked. But I'm failing totally to create this script.
Hi Matt, I'm at work right now but I love creating graphical scripts and will definitely help you by the end of the night if no one else has yet. Are you sure you want the image to follow your cursor? It might obscure the view (unless it fades in and out per click, possible to do).
Off Topic wrote:Are you sure you want the image to follow your cursor? It might obscure the view (unless it fades in and out per click, possible to do).
There are video capture tools that have a semi-transparent yellow spot under the cursor at all times so it's easy to follow. Because it's semi-transparent, it doesn't really obscure what's underneath. You might want to do something like that.
Re: Image Following mouse
Posted: 05 Feb 2018, 15:37
by A_AhkUser
This also can be done using a combination of geometric shapes sufficiently significant:
I've been wanting to try something like this, my DPI scaling (144) is throwing things off somewhere though:
More pictures in here
Spoiler
There are inherent graphical problems because I use transparency for the fading foreground, it has a camouflaged background that can show through:
You can also change your cursor to a sword:
On the more practical side, you can do arrows too:
You can scroll through them really nicely but my screen recording software (Icecream.me) doesn't register that at all so you'll have to run the script yourself, ^#WheelUp or down if the hotkey at the end (F24 for me) is pressed.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
; Create an invisible GUI that the picture is placed on:
Gui, -Caption +AlwaysOnTop +ToolWindow ;----
Gui, Margin , 0, 0 ; | Main Gui settings
Gui, Color, 2B2B2C ;----
;
Gui +LastFound ; ----
WinSet, TransColor, 2B2B2C ; ---| Make this color (and the GUI, for being this color) transparent
Gui, Add, Picture, x0 y0 vBG, annoM2.png ;---- Add a picture control
Gui, Show, Hide Center ;---- Build/Show the Gui, center it on screen but hide it
SetTimer, mouseTrack, 20 ; ---- Set a Timer to run itself every 20 miliseconds
Return ; End Auto-Execute
; The timer being called above
mouseTrack:
CoordMode, Mouse, Screen ;----
global vCurX, vCurY, hWnd, vCtlClassNN ; | Track the mouse position
MouseGetPos, vCurX, vCurY, hWnd, vCtlClassNN ;----
Return
~*RButton::
mouseX := vCurX-60, mouseY := vCurY-80 ;---- Offset from initial mouse position, origin is top left corner of picture
Gui, Show, x%mouseX% y%mouseY% ;---- Show the gui (unhide) at the newly offset position
Return
~*RButton Up::
Gui, Show, Hide ;----- Hide the gui when the button goes up
Return
The full code is below, you'll also need this .zip for the pictures:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Menu, Tray, Icon, vCursor.ico
#SingleInstance Force
global xOffset := 40
global yOffset := 60
global TotalTime := 500
global CurrentCursor = N
global CursorCount = 1
global TypeCount = 1
global KeyCount := ""
global ImageArray := [{anno:["L", "M", "R"], mouse:["L", "M", "R"], button:["L", "M", "R"]}]
global arrowArray := ["N", "E", "S", "W"]
; Create an invisible GUI that the picture is placed on:
Gui, -Caption +AlwaysOnTop +ToolWindow ;----
Gui -DPIScale ; |
Gui, Margin , 0, 0 ; | Main Gui settings
Gui, Color, 2B2B2C ;----
;
Gui +LastFound ; ----
WinSet, TransColor, 2B2B2C ; ---- Make this color (and the GUI, for being this color) transparent
Gui, Add, Picture, x0 y0 vBG, annoM.png ; Add a picture control
Gui, Show, Hide Center ; Build/Show the Gui, center it on screen but hide it
SetTimer, mouseTrack, 20 ; ---- Set a Timer to run itself every 20 miliseconds
Return ; End Auto-Execute
mouseTrack:
CoordMode, Mouse, Screen ;----
global vCurX, vCurY, hWnd, vCtlClassNN ; | Track the mouse position
MouseGetPos, vCurX, vCurY, hWnd, vCtlClassNN ;----
CoordMode, Pixel, Screen ;----
PixelGetColor, Camouflage, %vCurX%, %vCurY%, RGB ;---- Record the color of the pixel under mouse
Return
WhichKey(){
If (A_ThisHotkey = "~*RButton")
KeyCount = 3
If (A_ThisHotkey = "~*MButton")
KeyCount = 2
If (A_ThisHotkey = "~*LButton")
KeyCount = 1
vOutput := ""
for vKey, vValue in ImageArray {
for vKey2, vValue2 in vValue {
If (A_Index > TypeCount)
Break
for vKey3, vValue3 in vValue2{
If (A_Index > KeyCount)
Break
vOutput := vKey2 vValue3
}
}
GuiControl, , BG, % vOutput ".png"
}
Return
}
#If GetKeyState("CapsLock","T") ; If CapsLock is on
~*LButton::
~*MButton::
~*RButton::
WinGet, active_id, ID, A
Gui, Color, %Camouflage%
mouseX := vCurX-xOffset
mouseY := vCurY-yOffset
WinSet, Transparent, 255, ahk_class AutoHotkeyGUI
WhichKey()
Gui, Show, NoActivate x%mouseX% y%mouseY%
Return
~*LButton Up::
~*MButton Up::
~*RButton Up::
FadeOut()
WinSet, TransColor, 2B2B2C
Return
^#MButton::
++TypeCount
If (TypeCount > 3)
TypeCount = 1
Return
#If ; No longer affected by CapsLock
; @tic
; //autohotkey.com/board/topic/56327-simple-fade-in-out/?p=355931
FadeOut(){
Time1 := A_TickCount
Loop
{
Trans := Round(((A_TickCount-Time1)/TotalTime)*255)
Inv := ((Trans * (-1)) + 255)
WinSet, Transparent, %Inv%, ahk_class AutoHotkeyGUI
If (Trans >= 255)
break
Sleep, 10
}
; MsgBox % Trans
Gui, Show, Hide
Return
}
^#WheelUp::
If (A_PriorHotkey != A_ThisHotkey or A_TimeSincePriorHotkey > 60) {
++CursorCount
If (CursorCount > arrowArray.Length())
{
CursorCount := arrowArray.MinIndex()
}
arrowCheck()
}
Return
^#WheelDown::
If (A_PriorHotkey != A_ThisHotkey or A_TimeSincePriorHotkey > 60) {
--CursorCount
If (CursorCount < arrowArray.MinIndex())
{
CursorCount := arrowArray.Length()
}
arrowCheck()
}
Return
arrowCheck(){
If (CursorCount = 1)
SetSystemCursor(A_ScriptDir "\arrowN.cur")
If (CursorCount = 2)
SetSystemCursor(A_ScriptDir "\arrowE.cur")
If (CursorCount = 3)
SetSystemCursor(A_ScriptDir "\arrowS.cur")
If (CursorCount = 4)
SetSystemCursor(A_ScriptDir "\arrowW.cur")
Return
}
CapsLock::
; Uncomment these to see a tooltip during CapsLock
If !GetKeyState("CapsLock","T") {
SetCapsLockState, On
; SetTimer, TooltipDebug, 20
} Else {
SetCapsLockState, Off
; SetTimer, TooltipDebug, Off
; Tooltip
}
Return
TooltipDebug:
; Place any variables in here to show a Tooltip and see their current values, infinitely useful for seeing results and testing.
ToolTip % CursorCount "`r`n" CurrentCursor
Return
; @anon
;//autohotkey.com/board/topic/81438-is-there-an-easy-way-to-hide-cursor/?p=517640
; @Serenity
;https://autohotkey.com/board/topic/32608-changing-the-system-cursor/
F24::(k := !k)? SetSystemCursor(A_ScriptDir "\Sword.cur"):RestoreSystemCursor()
SetSystemCursor(Cursor) {
toggle = 1
return DllCall("SetSystemCursor", "UInt", DllCall("LoadCursorFromFile", "Str", Cursor), "Int", "32512")
}
RestoreSystemCursor() {
toggle = 0
return DllCall("SystemParametersInfo", "UInt", 0x57, "UInt", 0, "UInt", 0, "UInt", 0)
}
RestoreAndExit:
RestoreSystemCursor()
ExitApp
OnExit, RestoreAndExit
Exit:
^Esc::
ExitApp
I have it set to only activate if CapsLock is on, and use LWin a lot in this. I was going to put menu types on a context menu instead and a few other things but I have to turn in for the night.
A_AhkUser wrote:This also can be done using a combination of geometric shapes sufficiently significant:
This is pretty clever and I hadn't thought of using unicode for shapes like that. Thanks!
boiler wrote:
Off Topic wrote:Are you sure you want the image to follow your cursor? It might obscure the view (unless it fades in and out per click, possible to do).
There are video capture tools that have a semi-transparent yellow spot under the cursor at all times so it's easy to follow. Because it's semi-transparent, it doesn't really obscure what's underneath. You might want to do something like that.
The one I use has that, I was going to try something like it with the labeled yellow buttons but decided against spending too much time on it. Next time I can. I'd be able to do much better things if I knew a reliable way to animate png sequences or gifs (only once, forward or backward) but I'm not sure how. I'd like to add accents like this:
Spoiler
Re: Image Following mouse
Posted: 06 Feb 2018, 07:27
by ezekiel
Jesus... this forum is totally awesome! Thank you all very very much! You all helped me in a big way. I'll try all of your ideas and see what works best in the videos for students, but I have to thank all of you. I did not expect so much help.
Thx!!
Re: Image Following mouse
Posted: 30 Mar 2020, 17:31
by shadowwynd
Just wanted to say thanks - we are doing teletherapy with some kids and the school's remote therapy platform takes out the mouse cursor (with no options to leave it alone) - and the kids on the other end are lost without seeing what we are doing. ... However, the code that shows a circle under the mouse works just fine!
Of course I'm not emailing you. If you are serious about writing a program for me even though I posted nothing here indicating any particular need for a program, you can post the script here. If it's not an AHK script, then don't bother.
Re: Image Following mouse
Posted: 08 Nov 2020, 12:22
by mikeyww
Looks like a spammer.
Re: Image Following mouse
Posted: 08 Nov 2020, 12:28
by boiler
Yeah, one would think no one would actually send an email in response to posts like this, but I suppose it must work sometimes.
Yeah, one would think no one would actually send an email in response to posts like this, but I suppose it must work sometimes.
The circle shape will follow the mouse, this will be fast and this circle will be txt linked, it will read the txt file continuously and accordingly the diameter of the circle will change according to the txt information. Can we talk about this privately. can you send mail I am not spam.
The circle shape will follow the mouse, this will be fast and this circle will be txt linked, it will read the txt file continuously and accordingly the diameter of the circle will change according to the txt information. Can we talk about this privately. can you send mail I am not spam.
I’m not interested in such a program. I haven’t expressed a need for it. There is no reason why this would need to be directed privately to me and not in general to the forum. I am not interested in talking privately. Please stop trolling the forum.
The circle shape will follow the mouse, this will be fast and this circle will be txt linked, it will read the txt file continuously and accordingly the diameter of the circle will change according to the txt information. Can we talk about this privately. can you send mail I am not spam.
I’m not interested in such a program. I haven’t expressed a need for it. There is no reason why this would need to be directed privately to me and not in general to the forum. I am not interested in talking privately. Please stop trolling the forum.