Solved

How to use SendKeys() in MFC

Posted on 2004-04-05
6
1,757 Views
Last Modified: 2013-11-20
We use a function SendKeys() in visual vabic of shell object. We send keys to other applications(like notepad,word etc.) by sendkeys.
I'm unable to access SendKeys in MFC. how can i access it or how can i send messages to other applications in MFC?
and how can i access shell object in MFC?
Waiting for reply.
and thanks for your response for my first question(deletesystemfile).
0
Comment
Question by:ManojKrChauhan
  • 3
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
nonubik earned 20 total points
Comment Utility
To send messages to other applications, you can use CWnd::SendMessage(..) http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_CWnd.3a3a.SendMessage.asp
0
 

Author Comment

by:ManojKrChauhan
Comment Utility
Can i send keyboard event to other application using SendMesage().
I want to send TAB key event to other application. how can i do it?
0
 
LVL 16

Expert Comment

by:nonubik
Comment Utility
SendMessage(hAppWnd, WM_KEYDOWN, VK_TAB, 0), where the hAppWnd is the application's window handle
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:ManojKrChauhan
Comment Utility
It's not working. I open an exe through WinExec then send message to it.
no problem in WM_CLOSE,WMSETTEXT,WM_GETTEXT.
But keyboard messagees are not working. I want to send TAB key to application(without pressing it)
waiting for reply.
0
 
LVL 4

Expert Comment

by:mblat
Comment Utility
Do you have control of other application?  Basically you are the one who is writing it or you trying to control 3rd party app?
0
 

Author Comment

by:ManojKrChauhan
Comment Utility
I have done for sendmessage. Thanks
There is a problem related with sendkeys
when i open file file by shell function then it bacame active by appactivate() and i can send keys to its window by Sendkeys(). But when i open any file by shell.run the i activate the window by appactivate and tried to send keys. then keys don't send to its windows. I want to send keys to window which is open by shell.run
Like .MSC file we can open mmc.exe (only by shell.run() not shell() or winexec() or shellexecute())for win2k. when i open .msc file then i try to activate its window by appactivate() setforegroundwindow() etc. but no success.
 so please give a reply how can i send keys to such applications
             thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now