Skip to content

Commit

Permalink
PixelSearch: fix wrong x/y with coordmode relative (the default)
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Feb 25, 2023
1 parent 178857b commit a8ea453
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cmd/misc/pixel-search.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Cmd::Misc::PixelSearch < Cmd::Base
match_x = x + x1
match_y = y + y1
if thread.settings.coord_mode_pixel == ::Run::CoordMode::RELATIVE
match_y, match_x = Cmd::X11::Window::Util.coord_screen_to_relative(thread, match_y, match_x)
match_x, match_y = Cmd::X11::Window::Util.coord_screen_to_relative(thread, match_x, match_y)
end
thread.runner.set_user_var(out_x, match_x.to_s) if ! out_x.empty?
thread.runner.set_user_var(out_y, match_y.to_s) if ! out_y.empty?
Expand Down
13 changes: 6 additions & 7 deletions tests.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; Right now, only commands that can be easily tested in 1-2 lines are tested.
;;;;;;;;;;;;;;;;;;;;;;

N_TESTS = 30
N_TESTS = 32

GoSub, run_tests
if tests_run != %N_TESTS%
Expand Down Expand Up @@ -387,16 +387,15 @@ gosub assert
;Pause [, On|Off|Toggle]

coordmode, pixel, relative
PixelGetColor, color, 24, 10, rgb
PixelGetColor, color, 26, 8, rgb
expect = pixelgetcolor,color,7BC07B
gosub assert

PixelSearch, x, y, 0, 0, 100, 100, 0x7BC07B, 0, rgb
expect = pixelsearch,x,24
; TODO broken?
; gosub assert
expect = pixelsearch,y,10
; gosub assert
expect = pixelsearch,x,26
gosub assert
expect = pixelsearch,y,8
gosub assert

;;PostMessage, Msg [, wParam, lParam, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
;;Process, Cmd, PID-or-Name [, Param3]
Expand Down

0 comments on commit a8ea453

Please sign in to comment.