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",¤t)
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
}