OS X 10.11.5를 마우스 오른쪽 버튼으로 클릭 할 수있는 스크립트를 작성하려고합니다. 나는 이것을 달성하기 위해 Objective-C에 Foundation 프레임 워크를 사용 해왔다. 지금까지 성공적으로 왼쪽 버튼을 클릭 할 수있었습니다.CGPostMouseEvent를 사용한 마우스 오른쪽 버튼 클릭 이벤트
아래 스크립트는 CGPostMouseEvent
을 사용하여 왼쪽 클릭을 할 수 있습니다. 해당 설명서는 CGRemoteOperation.h에서 찾을 수 있습니다.
CGPostMouseEvent에서 최종 매개 변수로 boolean_t
이 필요하다는 언급이 있습니다.
(태평양 표준시, 1, 1, 0, 1)
(태평양 표준시, 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;
}
Mac OS 10.6에서는'CGPostMouseEvent'가 사용되지 않습니다. – Willeke