Closed dudul closed 7 years ago
Interception currently can only work by intercepting an actual device, there's no option like it creating and using its own stand alone virtual device.
Given that, there's one mechanism though, by emulating input from any attached device, which is to query hardware device IDs for all possible device IDs and checking whether the return is not 0. Something along these lines (didn't tried):
wchar_t hardware_id[500];
std::vector<unsigned int> available_keyboards;
for(auto d = INTERCEPTION_KEYBOARD(0); d != INTERCEPTION_KEYBOARD(INTERCEPTION_MAX_KEYBOARD); d++) {
size_t length = interception_get_hardware_id(context, d, hardware_id, sizeof(hardware_id));
if (length != 0) {
available_keyboards.push_back(d);
}
}
std::vector<unsigned int> available_mice;
for(auto d = INTERCEPTION_MOUSE(0); d != INTERCEPTION_MOUSE(INTERCEPTION_MAX_MOUSE); d++) {
size_t length = interception_get_hardware_id(context, d, hardware_id, sizeof(hardware_id));
if (length != 0) {
available_mice.push_back(d);
}
}
With such ID lists for active attached devices, you can use any of those ID's
as argument for interception_send
.
Also, as explained in the web page, the device ID is a dynamic counter, which is subject to change on device reattaching and the hardware IDs can be the same for different devices in case these devices happen to be of same model and fabricant.
I tried the following but I get no input and no error :(
int main()
{
wchar_t hardware_id[500];
std::vector<unsigned int> available_keyboards;
for (auto d = INTERCEPTION_KEYBOARD(0); d != INTERCEPTION_KEYBOARD(INTERCEPTION_MAX_KEYBOARD); d++) {
size_t length = interception_get_hardware_id(context, d, hardware_id, sizeof(hardware_id));
if (length != 0) {
available_keyboards.push_back(d);
}
}
InterceptionKeyStroke stroke;
enum ScanCode
{
SCANCODE_X = 0x2D,
SCANCODE_Y = 0x15,
SCANCODE_ESC = 0x01
};
stroke.code = SCANCODE_Y;
for (std::vector<unsigned int>::const_iterator i = available_keyboards.begin(); i != available_keyboards.end(); ++i) {
std::cout << *i << ' ';
interception_send(context, *i, (InterceptionStroke *)&stroke, 1);
interception_send(context, *i, (InterceptionStroke *)&stroke, 1);
interception_send(context, *i, (InterceptionStroke *)&stroke, 1);
}
}```
@Ricardonacif have you checked whether you got any device pushed into available_keyboards
at least? Your InterceptionKeyStroke stroke
is also not correctly/fully initialized.
Is it possible to run interception_send without specific device. Or is there option to get the device without waiting for key to be pressed?
Thnaks