Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SendMessage

Posted on 1999-07-26
7
Medium Priority
?
676 Views
Last Modified: 2010-04-30
Is there any way to send the "Enter" button using the sendmessage functions?
0
Comment
Question by:MChu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Accepted Solution

by:
bshuler072699 earned 200 total points
ID: 1527571
Use SendKeys.
0
 

Author Comment

by:MChu
ID: 1527572
i know sendkeys works but it gets messy because you ain't sure if it is setfocus on it at the time.  Is there any way to use sendmessage instead?
0
 
LVL 4

Expert Comment

by:tmack
ID: 1527573
Mchu.

What are you trying to accomplish?? Are you trying to send a message using the MAPI control?? More info please....

T
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:bshuler072699
ID: 1527574
Because you give no details, I will give you the process.

1: Do the task you want to automate a number of times by hand. Try not to do it with a mouse. Write down the strokes.

2: Use Spy++ to watch the messages. Only watch the Keyboard messages if you can.

3: Write SendMessage statements to replicate the activity.

Or the easy way:

1: Use FindWindow to get a handle to the window you want to send keys.

2: Use SetActiveWindow to make sure the keys go to the right window

3: Use send Keys to do the dirty work. Reuse SetActiveWindow if you need to do a lot and you are woried about user intervention. Also, buttons are 'windows'. So you can use FindWindow and IsVisible to check and see if the OK button is there yet, or IsEnabled to see it it is greyed or clickable.
0
 

Author Comment

by:MChu
ID: 1527575
i want to put text into a text of another application, and in order for the application to pick up the text you have to send the enter key.  i could use sendkeys but i am not that the focus would be at the textbox at the time. if there any way to send the enter key using sendmessage?
0
 
LVL 4

Expert Comment

by:tmack
ID: 1527576
MCHu,
I'm not sure how you would do this other than what was already suggested. (using the SENDKEYS)...

T
0
 
LVL 1

Expert Comment

by:bshuler072699
ID: 1527577
The way that you ensure that you are using SendMessage to the correct text box is by sending the keys to the TextBox's Handle.

How do I find the text box handle?

Enumerate the child windows
Check each window for class - maybe thunderbox, check in Spy++
Check each window for the offset from its parent.


If the parent is at 1000, 1000 and the child is at 1500, 1500 then the offset is 500, 500. It is very unlikely that there will be 2 text boxes that are at the same offset from their parent. If you run accross one that is the same, then also check for the size of the text box.

Any way, Get a list of handles to check using EnumChildWindows, then evaluate their class and offset using GetWindowRect and GetClassName

0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

722 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