1

如何获取鼠标悬停的 x 和 y 坐标。

我在 android 中有一个服务,它通过 eneter 消息传递框架连接到 .net 应用程序。我想从服务中获得鼠标的 x 和 y 位置。我希望鼠标位置不仅在点击上,而且在鼠标悬停上。

非常感谢

4

2 回答 2

3

Maybe not a best solution but atleast it works. Both solutions are based on Genymotion emulator.

Solution #1

  1. You need to install Genymotion emulator.
  2. Run emulator from VirtualBox app, wait a bit until you see a few lines like "init: untracked pid ... exited"
  3. Run the same emulator from Genymotion launcher.
  4. Now you can simulate mouse by moving it in VirtualBox app window (not genymotion window).

Depends on how long you wait before you do step 3, android can appear in genymotion or virtual box window.

Solution #2

  1. You need to install Genymotion emulator.
  2. Run VirtualBox app, go to your virtual box "android emulator":

    Settings -> Display -> Remote Display -> Check Enable Server
    
  3. Run android emulator through the genymotion launcher.
  4. Connect to your virtualbox with:

    $ rdesktop -a 16 localhost:3389
    

While you move cursor in rdesktop, you can see pointer in genymotion android emulator window. Now you can intercept hover events.

There is maybe a better solution - disable mouse integration for virtual machine, so, virtualbox can grab mouse cursor, like:

$ VBoxManage modifyvm "your-vm-name" --mouse ps2

but it doesn't work for me, maybe genymotion launcher overrides settings on every launch?

Links: http://developer.android.com/reference/android/view/View.OnHoverListener.html

p.s. hover events are available starting from api 14.

于 2013-11-21T23:27:43.343 回答
0

您还可以在 Live CD 模式下使用Android x86(或使用 Windows 以双启动方式安装它)。

于 2019-12-28T11:47:41.053 回答