VB send information to window handle w/o SendKeys

Posted on 2005-04-19
Last Modified: 2010-05-02
Here's the skinny -->

* I've a known window handle to where I want to send a piece of data from my pre-existing VB app.
* It is ten characters (all numeric)
* There also needs to be a CR to submit the query.  It is not a web based application.
* Sendkeys = BAAAAD!  

I can grab the window handle, but sending to that window handle (caption, text or window handle) is... ahem... throwing me for a Loop.  Sorry, couldn't resist.  
Question by:chitterbutt
    LVL 13

    Accepted Solution

    "The SetWindowText function changes the text of the specified window’s title bar (if it has one). If the specified window is a control, the text of the control is changed."

    Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

    LVL 29

    Expert Comment

    Use an API spy...There is one called PAT or JK's API spy, This will give you many options to choose from and to do whatever you want with the windows.  It also will actually write the source code for you so you can simply copy and paste the code into your application.

    For what you describe the options you would need are...findwindow,settext,gettext etc..

    It's very simple to use give it a try...

    download here::

    Author Comment

    LVL 29

    Expert Comment

    Whats terrible?
    LVL 29

    Expert Comment

    Sorry to inform you bit sendkeys is the only terrible thing here buddy

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    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…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now