From 16f67af2efcf1f4c6cd00403cde3f50fcd948772 Mon Sep 17 00:00:00 2001 From: Jason Stallings Date: Mon, 19 Jan 2015 04:38:18 -0600 Subject: [PATCH] Cleaning up the code, moving window code to new branch. --- src/robotjs.cc | 51 ++++++++++---------------------------------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/src/robotjs.cc b/src/robotjs.cc index d6616d21..b4b598f0 100644 --- a/src/robotjs.cc +++ b/src/robotjs.cc @@ -15,6 +15,7 @@ using namespace v8; | |\/| |/ _ \| | | / __|/ _ \ | | | | (_) | |_| \__ \ __/ |_| |_|\___/ \__,_|___/\___| + */ Handle moveMouse(const Arguments& args) @@ -107,7 +108,15 @@ Handle typeString(const Arguments& args) return scope.Close(String::New("1")); } -//Screen +/* + _____ + / ____| +| (___ ___ _ __ ___ ___ _ __ + \___ \ / __| '__/ _ \/ _ \ '_ \ + ____) | (__| | | __/ __/ | | | +|_____/ \___|_| \___|\___|_| |_| + + */ Handle captureScreen(const Arguments& args) { @@ -126,43 +135,6 @@ Handle captureScreen(const Arguments& args) //return scope.Close(String::New("1")); } -Handle getWindows(const Arguments& args) -{ - HandleScope scope; - - CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); - CFIndex windowNum = CFArrayGetCount(windowList); - - std::vector windows; - Local obj = Object::New(); - - - for (int i = 0; i < (int)windowNum; i++) - { - CFDictionaryRef info = (CFDictionaryRef)CFArrayGetValueAtIndex(windowList, i); - CFNumberRef currentPID = (CFNumberRef)CFDictionaryGetValue(info, kCGWindowOwnerPID); - CFNumberRef currentWindowNumber = (CFNumberRef)CFDictionaryGetValue(info, kCGWindowNumber); - CFStringRef currentTitle = (CFStringRef)CFDictionaryGetValue(info, kCGWindowName); - CFIndex length = CFStringGetLength(currentTitle); - CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); - char *buffer = (char *)malloc(maxSize); - CFStringGetCString(currentTitle, buffer, maxSize, kCFStringEncodingUTF8); - obj->Set(String::NewSymbol("title"), String::New(buffer)); - obj->Set(String::NewSymbol("id"), Number::New(*(int *)currentWindowNumber)); - printf(buffer); - printf("\n"); - //windows.push_back(obj); - - } - - - - //return scope.Close(String::New("1")); - - return scope.Close(String::New("1")); -} - - void init(Handle target) { target->Set(String::NewSymbol("moveMouse"), @@ -182,9 +154,6 @@ void init(Handle target) target->Set(String::NewSymbol("captureScreen"), FunctionTemplate::New(captureScreen)->GetFunction()); - - target->Set(String::NewSymbol("getWindows"), - FunctionTemplate::New(getWindows)->GetFunction()); } NODE_MODULE(robotjs, init)