Przeglądaj źródła

find toontown windows

Fabian Peter Hammerle 8 lat temu
rodzic
commit
263d7c1bcd
1 zmienionych plików z 33 dodań i 2 usunięć
  1. 33 2
      main.cpp

+ 33 - 2
main.cpp

@@ -1,11 +1,42 @@
+#include <cstring>
+#include <cassert>
+#include <iostream>
 extern "C" {
     #include <xdo.h>
 }
 
+void search_windows_by_name(const xdo_t* xdo, const char* name_regex, Window** windowlist_ret, unsigned int* nwindows_ret) {
+    xdo_search_t search;
+    memset(&search, 0, sizeof(xdo_search_t));
+    search.max_depth = -1;
+    search.require = xdo_search::SEARCH_ALL;
+    search.searchmask |= SEARCH_NAME;
+    search.winname = name_regex;
+    xdo_search_windows(xdo, &search, windowlist_ret, nwindows_ret);
+}
+
+void search_toontown_windows(const xdo_t* xdo, Window** windowlist_ret, unsigned int* nwindows_ret) {
+    search_windows_by_name(xdo, "Toontown.*", windowlist_ret, nwindows_ret);
+}
+
 int main() {
     xdo_t* xdo = xdo_new(NULL);
-    if(!xdo) {
-        return 1;
+    assert(xdo);
+
+    Window* windows;
+    unsigned int nwindows = 77;
+    search_toontown_windows(xdo, &windows, &nwindows);
+    std::cout << nwindows << std::endl;
+    for(unsigned int i=0; i<nwindows; i++) {
+        unsigned char* window_name = new unsigned char[255];
+        int name_len, name_type;
+        xdo_get_window_name(xdo, windows[i], &window_name, &name_len, &name_type);
+        if(name_len > 0) {
+            window_name[name_len] = '\0';
+            std::cout << window_name << std::endl;
+        }
+        delete(window_name);
     }
+
     return 0;
 }