MouseClickDrag function not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
WeThotUWasAToad
Posts: 312
Joined: 19 Nov 2013, 08:44

MouseClickDrag function not working

06 Sep 2020, 17:16

Hello,

What would cause MouseClickDrag to not work and is there a way to improve its function?

I'm using Camtasia video editing software and I've got a number of steps which are repetitive, hence my use of an AutoHotkey script.

In one part of the process, I remove a small section of the recording. Doing so leaves a gap between the previous part of the recording (to the left) and the remaining part of the recording (to the right). When going through the process manually, the gap can easily be closed by simply dragging the remaining part of the recording from right to left.

I've used MouseClickDrag plenty of times in the past, but with this script, everything works great until the drag step and that doesn't work at all. (I can see the cursor move from the starting position to the ending position but it doesn't drag the recording bar with it as it should.)

Here is the portion of the script which includes the MouseClickDrag step:

Code: Select all

. . .
;Sleep lengths:
    short := 399
    medium := 999
    long := 2299
CoordMode, Mouse, Screen
MouseGetPos px,py
MouseMove %px%, 1945
	Sleep, short
Click						; activate track
	Sleep, short
Click, 335, 1735		; split track at current position
	Sleep, short
Click, 400, 1945		; activate segment to be deleted
	Sleep, short
Send {Delete}		; delete segment
	Sleep, short
MouseMove %px%, 1945
	Sleep, short
MouseMove, 100, 0,, R
	Sleep, short
Click
	Sleep, short
xNew := px + 100
	Sleep, medium
MouseClickDrag, Left, %xNew%, 1945, 350, 1945
	Sleep, medium
MouseMove %xNew%, 1945
	Sleep, short
Click
	Sleep, short
. . .
By the way, in the AHK docs, the syntax for MouseClickDrag includes an optional Speed parameter:

MouseClickDrag, WhichButton, X1, Y1, X2, Y2 [, Speed, Relative]

I've tried adding a value for that parameter but I've never (in this script or others in the past) seen any resulting change in the cursor speed.

Any suggestions re how to get the drag step working would be appreciated.

Thanks
A ------------------------------ [A LOT OF SPACE] ------------------------------ LOT

"ALOT" is not a word. It never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.
User avatar
mikeyww
Posts: 27241
Joined: 09 Sep 2014, 18:38

Re: MouseClickDrag function not working

06 Sep 2020, 17:55

It looks like you're going about it the hard way. Most advanced video editors have an auto-trim feature. You want to trim rather than cut, because trim will crop the media so that you can restore it later if needed. Look to see whether Camtasia has an option that will automatically close the gap for you following a trim; most editors can do it.
gregster
Posts: 9096
Joined: 30 Sep 2013, 06:48

Re: MouseClickDrag function not working

06 Sep 2020, 21:08

WeThotUWasAToad wrote:
06 Sep 2020, 17:16
By the way, in the AHK docs, the syntax for MouseClickDrag includes an optional Speed parameter:

MouseClickDrag, WhichButton, X1, Y1, X2, Y2 [, Speed, Relative]

I've tried adding a value for that parameter but I've never (in this script or others in the past) seen any resulting change in the cursor speed.
Did you try SendEvent mode in these cases?
https://www.autohotkey.com/docs/commands/MouseClickDrag.htm#Parameters wrote:Speed is ignored for SendInput/Play modes; they move the mouse instantaneously (though SetMouseDelay has a mode that applies to SendPlay). To visually move the mouse more slowly -- such as a script that performs a demonstration for an audience -- use SendEvent {Click 100, 200} or SendMode Event (optionally in conjuction with BlockInput).
https://www.autohotkey.com/docs/commands/MouseClickDrag.htm#Remarks wrote:This command uses the sending method set by SendMode.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], j4byers and 130 guests