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

Float distance in mouse scroll. #1365

Open
PerretB opened this issue Jan 4, 2024 · 2 comments
Open

Float distance in mouse scroll. #1365

PerretB opened this issue Jan 4, 2024 · 2 comments

Comments

@PerretB
Copy link

PerretB commented Jan 4, 2024

Expected Behavior

Mouse scroll wheel function should accept float distance values on Windows.

It seems that a simple cast into int on this line https://github.com/pywinauto/pywinauto/blob/bf7f789d01b7c66ccd0c213db0a029da7e588c9e/pywinauto/windows/mouse.py#L321C37-L321C38 would solve the issue. Accepting float values would make sense because the distance is internally multiplied by 120 (one wheel click according to MS). However, I don't know about possible consequences on other systems.

Actual Behavior

Using a float value produces an Exception.

Steps to Reproduce the Problem

  1. Call pywinauto.mouse.scroll(wheel_dist=x) with x a float value

produces

Traceback (most recent call last):
  File "pywinauto\mouse.py", line 260, in scroll
    _perform_click_input(button='wheel', wheel_dist=wheel_dist, coords=coords)
  File "pywinauto\mouse.py", line 177, in _perform_click_input
    win32api.mouse_event(
TypeError: 'float' object cannot be interpreted as an integer

Short Example of Code to Demonstrate the Problem

from pywinauto import mouse
mouse.scroll(wheel_dist=0.5)

Specifications

  • Pywinauto version: 0.6.8
  • Python version and bitness: 3.10 x64
  • Platform and OS: AMD64, Windows
@vasily-v-ryabov
Copy link
Contributor

This is interesting feature request. I guess it is possible to implement it for high level method .wheel_mouse_input(wheel_dist=0.5) or .click_input() if the scroll bar range is available at the UI element level. More low level function mouse.scroll(wheel_dist=0.5) has no information about any scroll bars, so the ratio 0.5 is undefined at this level.

@PerretB
Copy link
Author

PerretB commented Jan 7, 2024

Thanks for your answer, indeed I was rather thinking about the low level feature. In my use case, there is no scroll bar (I use the scroll event to simulate a swipe up/down in a mobile like app), and a "wheel click" as defined by MS is indeed too coarse to have a fine control on the movement generated by the event. I tested with the low level win32 api and it accepts (and works) with distances which are not multiples of 120 (WHEEL_DELTA).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants