Skip to content

Commit 16f67af

Browse files
committed
Cleaning up the code, moving window code to new branch.
1 parent c5da2d2 commit 16f67af

File tree

1 file changed

+10
-41
lines changed

1 file changed

+10
-41
lines changed

src/robotjs.cc

+10-41
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ using namespace v8;
1515
| |\/| |/ _ \| | | / __|/ _ \
1616
| | | | (_) | |_| \__ \ __/
1717
|_| |_|\___/ \__,_|___/\___|
18+
1819
*/
1920

2021
Handle<Value> moveMouse(const Arguments& args)
@@ -107,7 +108,15 @@ Handle<Value> typeString(const Arguments& args)
107108
return scope.Close(String::New("1"));
108109
}
109110

110-
//Screen
111+
/*
112+
_____
113+
/ ____|
114+
| (___ ___ _ __ ___ ___ _ __
115+
\___ \ / __| '__/ _ \/ _ \ '_ \
116+
____) | (__| | | __/ __/ | | |
117+
|_____/ \___|_| \___|\___|_| |_|
118+
119+
*/
111120

112121
Handle<Value> captureScreen(const Arguments& args)
113122
{
@@ -126,43 +135,6 @@ Handle<Value> captureScreen(const Arguments& args)
126135
//return scope.Close(String::New("1"));
127136
}
128137

129-
Handle<Value> getWindows(const Arguments& args)
130-
{
131-
HandleScope scope;
132-
133-
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
134-
CFIndex windowNum = CFArrayGetCount(windowList);
135-
136-
std::vector<Object> windows;
137-
Local<Object> obj = Object::New();
138-
139-
140-
for (int i = 0; i < (int)windowNum; i++)
141-
{
142-
CFDictionaryRef info = (CFDictionaryRef)CFArrayGetValueAtIndex(windowList, i);
143-
CFNumberRef currentPID = (CFNumberRef)CFDictionaryGetValue(info, kCGWindowOwnerPID);
144-
CFNumberRef currentWindowNumber = (CFNumberRef)CFDictionaryGetValue(info, kCGWindowNumber);
145-
CFStringRef currentTitle = (CFStringRef)CFDictionaryGetValue(info, kCGWindowName);
146-
CFIndex length = CFStringGetLength(currentTitle);
147-
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
148-
char *buffer = (char *)malloc(maxSize);
149-
CFStringGetCString(currentTitle, buffer, maxSize, kCFStringEncodingUTF8);
150-
obj->Set(String::NewSymbol("title"), String::New(buffer));
151-
obj->Set(String::NewSymbol("id"), Number::New(*(int *)currentWindowNumber));
152-
printf(buffer);
153-
printf("\n");
154-
//windows.push_back(obj);
155-
156-
}
157-
158-
159-
160-
//return scope.Close(String::New("1"));
161-
162-
return scope.Close(String::New("1"));
163-
}
164-
165-
166138
void init(Handle<Object> target)
167139
{
168140
target->Set(String::NewSymbol("moveMouse"),
@@ -182,9 +154,6 @@ void init(Handle<Object> target)
182154

183155
target->Set(String::NewSymbol("captureScreen"),
184156
FunctionTemplate::New(captureScreen)->GetFunction());
185-
186-
target->Set(String::NewSymbol("getWindows"),
187-
FunctionTemplate::New(getWindows)->GetFunction());
188157
}
189158

190159
NODE_MODULE(robotjs, init)

0 commit comments

Comments
 (0)