Xcode 鼠标单击脚本帮助

Xcode 鼠标单击脚本帮助,xcode,cocoa,macos,mouse,Xcode,Cocoa,Macos,Mouse,我需要让鼠标点击屏幕上的一个点,具体到safari中的一个flash对象。。。。 我试着用applescript做这个,但没用。然后我在网上找到了这个脚本 // File: // click.m // // Compile with: // gcc -o click click.m -framework ApplicationServices -framework Foundation // // Usage: // ./cli

我需要让鼠标点击屏幕上的一个点,具体到safari中的一个flash对象。。。。 我试着用applescript做这个,但没用。然后我在网上找到了这个脚本

    // File: 
    // click.m
    //
    // Compile with: 
    // gcc -o click click.m -framework ApplicationServices -framework Foundation
    //
    // Usage:
    // ./click -x pixels -y pixels 
    // At the given coordinates it will click and release.


    #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;
}
//文件:
//点击.m
//
//编译时使用:
/gcc-o单击.m-框架应用服务-框架基础
//
//用法:
///单击-x像素-y像素
//在给定坐标处,它将单击并释放。
#进口

#导入

这是您在大多数编程入门课程中学习的内容。完整的答案很长,所以我只告诉你几个基石:

  • 您下载的程序不是脚本
  • 这是objective-C-sourcecode
  • 您需要学习如何使用终端应用程序(命令行)
  • 您需要学习如何在终端上调用命令(例如,
    gcc
  • 你必须理解单词
    compile
    的意思。在本例中,这是作者希望您在命令行中执行的操作
第二步:

  • /
    在目标C中开始注释
  • gcc…
    是编译程序时应在命令行上执行的命令
  • /click
    是调用程序的操作(编译后:-)
gcc-o单击click.m-frameworkapplicationservices-frameworkfoundation
指:

  • gcc
    :Gnu C编译器
  • -o单击
    :程序应命名为
    单击
  • click.m
    :这应该是源代码的名称(您称之为“脚本”的文件)

希望这能有所帮助……

谢谢michael,但我能想出如何使用终端,然后我就不仅仅是一个可以放置鼠标位置的x和y坐标的地方了。。。。它在哪里?它是程序的一个论点。你说
/点击-x200-y300
,它点击到位置(200300)pls。只需阅读源代码,它解释了它的所有细节!