VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Basic Text Entering via SendMessage / Postmessage API

SKoW  (11 Submissions)   Windows API Call/Explanation   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

This is a *baisc* sample of how to use the PostMessage API calls (same as SendMessage) to send text to a Textbox (or any hWnd actually).
Note: I tracked down the 3 WM_ messages through SPY++ and Notepad. Differnt applications may require more/less WM_ messages. A VB Textbox only needs WM_KEYDOWN but I added the other code incase. =].. Sorry about the cheap Variable names, this was programmed at 5am :)

Assumes
To make life easy, Assume you have a Form with a Text box on it (Text2) which will have the text to SEND to another text box (which we will put on the form so the hWnd is easy to get: Text1)

Side Effects
May have some issues if you put in random hWnds.

API Declarations
' I like Postmessage over Sendmessage
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_CHAR = &H102

Rate Basic Text Entering via SendMessage / Postmessage API (4(4 Vote))
Basic Text Entering via SendMessage / Postmessage API.bas

Basic Text Entering via SendMessage / Postmessage API Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters