Results 1 to 6 of 6

Thread: Send a character to active window

  1. #1

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    Send a character to active window

    Hi,

    This is what i use to send a character to the active window ...

    But it does not work with some software .....

    ds2 = active_control_hwnd

    chr_a = â

    Call PostMessage(ds2, WM_CHAR, Asc(chr_a), 0&)

    Does anyone know a better way to send the charcater to the active window .... ?

    the programs Outlook Express and Dreamweaver don't get the WM_CHAR command.....
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961
    Try using SendKeys()

  3. #3

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    I want to use sendmsessage

    Hi,

    I want to send it using sendmessage .....
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  4. #4
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711
    the reason sertian applications dont recieve characters like
    "áéÉÑÔ¾¶×Ü" may be because the application uses a font that doesn't support those characters.

    Try using this and tell us if it workes:
    VB Code:
    1. Call PostMessage(ds2, WM_CHAR, 41, 0&)
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  5. #5

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    I want to send the backspace key

    Hi,

    I used it this way and it worked

    Call PostMessage(ds2, WM_CHAR, asc(chr_a), 1)

    But can't send the backspace key that way ....

    I tried the WM_KEYDOWN and WM_KEYUP messages too...

    How can I send the backspace key using sendmessage ....?

    Is there another way to send the backspace key using sendmessage...
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  6. #6
    Lively Member vbgamer45's Avatar
    Join Date
    Sep 2004
    Posts
    72
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Const WM_CHAR As Long = &H102
    Public Const VK_RETURN = &HD 'you must use your key LOOK HERE!

    sub SendReturnToNotepad()

    dim hWindow as long
    hWindow=FindWindow(vbNullString,"Notepad")

    SendMessage hWindow, WM_CHAR, VK_RETURN, 0&

    end sub


    If that doesn't work for you, you can try to get the
    Virtual Key for backspace using this api.
    Declare Function MapVirtualKey Lib "user32.dll" Alias "MapVirtualKeyA" ( _
    ByVal wCode As Long, _
    ByVal wMapType As Long) As Long
    Semi VB Decompiler 0.07 Getting better everyday
    http://www.visualbasiczone.com/produ...ivbdecompiler/
    VisualBasicZone
    http://www.visualbasiczone.com
    EasyPHPBB.com
    Free PHPBB forums the quick and easy way!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width