keyboard - game(directx) doesn't react on c++ keybd_event -
i need solving 1 thing.
i write fun 1 project take control of hugo game, want simulate keyboard in it. despite simulating keyboard in c++ easy thing, don't know why hugo doesn't react.
when simulate keyb_event:
keybd_event(vk_left, 0, 0, 0); keybd_event(vk_left, 0, keyeventf_keyup, 0);
as when send sendinput:
input ip; ip.type = input_keyboard; ip.ki.wscan = 0; ip.ki.time = 0; ip.ki.dwextrainfo = 0; ip.ki.wvk = vk_right; ip.ki.dwflags = 0; sendinput(1, &ip, sizeof(input)); ip.ki.dwflags = keyeventf_keyup; sendinput(1, &ip, sizeof(input));
or sendmessage:
sendmessage(hwnd, wm_keydown, vk_right, 0); sendmessage(hwnd, wm_keyup, vk_right, 0);
in cases, in notepad, cursor moves correctly, hugo still doesn't react.
i checked getforegroundwindow , getclassname hugo correctly on foreground. forcing setfocus , setactivewindow didn't changed also.
i can't tell hugo, here know sure: it's old game, opens in full screen, catalog "directx" suggests written directx , know.
currently don't have more ideas, send keyboard press game. have clues?
it use directinput. try using scancode sendinput.
example:
input ip = {0}; ip.type = input_keyboard; ip.ki.wscan = 73; // left arrow ip.ki.dwflags = keyeventf_scancode; sendinput(1, &ip, sizeof(input)); // left arrow pressed ip.ki.dwflags = keyeventf_keyup | keyeventf_scancode; sendinput(1, &ip, sizeof(input)); // left arrow released
Comments
Post a Comment