Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
293 views
in Technique[技术] by (71.8m points)

c++ - How to implement mouse_event() to work continuously in MFC?

I am trying to make a MFC Program using Myo.

I made several combo box control for each gesture.

This is my plan.


When I select an option of combo box, It should work as a real mouse.

(e.g. : If I choose option(Left Click), it should allow me to do Left click when I take a pose "Fist" && Myo is in unlock state.

void CMyoControllerView::OnCbnSelchangeComboFist() {
   int nIndex = m_combo_Fist.GetCurSel();

   if(nIndex == 0) {// Left Click
     if(collector.isUnlocked == true && collector.currentPose == myo::Pose::fist) { 
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, NULL);
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, NULL);
      }
   }
}

However, this code only affects mouse just when I change the option(ONLY ONE TIME!).

I know that I should not put this code in control event code. The problem is that I have no idea where should I put it.

I want to make this function working continuously until I finish this program.

(Like a thread.. I have five combo box and each has different mouse event. All five function should be working together.)

Please give me some advices. Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Create a queue of actions. Have the combobox handler put a click action into the queue. Use a separate timer or thread to process actions that are in the queue. If an action needs to be repeated, put it back in the queue after it has finished.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...