|
@@ -1,10 +1,12 @@
|
|
#include <cstring>
|
|
#include <cstring>
|
|
#include <cassert>
|
|
#include <cassert>
|
|
-#include <iostream>
|
|
|
|
|
|
+#include <thread>
|
|
|
|
+#include <chrono>
|
|
extern "C" {
|
|
extern "C" {
|
|
#include <xdo.h>
|
|
#include <xdo.h>
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const auto KEY_INTERVAL = std::chrono::seconds(64);
|
|
const useconds_t KEY_DELAY = 12000; // microseconds
|
|
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) {
|
|
void search_windows_by_name(const xdo_t* xdo, const char* name_regex, Window** windowlist_ret, unsigned int* nwindows_ret) {
|
|
@@ -21,17 +23,22 @@ void search_toontown_windows(const xdo_t* xdo, Window** windowlist_ret, unsigned
|
|
search_windows_by_name(xdo, "Toontown.*", windowlist_ret, nwindows_ret);
|
|
search_windows_by_name(xdo, "Toontown.*", windowlist_ret, nwindows_ret);
|
|
}
|
|
}
|
|
|
|
|
|
-int main() {
|
|
|
|
- xdo_t* xdo = xdo_new(NULL);
|
|
|
|
- assert(xdo);
|
|
|
|
-
|
|
|
|
|
|
+void send_keysequence(const xdo_t* xdo) {
|
|
Window* windows;
|
|
Window* windows;
|
|
unsigned int nwindows;
|
|
unsigned int nwindows;
|
|
search_toontown_windows(xdo, &windows, &nwindows);
|
|
search_toontown_windows(xdo, &windows, &nwindows);
|
|
for(unsigned int i=0; i<nwindows; i++) {
|
|
for(unsigned int i=0; i<nwindows; i++) {
|
|
- xdo_send_keysequence_window(xdo, windows[i], "Right", KEY_DELAY);
|
|
|
|
xdo_send_keysequence_window(xdo, windows[i], "Left", KEY_DELAY);
|
|
xdo_send_keysequence_window(xdo, windows[i], "Left", KEY_DELAY);
|
|
|
|
+ xdo_send_keysequence_window(xdo, windows[i], "Right", KEY_DELAY);
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
|
|
|
|
+int main() {
|
|
|
|
+ xdo_t* xdo = xdo_new(NULL);
|
|
|
|
+ assert(xdo);
|
|
|
|
+ while(true) {
|
|
|
|
+ send_keysequence(xdo);
|
|
|
|
+ std::this_thread::sleep_for(KEY_INTERVAL);
|
|
|
|
+ }
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|