TeaSpeak-Client/native/ppt/test/HookTest.cpp
2019-10-26 01:51:40 +02:00

26 lines
1.0 KiB
C++

#include "../src/KeyboardHook.h"
#include <iostream>
#include <thread>
using namespace std::chrono;
using namespace std;
int main() {
KeyboardHook hook;
hook.callback_event = [](const shared_ptr<KeyboardHook::KeyEvent>& event) {
if(event->type == KeyboardHook::KeyEvent::PRESS)
cout << "press " << event->code.c_str() << ": shift: " << event->key_shift << ", alt: " << event->key_alt << ", ctrl: " << event->key_ctrl << ", win: " << event->key_windows << endl;
else if(event->type == KeyboardHook::KeyEvent::TYPE)
cout << "type " << event->code.c_str() << ": shift: " << event->key_shift << ", alt: " << event->key_alt << ", ctrl: " << event->key_ctrl << ", win: " << event->key_windows << endl;
else
cout << "release " << event->code.c_str() << ": shift: " << event->key_shift << ", alt: " << event->key_alt << ", ctrl: " << event->key_ctrl << ", win: " << event->key_windows << endl;
};
if(!hook.attach()) {
cerr << "failed to attach!" << endl;
return 0;
}
this_thread::sleep_for(seconds(100));
return 0;
}