【问题标题】:Using Ruby on Mac OS X, how to programmatically click on the screen -- and mouse move, mouse down, and mouse up?在 Mac OS X 上使用 Ruby,如何以编程方式在屏幕上单击——以及鼠标移动、鼠标向下和鼠标向上?
【发布时间】:2011-03-27 02:51:09
【问题描述】:

最好的方法是什么? ffi、RubyCocoa 或 MacRuby 能做到吗?

似乎可以使用CGEventCreateMouseEventCGPostMouseEvent(已弃用)。

请给出一个可行的例子。谢谢。

更新:此问题的标题已更新...

【问题讨论】:

    标签: ruby macos osx-snow-leopard macruby ruby-cocoa


    【解决方案1】:

    在 MacRuby 中,您的视图可以捕获这些事件。只需查看 MacRuby 附带的 DotView 示例即可。

    class MyView < NSView 
      def mouseUp event
        puts convertPoint(event.locationInWindow, fromView:nil)
      end
    end
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多