main.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <cstring>
  2. #include <cassert>
  3. #include <iostream>
  4. extern "C" {
  5. #include <xdo.h>
  6. }
  7. const useconds_t KEY_DELAY = 12000; // microseconds
  8. void search_windows_by_name(const xdo_t* xdo, const char* name_regex, Window** windowlist_ret, unsigned int* nwindows_ret) {
  9. xdo_search_t search;
  10. memset(&search, 0, sizeof(xdo_search_t));
  11. search.max_depth = -1;
  12. search.require = xdo_search::SEARCH_ALL;
  13. search.searchmask |= SEARCH_NAME;
  14. search.winname = name_regex;
  15. xdo_search_windows(xdo, &search, windowlist_ret, nwindows_ret);
  16. }
  17. void search_toontown_windows(const xdo_t* xdo, Window** windowlist_ret, unsigned int* nwindows_ret) {
  18. search_windows_by_name(xdo, "Toontown.*", windowlist_ret, nwindows_ret);
  19. }
  20. int main() {
  21. xdo_t* xdo = xdo_new(NULL);
  22. assert(xdo);
  23. Window* windows;
  24. unsigned int nwindows;
  25. search_toontown_windows(xdo, &windows, &nwindows);
  26. for(unsigned int i=0; i<nwindows; i++) {
  27. xdo_send_keysequence_window(xdo, windows[i], "space", KEY_DELAY);
  28. xdo_send_keysequence_window(xdo, windows[i], "BackSpace", KEY_DELAY);
  29. }
  30. return 0;
  31. }