Results 1 to 14 of 14

Thread: Send text to other programs [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Resolved Send text to other programs [RESOLVED]

    Is it possible to send text to fill boxes, clicks to check options and some way to press buttons in other program. Would that be possible? If yes, how would i?
    I'v tryed sendkeys but it didn't worked as i wanted to.

    Thanks
    Last edited by TDQWERTY; Sep 24th, 2005 at 09:53 AM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  2. #2
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Send text to other programs

    You should be able to do this with the SendMessage API, do a search with google, or search http://www.pscode.com/vb
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  3. #3
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Send text to other programs

    If you find a solution to your problem, please let me know as I am also interested in this.
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  4. #4
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Send text to other programs

    You could try DDE (Dynamic Data Exchange). People on here say its old, but it still works.
    Attached Files Attached Files
    Last edited by Keithuk; Sep 26th, 2005 at 03:06 PM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  5. #5
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Send text to other programs

    I think I might have an answer for you using SendMessage, check it out here: http://www.vbforums.com/showthread.php?t=36212
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  6. #6

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Send text to other programs

    the findwindow() doesn't find the window i'm looking for and the window title is correct..

    With notepad it works just fine!

    I'v tryed with:

    "MSN Messenger"
    "Mozilla Firefox"
    And some others...
    Last edited by TDQWERTY; Sep 24th, 2005 at 09:20 AM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  7. #7
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Send text to other programs

    Can you post the code you tried? What window is it?


    Has someone helped you? Then you can Rate their helpful post.

  8. #8

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Send text to other programs

    I'm using one that i'v found on psc:

    VB Code:
    1. Option Explicit
    2. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    4. Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
    5. Private Declare Function SendMessageLONG Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    6.  
    7. Private Const WM_GETTEXT = &HD
    8. Private Const WM_SETTEXT = &HC
    9. Private Const EM_GETLINECOUNT = &HBA
    10.  
    11. Private Sub CMDOPEN_Click()
    12. Shell "notepad.exe"
    13. End Sub
    14.  
    15. Private Sub tmrVirus_Timer()
    16. Dim lNotepadHwnd As Long
    17. Dim lNotepadEdit As Long
    18. Dim sCaption As String
    19.    
    20.     lNotepadHwnd = FindWindow("Notepad", vbNullString)
    21.     lNotepadEdit = FindWindowEx(lNotepadHwnd, 0&, "Edit", vbNullString)
    22.  
    23.     If lNotepadHwnd Then
    24.     lblStatus.Caption = "Open"
    25.     Else
    26.     lblStatus.Caption = "Closed"
    27.     End If
    28.    
    29.     SendMessageSTRING lNotepadHwnd, WM_SETTEXT, 256, "How does it feel?"
    30.     SendMessageSTRING lNotepadEdit, WM_SETTEXT, 256, "I told you so!"
    31.  
    32. End Sub

    It works fine on notepad...but not in other apps such as msn messenger or firefoz or whatever

    At this moment i would be happy to fin my own project app opened
    Last edited by TDQWERTY; Sep 24th, 2005 at 09:34 AM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  9. #9
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Send text to other programs

    You need to change
    VB Code:
    1. lNotepadEdit = FindWindowEx(lNotepadHwnd, 0&, "Edit", vbNullString)
    Replace "Edit" with the class of the control inside the prog
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  10. #10

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Send text to other programs

    i don't know why but i can't add the attachement.

    copy/paste in a *.frm file

    VERSION 5.00
    Begin VB.Form Form1
    Caption = "Form1"
    ClientHeight = 3945
    ClientLeft = 60
    ClientTop = 390
    ClientWidth = 9600
    LinkTopic = "Form1"
    ScaleHeight = 3945
    ScaleWidth = 9600
    StartUpPosition = 3 'Windows Default
    Begin VB.CommandButton Command3
    Caption = "Command3"
    Height = 495
    Left = 6840
    TabIndex = 11
    Top = 2760
    Width = 1935
    End
    Begin VB.CommandButton Command2
    Caption = "Command2"
    Height = 495
    Left = 3840
    TabIndex = 10
    Top = 2760
    Width = 1935
    End
    Begin VB.CommandButton Command1
    Caption = "Command1"
    Height = 495
    Left = 720
    TabIndex = 9
    Top = 2760
    Width = 1935
    End
    Begin VB.CheckBox Check3
    Caption = "Check3"
    Height = 375
    Left = 5640
    TabIndex = 8
    Top = 1920
    Width = 1575
    End
    Begin VB.CheckBox Check2
    Caption = "Check2"
    Height = 375
    Left = 4200
    TabIndex = 7
    Top = 1920
    Width = 1575
    End
    Begin VB.CheckBox Check1
    Caption = "Check1"
    Height = 375
    Left = 2520
    TabIndex = 6
    Top = 1920
    Width = 1575
    End
    Begin VB.TextBox Text3
    Height = 375
    Left = 6600
    TabIndex = 5
    Top = 240
    Width = 2655
    End
    Begin VB.TextBox Text2
    Height = 375
    Left = 3360
    TabIndex = 4
    Top = 240
    Width = 2655
    End
    Begin VB.TextBox Text1
    Height = 375
    Left = 120
    TabIndex = 3
    Top = 240
    Width = 2655
    End
    Begin VB.OptionButton Option3
    Caption = "Option3"
    Height = 255
    Left = 5640
    TabIndex = 2
    Top = 1320
    Width = 1575
    End
    Begin VB.OptionButton Option2
    Caption = "Option2"
    Height = 255
    Left = 4200
    TabIndex = 1
    Top = 1320
    Width = 1575
    End
    Begin VB.OptionButton Option1
    Caption = "Option1"
    Height = 255
    Left = 2520
    TabIndex = 0
    Top = 1320
    Width = 1575
    End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Private Sub Form_Load()

    End Sub
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  11. #11

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Send text to other programs

    Quote Originally Posted by shirazamod
    You need to change
    VB Code:
    1. lNotepadEdit = FindWindowEx(lNotepadHwnd, 0&, "Edit", vbNullString)
    Replace "Edit" with the class of the control inside the prog
    But it can't even find the window...the problem is before that

    I get lNotepadHwnd = 0 always
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  12. #12
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Send text to other programs

    There is no code in the form you submitted, just controls.
    Do you have the Class of the window?
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  13. #13

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Send text to other programs

    I found the window using Spy++ and i needed something more to find it.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  14. #14

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Send text to other programs

    Quote Originally Posted by shirazamod
    There is no code in the form you submitted, just controls.
    Do you have the Class of the window?
    No need for code in that form, i just want to fill it.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

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