Creating a mouse click simulation, in windows development

  • For development, I am trying to simulate a mouse click on emWIn Windows simulation.
    It works fine on the embedded device, but will make it much easier for development if I can simulate on my pC.
    I tried this, but it does not work.

    Any idea how to accomplish this?
    Thanks.

  • Hi,

    Try using the function GUI_PID_StoreState(). Simply fill the GUI_PID_STATE structure, passed along with this function, with the desired coordinates and if a press or unpress event occurs.

    For a click the unpress event should happen on the same position as the last down event.

    Below is an example, on click or release of the upper button a GUI_PID_STATE structure gets filled and passed to emWin. Since the up and down events occur inside the second button, it gets pressed and released.


    Regards,
    Sven

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Thanks Sven,
    I tried your code and it works OK with simulation, but my code does not.
    Should I call GUI_PID_StoreState() only inside the callBack function?

    My code is simple but in another thread (FreeRtos, but only one task calling GUI_EXE)
    any idea why it does not work?

    Regards,

  • Hi,

    You are passing a pressed and unpressed event directly after each other. On my end this is working but it will look like nothing happens. The only thing visible is that the button gets the focus.

    Try to perform a delay between the pressed and unpressed change in your other thread (not a GUI_Delay() one of your OS).
    Then it should become visible. Like in the code below.

    Also try to set breakpoints on both 'NCode = 0' in _cbBk(). Then you should run on them. First on the clicked and then on released event.

    Regards,
    Sven

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Working !!
    Thanks very much.
    I use FREERtos queue inside the call back routine, I find this to be stable, if it helps anyone:

    Johanan

    Edited once, last by johanan (July 11, 2018 at 9:10 AM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!