CEF client : SendKeyEvent does not give the expected result

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

CEF client : SendKeyEvent does not give the expected result

Postby dpsbhamra » Sun May 21, 2017 5:45 am

I am using CEF version 3.2556.1368 and extended the cefclient sample in off-screen-rendering mode in a way that offscreen rendering window receives the keyoard input through my interface instead from the existing main root window through its window procedure.

I am using SendKeyEvent to send the keyboard inputs to the bowser.
Here is the small code snippet

DoKeyEvent(unsigned long vkCode, bool isDown, bool extended){

CefKeyEvent event;
event.windows_key_code = vkCode;
event.native_key_code = MapVirtualKey(vkCode,MAPVK_VK_TO_VSC);
event.is_system_key = 0;

if(isDown)
{
event.type = KEYEVENT_RAWKEYDOWN;
}
else
{
event.type = KEYEVENT_KEYUP;
}

event.modifiers = GetCefKeyboardModifiers(vkCode,isDown,extended);
browser_->GetHost()->SendKeyEvent(event);
}

Can anyone tell what is wrong with this code as i am not able to generate the desire result.
For eg VK_Code for generating "a" is ( 65 (Dec) or 0x41 (Hex) ) , even if i hardcode this value , i am not able to simulate "a" through the bowser.
Even if no modifiers is being used then also the result is not appropriate.
Just want to simulate simple "a" character without using any modifiers.
What i am doing wrong ??
dpsbhamra
Newbie
 
Posts: 2
Joined: Fri Mar 03, 2017 7:07 am

Re: CEF client : SendKeyEvent does not give the expected res

Postby Czarek » Thu May 25, 2017 12:43 pm

You should google for how Windows keyboard messages work. For 'a' character you have to send a KEYEVENT_CHAR event.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 30 guests