How to Simulate a key press likes function keybd_event()

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
huynhvansen
In need of some credit
In need of some credit
Posts: 8
Joined: Fri Nov 10, 2006 9:37 am
Location: Viet Name

How to Simulate a key press likes function keybd_event()

Post by huynhvansen »

How to Simulate a key press likes function VOID keybd_event(
BYTE bVk, // virtual-key code
BYTE bScan, // hardware scan code
DWORD dwFlags, // function options
ULONG_PTR dwExtraInfo // additional keystroke data
);
in window API
How to do Simulate Key press in wxWindow wxwidgets ?
manianis
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Jan 15, 2007 11:00 am

Post by manianis »

Try sending message wxKeyEvent after filling :

wxKeyEvent::m_altDown
wxKeyEvent::m_controlDown
wxKeyEvent::m_keyCode
wxKeyEvent::m_metaDown
wxKeyEvent::m_shiftDown
wxKeyEvent::m_x
wxKeyEvent::m_y

properties... It can help perhaps...
agkaiser
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Jan 22, 2016 6:40 pm

Re: How to Simulate a key press likes function keybd_event()

Post by agkaiser »

the following worked for me without collateral damage.

Code: Select all

wxApp::OnInit()
{
...
Construct frame and canvas
...
other desired intitialization

frame->Show();

// see <wx/event.h>
    wxKeyEvent kevent;
    kevent.m_keyCode = 0; // replace 0 with the key you wish to send
    frame->canvas->OnChar(kevent);

    return true;
}
Last edited by doublemax on Sun Jan 31, 2016 10:06 pm, edited 1 time in total.
Reason: Added code tags
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to Simulate a key press likes function keybd_event()

Post by doublemax »

That would only work inside your own application.

The equivalent for keybd_event() under Windows would be wxUIActionSimulator:
http://docs.wxwidgets.org/trunk/classwx ... lator.html
Use the source, Luke!
Post Reply