Cursor not visible when video recording ahk movements

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
braddo
Posts: 6
Joined: 05 Jun 2021, 10:28

Cursor not visible when video recording ahk movements

05 Jun 2021, 10:41

I can see that this question is asked over and over in this and the old forum. I have tried many of the solutions offered but yet, still can't seem to accomplish what I'm trying to do.

The goal is to record video demonstration with the mouse being recorded traversing from point to point, clicking as needed. Ideally the mouse moves with easing/natural acceleration and in a curved path for aesthetic appeal for a recorded video.

Now, most of the solutions I've seen result in jerky movements of the mouse, or at least the cursor will jump "an inch" across the screen before flashing and reappearing another "distance" later.

I finally found a very nice smooth example below, which I hacked a little because I'm not trying to fool some anti-bot software and just want to move to a particular pixel. (apologies to the author, I now cannot remember from whence I snatched this code snippet). Here's the problem though - when recording the use of this particular example to move the mouse, although the cursor is visible to me on the screen, the recorder either sees nothing at all (Camtasia) or, again, only sees the cursor at one or two locations along the path (OBS screen recording). Is there some additional command/flag needed to make sure that the cursor is seen in every single frame of a recording (ideally at 60fps)?

How is the cursor visible to me but not the video recorder? Is there any relationship between this phenomenon and the physical mouse dpi or refresh rate? Grasping at straws since I think the physical mouse is irrelevant, but, who knows?

Thanks!

Brad

* I think the function below was originally called mousemove, but it wasn't clear if that would conflict with the inbuilt mousemove command, or maybe it *is* the mousemove command, not sure

Code: Select all

OMove(x,y,t:=750, r:=0,h:=1,w:=1){  ;hard coded the parameters because wanted it to be easier to call this function and set the random rectangle to 1x1 pixel
desiredx:=x ;regexmatch(options,"i)x(\-?\d+)",m) ? m1:""
desiredy:=y ;regexmatch(options,"i)y(\-?\d+)",m) ? m1:""
width:=w ;regexmatch(options,"i)w(\d+)",m) ? m1:0
height:=h ;regexmatch(options,"i)h(\d+)",m) ? m1:0
relative:=r ;regexmatch(options,"i)r(\d+)",m) ? m1:false
time:=t ;regexmatch(options,"i)t(\d+)",m)&&m1>0 ? m1:200
if desiredx=""||desiredy=""
		 return
batchlines:=a_batchlines
setbatchlines,-1
varsetcapacity(current,8)
dllcall("GetCursorPos","Uint",&current)
currentx:=numget(current,0,"Int")
currenty:=numget(current,4,"Int")
desiredx:=width ? rand(relative ? desiredx+currentx:desiredx,(relative ? desiredx+currentx:desiredx)+width):relative ? desiredx+currentx:desiredx
desiredy:=height ? rand(relative ? desiredy+currenty:desiredy,(relative ? desiredy+currenty:desiredy)+height):relative ? desiredy+currenty:desiredy
secondx:=rand(firstx:=rand(currentx,desiredx),desiredx)
secondy:=rand(firsty:=rand(currenty,desiredy),desiredy)
blockinput,mousemove
timeend:=(timestart:=a_tickcount)+time
while(a_tickcount<timeend)
{
	 dllcall("SetCursorPos",int,round(currentx*(fromend:=(timeend-a_tickcount)/time)**3+3*firstx*(fromstart:=(a_tickcount-timestart)/time)*fromend**2+3*secondx*fromend*fromstart**2+desiredx*fromstart**3),int,round(currenty*fromend**3+3*firsty*fromstart*fromend**2+3*secondy*fromend*fromstart**2+desiredy*fromstart**3))
	 dllcall("Sleep",UInt,1)
}
dllcall("SetCursorPos",int,desiredx,int,desiredy)
blockinput,mousemoveoff
setbatchlines,% batchlines
}
rand(a=0.0, b=1) {
ifequal a,,random,,b
else random,r,a,b
return r
}
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: Cursor not visible when video recording ahk movements

07 Jun 2021, 09:03

Are you sure that you can see the your normal (without ahk) cursor with Camtasia?

For OBS I recorded a test and I can see the mouse moving with your function (but I don't remember if I changed any mouse visibility settings, not sure if there's a setting actually).
braddo
Posts: 6
Joined: 05 Jun 2021, 10:28

Re: Cursor not visible when video recording ahk movements

07 Jun 2021, 19:58

Camtasia can see the mouse with manual recording. It is however recording mouse data in some way separately from the video because it has the option of hiding or smoothing the mouse after the fact. That feature works relatively well but it needs enough "mouse points" to smooth. I have ensured that Camtasia is set to record and show the mose, have recorded in every frame rate, used "trec" and h264 modes etc etc. Camtasia support has no clue.

OBS records only a few points. Have tried tweaking optiins there too but would def prefer Camtasia if I could. BTW another recorder "Macro Recorder" from Bartels Media does work with Camtasia but it is super fussy to use to capture a demo. Ahk is much more configurable

Finally, I found that the NVIDIA recorder with that cards driver works! Going with that for now but still suboptimal.

Honestly its nuts to record 4k, 60Hz, 54kbps to just record the mouse badly when nothing else is miving in the acreen. There has to be a way to get smooth captured mouse movements! The for sure alternative would be to animate the mouse movements in post but again huge waste of time!

Anyone who knows the secret please let me in on it! :-)
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: Cursor not visible when video recording ahk movements

08 Jun 2021, 08:45

Excuse me a question, since each person here has different levels of understanding.
Have you noticed the option "t" (for movement duration) on your function Omove()?
I was thinking that maybe you could record a mouse movement in slow motion and then speed up the video.
need4speed
Posts: 143
Joined: 22 Apr 2016, 06:50

Re: Cursor not visible when video recording ahk movements

08 Jun 2021, 15:24

Hey Brad,

afaik most screen recording software like OBS use the ffmpeg library which has certain limitations.
Post some code to show how you use the OMove function, maybe someone can reproduce the issue or provide a work-around.
braddo
Posts: 6
Joined: 05 Jun 2021, 10:28

Re: Cursor not visible when video recording ahk movements

11 Jun 2021, 12:26

thanks for the responses @need4speed and @safetycar

Sorry for the delayed response. I did need to complete my project manually for our launch.

In case anyone's interested, we make the best financial modeling tool, Quantrix, and here's the latest "What's New" video :https www.youtube.com /watch?v=Zf2Q75sdpmM&t=2s Broken Link for safety

So, yes I make great use of the timing aspect of that function. And, indeed, in the past, I have recorded at super slow speed then sped up the video in post. It works well!, but takes forever.

I was hoping to find the right automation tooling that would make that kind of approach unnecessary. Still looking! and ahk is terrific.

Then, as to how the OMove function is used, it's just like this:

Code: Select all

OMove(1172 , 931)
sleep MyPause
Send, {Shift down}
GoClick(1172 , 931) ; sales to
sleep 500
GoClick(1196 , 1041) ; to profit
sleep 500
Send, {Shift up}
sleep MyPause
GoClick, calls OMove then adds a click and pause to it. Pretty simple stuff.

The challenge may lie in how exactly the mouse/cursor is controlled in the underlying libraries/apis, then if that can be smooth, and also if in doing so, one could keep from locking Camtasia out of also capturing those moves.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: avernikov and 114 guests