Skip to content

Commit

Permalink
GH-264 fix mouse_drag error when using AutoHotkey v2
Browse files Browse the repository at this point in the history
  • Loading branch information
spyoungtech committed Feb 26, 2024
1 parent f2d38c9 commit 074e82f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ahk/_async/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2901,7 +2901,7 @@ async def mouse_drag(
*,
from_position: Optional[Tuple[int, int]] = None,
speed: Optional[int] = None,
button: MouseButton = 1,
button: MouseButton = 'left',
relative: Optional[bool] = None,
blocking: bool = True,
coord_mode: Optional[CoordModeRelativeTo] = None,
Expand All @@ -2927,6 +2927,8 @@ async def mouse_drag(

if coord_mode:
args.append(coord_mode)
else:
args.append('')

await self._transport.function_call('AHKMouseClickDrag', args, blocking=blocking)

Expand Down
12 changes: 11 additions & 1 deletion ahk/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4815,7 +4815,17 @@
CoordMode("Mouse", relative_to)
}
MouseClickDrag(button, x1, y1, x2, y2, speed, relative)
if (speed = "") {
speed := A_DefaultMouseSpeed
}
if (x1 = "" and y1 = "") {
MouseClickDrag(button, , , x2, y2, speed, relative)
}
else {
MouseClickDrag(button, x1, y1, x2, y2, speed, relative)
}
if (relative_to != "") {
CoordMode("Mouse", current_coord_rel)
Expand Down
4 changes: 3 additions & 1 deletion ahk/_sync/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2889,7 +2889,7 @@ def mouse_drag(
*,
from_position: Optional[Tuple[int, int]] = None,
speed: Optional[int] = None,
button: MouseButton = 1,
button: MouseButton = 'left',
relative: Optional[bool] = None,
blocking: bool = True,
coord_mode: Optional[CoordModeRelativeTo] = None,
Expand All @@ -2915,6 +2915,8 @@ def mouse_drag(

if coord_mode:
args.append(coord_mode)
else:
args.append('')

self._transport.function_call('AHKMouseClickDrag', args, blocking=blocking)

Expand Down
12 changes: 11 additions & 1 deletion ahk/templates/daemon-v2.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,17 @@ AHKMouseClickDrag(args*) {
CoordMode("Mouse", relative_to)
}

MouseClickDrag(button, x1, y1, x2, y2, speed, relative)
if (speed = "") {
speed := A_DefaultMouseSpeed
}

if (x1 = "" and y1 = "") {
MouseClickDrag(button, , , x2, y2, speed, relative)
}
else {
MouseClickDrag(button, x1, y1, x2, y2, speed, relative)
}


if (relative_to != "") {
CoordMode("Mouse", current_coord_rel)
Expand Down

0 comments on commit 074e82f

Please sign in to comment.