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.
Is there anyone that could help me doing this?
Images: https://www.dropbox.com/sh/77xbsn1hvviv ... SVpka?dl=0
Thx,
Matt
Image Following mouse
Re: Image Following mouse
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).
Re: Image Following mouse
Something similar to this: http://www.markuswelz.de/software/features.html (15€)
Re: Image Following mouse
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.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).
Re: Image Following mouse
This also can be done using a combination of geometric shapes sufficiently significant:
Code: Select all
#NoEnv
blackSquare := Chr(9632), whiteSquare := Chr(9633)
LButton := blackSquare . whiteSquare . whiteSquare
MButton := whiteSquare . blackSquare . blackSquare
RButton := whiteSquare . whiteSquare . blackSquare
DetectHiddenWindows, On
WS_EX_CLICKTHROUGH := "E0x20"
Gui, New, +ToolWindow -Caption -Border +AlwaysOnTop +%WS_EX_CLICKTHROUGH% +LastFound +HWNDID
Gui, Font, s14 cwhite, Segoe UI
Gui, Color, red
Gui, Add, Text, hwndCID, % LButton := blackSquare . whiteSquare . whiteSquare
Gui, Show, Hide AutoSize
WinSet, Transparent, 90
DetectHiddenWindows, Off
enabled := true
return
!t::enabled:=not enabled
#If (enabled)
~LButton::
~RButton::
~MButton::
hotkey := LTrim(A_ThisHotkey, "~")
GuiControl,, %CID%, % %hotkey%
MouseGetPos, x, y
Gui, %ID%:Show, NA x%x% y%y%
SetTimer, GUIHide, -2000
return
#If
GUIHide:
Gui, %ID%:Show, Hide
return
Re: Image Following mouse
Not sure why that's not working for me.
Here's a simple one I just made:
Here's a simple one I just made:
Code: Select all
CoordMode, Mouse, Screen
Gui, +AlwaysOnTop -Caption -Border +E0x20
Gui, Color, Yellow
Gui, Show, NoActivate w51 h51, MouseSpot
WinSet, Trans, 100, MouseSpot
WinSet, Region, 0-0 W51 H51 E, MouseSpot
loop
{
MouseGetPos, MX, MY
WinMove, MouseSpot,, MX - 25, MY - 25
}
return
~LButton::
Gui, Color, Lime
KeyWait, LButton
Gui, Color, Yellow
return
~RButton::
Gui, Color, Red
KeyWait, RButton
Gui, Color, Yellow
return
Re: Image Following mouse
I would just use what BoBo posted. Looks pretty good and very configurable.
Re: Image Following mouse
A (German) thread about the requested topic: https://www.cc-community.net/threads/su ... ng.107721/ it contains a few AHK script snippets as a starting point. Good luck.
Re: Image Following mouse
I've been wanting to try something like this, my DPI scaling (144) is throwing things off somewhere though:
More pictures in here
The full code is below, you'll also need this .zip for the pictures:
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.
More pictures in here
Spoiler
Here's the most barebones version:Code: Select all
#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:
Code: Select all
#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
This is pretty clever and I hadn't thought of using unicode for shapes like that. Thanks!A_AhkUser wrote:This also can be done using a combination of geometric shapes sufficiently significant:
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:boiler wrote: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.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).
Spoiler
Re: Image Following mouse
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!!
Thx!!
-
- Posts: 3
- Joined: 27 Jul 2014, 21:26
Re: Image Following mouse
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!
Re: Image Following mouse
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.tubbiya wrote: ↑08 Nov 2020, 11:17I want to write a program for you, please e-mail me. tubbiya@hotmail.com
Re: Image Following mouse
Looks like a spammer.
Re: Image Following mouse
Yeah, one would think no one would actually send an email in response to posts like this, but I suppose it must work sometimes.
Re: Image Following mouse
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.
Re: Image Following mouse
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.tubbiya wrote: ↑08 Nov 2020, 14:55
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.
Re: Image Following mouse
I misrepresented myself, I need this program.boiler wrote: ↑08 Nov 2020, 15:41I’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.tubbiya wrote: ↑08 Nov 2020, 14:55
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.