を使用してイベントを右クリックしてOS X 10.11.5上で右クリックします。私はこれを達成するためにObjective-CでFoundationフレームワークを使用してきました。これまでのところ、私は正常に左クリックすることができました。ポスト私のことができるようになりますスクリプト記述しようとしていますCGPostMouseEvent
以下のスクリプトはCGPostMouseEvent
を使用して左クリックできます。そのドキュメントはCGRemoteOperation.hにあります。
のコメントは、私はCGPostMouseEventの最後のパラメータにboolean_t
が必要であることを言及します。
(PT、1、1、0、1)
(PT、1、1、(0、1:私は、しかし、私は無駄にのparamsの次の組み合わせを試してみましたが、それが何を意味するのかわかりません))
(pt、1,1,2)
右クリックをトリガーするCGPostMouseEventの適切な最終パラメータは何ですか?
#import <Foundation/Foundation.h>
#import <ApplicationServices/ApplicationServices.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSUserDefaults *args = [NSUserDefaults standardUserDefaults];
// grabs command line arguments -x and -y
//
int x = [args integerForKey:@"x"];
int y = [args integerForKey:@"y"];
// The data structure CGPoint represents a point in a two-dimensional
// coordinate system. Here, X and Y distance from upper left, in pixels.
//
CGPoint pt;
pt.x = x;
pt.y = y;
// This is where the magic happens. See CGRemoteOperation.h for details.
//
// CGPostMouseEvent(CGPoint mouseCursorPosition,
// boolean_t updateMouseCursorPosition,
// CGButtonCount buttonCount,
// boolean_t mouseButtonDown, ...)
//
// So, we feed coordinates to CGPostMouseEvent, put the mouse there,
// then click and release.
//
CGPostMouseEvent(pt, 1, 1, 1);
CGPostMouseEvent(pt, 1, 1, 0);
[pool release];
return 0;
}
「CGPostMouseEvent」はMac OS 10.6では廃止予定です。 – Willeke