LoginSignup
2
2

More than 5 years have passed since last update.

マウストラッキングをインタプリタでやってみる

Posted at

MacOS Xのマウス座標を拾ってみる、というのをコマンドラインベースでやってみようと、
色々見てみたけども、rubyCocoaはこういう用途に向いているかもしれない。

#!/usr/bin/ruby
require 'osx/cocoa'
while true
    event=OSX::CGEventCreate(nil); 
    pt = OSX::CGEventGetLocation(event); 
    print pt.x, ':', pt.y; print "\n"

    sleep 0.1
end
-- 結果のサンプル
1211.30859375:707.2578125
1121.4375:723.9765625
1000.21875:690.53515625
961.55078125:653.265625

マウス座標は整数値だと思っているので
小数点がとれてくるのがいまいち理解できてないところ。。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2