Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-264 fix mouse_drag error when using AutoHotkey v2 #265

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading