Skip to content

Commit

Permalink
Added mouseClick function.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Sep 1, 2014
1 parent 7f2090d commit e4ba3c0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/autonode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,33 @@ Handle<Value> getMousePos(const Arguments& args)
HandleScope scope;

MMPoint pos = getMousePos();

//Return object with .x and .y.
Local<Object> obj = Object::New();
obj->Set(String::NewSymbol("x"), Number::New(pos.x));
obj->Set(String::NewSymbol("y"), Number::New(pos.y));
return scope.Close(obj);
}

Handle<Value> mouseClick(const Arguments& args)
{
HandleScope scope;

MMMouseButton button = LEFT_BUTTON;

clickMouse(button);
return scope.Close(String::New("1"));
}

void init(Handle<Object> target)
{
target->Set(String::NewSymbol("moveMouse"),
FunctionTemplate::New(moveMouse)->GetFunction());

target->Set(String::NewSymbol("getMousePos"),
FunctionTemplate::New(getMousePos)->GetFunction());

target->Set(String::NewSymbol("mouseClick"),
FunctionTemplate::New(mouseClick)->GetFunction());
}
NODE_MODULE(autonode, init)

0 comments on commit e4ba3c0

Please sign in to comment.