Skip to content

Commit

Permalink
Merge pull request #282 from spyoungtech/gh-280
Browse files Browse the repository at this point in the history
Fix winmove in AutoHotkey v2 when width and height are omitted
  • Loading branch information
spyoungtech committed Apr 3, 2024
2 parents 2e70f6f + 680a922 commit 6d993d9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ahk/_async/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ async def find_windows(
if exact is not None and title_match_mode is not None:
raise TypeError('exact and match_mode parameters are mutually exclusive')
if exact is not None:
warnings.warn('exact parameter is deprecated. Use match_mode=3 instead', stacklevel=2)
warnings.warn('exact parameter is deprecated. Use title_match_mode instead', stacklevel=2)
if exact:
title_match_mode = (3, 'Fast')
else:
Expand Down
9 changes: 9 additions & 0 deletions ahk/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5494,6 +5494,15 @@
if (detect_hw != "") {
DetectHiddenWindows(detect_hw)
}
if (width = "" or height = "") {
WinGetPos(&_, &__, &w, &h, title, text, extitle, extext)
if (width = "") {
width := w
}
if (height = "") {
height := h
}
}
try {
WinMove(x, y, width, height, title, text, extitle, extext)
Expand Down
2 changes: 1 addition & 1 deletion ahk/_sync/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def find_windows(
if exact is not None and title_match_mode is not None:
raise TypeError('exact and match_mode parameters are mutually exclusive')
if exact is not None:
warnings.warn('exact parameter is deprecated. Use match_mode=3 instead', stacklevel=2)
warnings.warn('exact parameter is deprecated. Use title_match_mode instead', stacklevel=2)
if exact:
title_match_mode = (3, 'Fast')
else:
Expand Down
9 changes: 9 additions & 0 deletions ahk/templates/daemon-v2.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2504,6 +2504,15 @@ AHKWinMove(args*) {
if (detect_hw != "") {
DetectHiddenWindows(detect_hw)
}
if (width = "" or height = "") {
WinGetPos(&_, &__, &w, &h, title, text, extitle, extext)
if (width = "") {
width := w
}
if (height = "") {
height := h
}
}

try {
WinMove(x, y, width, height, title, text, extitle, extext)
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ Some of the notable differences that you may experience when using AutoHotkey v2
3. Some functionality is not supported in v2 -- specifically: the `secondstowait` paramater for `TrayTip` (`ahk.show_traytip`) was removed in v2. Specifying this parameter in the Python wrapper will cause a warning to be emitted and the parameter is ignored.
4. Some functionality that is present in v1 is not yet implemented in v2 -- this is expected to change in future versions. Specifically: some [sound functions](https://www.autohotkey.com/docs/v2/lib/Sound.htm) are not implemented.
5. The default SendMode changes in v2 to `Input` rather than `Event` in v1 (as a consequence, for example, mouse speed parameters to `mouse_move` and `mouse_drag` will be ignored in V2 unless the send mode is changed)

6. The default [TitleMatchMode](https://www.autohotkey.com/docs/v2/lib/SetTitleMatchMode.htm) is `2` in AutoHotkey v2. It is `1` in AutoHotkey v1. Use the `title_match_mode` keyword arguments to `win_get` and other methods that accept this keyword to control this behavior or use `set_title_match_mode` to change the default behavior (non-blocking calls are run in separate processes and are not affected by `set_title_match_mode`)

## Extending: add your own AutoHotkey code (beta)

Expand Down

0 comments on commit 6d993d9

Please sign in to comment.