Ver Fonte

sned space and backspace

Fabian Peter Hammerle há 8 anos atrás
pai
commit
1af4cd9e81
1 ficheiros alterados com 5 adições e 10 exclusões
  1. 5 10
      main.cpp

+ 5 - 10
main.cpp

@@ -5,6 +5,8 @@ extern "C" {
     #include <xdo.h>
 }
 
+const useconds_t KEY_DELAY = 12000; // microseconds
+
 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));
@@ -24,18 +26,11 @@ int main() {
     assert(xdo);
 
     Window* windows;
-    unsigned int nwindows = 77;
+    unsigned int nwindows;
     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);
+        xdo_send_keysequence_window(xdo, windows[i], "space", KEY_DELAY);
+        xdo_send_keysequence_window(xdo, windows[i], "BackSpace", KEY_DELAY);
     }
 
     return 0;