• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

How to action "keybd_event in ExecWB"

I want to know the Reason
that keybd_event("Tab") doesn't
working in ExecWB.

Where is this code Wrong?

 void CMyHtmlView::OnNavigateComplete2(LPCTSTR strURL)
{
// TODO: Add your specialized code here and/or call the base class

ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER, NULL, NULL);

HWND aWnd = (HWND)GetActiveWindow();

::SetActiveWindow(aWnd);

::keybd_event(VK_TAB,MapVirtualKey(VK_TAB,0),0,0);

::keybd_event(VK_TAB,MapVirtualKey(VK_TAB,0),KEYEVENTF_KEYUP,0);
      
CHtmlView::OnNavigateComplete2(strURL);
}
0
bluewin
Asked:
bluewin
  • 3
  • 3
1 Solution
 
chensuCommented:
The ExecWB does not return until it is done. That means the dialog box is no longer there when keybd_event is executed. There seems no way to achieve what you want.
0
 
bluewinAuthor Commented:
Then can I access and handle
the dialog box
that ExecWB created.

Isn't there any solution?

0
 
chensuCommented:
You may create another thread right befoer ExecWB. In that thread, try to use FindWindow to locate the dialog box. But this method is not stable and very ugly.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
bluewinAuthor Commented:
Could you donate me
the outline or skeleton of

Creating Thread,
Finding the window of CFileDialog...

Thank you very much.

0
 
chensuCommented:
Use AfxBeginThread to create a worker thread. See the documentation on AfxBeginThread and the article Multithreading: Creating Worker Threads in Visual C++ Programmer’s Guide.
0
 
bluewinAuthor Commented:
Thank you from the bottom of my heart for your kindness.
Good Luck!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now