dcsimg
Results 1 to 9 of 9

Thread: Sending data from APP to another.. is it possible?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2003
    Posts
    509

    Question Sending data from APP to another.. is it possible?

    Inva
    Last edited by raladin; Mar 29th, 2014 at 10:01 PM.

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,630
    Very possible.

    Look for examples of the FindWindow, FindWindowEx, and SendMessage API functions.
    Please rate my post.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2003
    Posts
    509
    Inva
    Last edited by raladin; Mar 29th, 2014 at 10:15 PM.

  4. #4
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,630
    SendMessage does not send the message to any other hWnd other than the one you specify. If another window is receiving your messages then it's because a) the application is built to do that or b) I was going to say something else but I'm to drunk to say itand I don't feel like backspacing. c) You're finding the wrong window to send the message to.
    Please rate my post.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2003
    Posts
    509
    Inva
    Last edited by raladin; Mar 29th, 2014 at 10:15 PM.

  6. #6
    Member
    Join Date
    Oct 2003
    Posts
    40
    the hwnd changes all the time. I have a routine here that searches for window hWnd, based on the title of the window..

    your difficulty comes in trying to send text to the other window.. for that you need to get a handle on the hWnd of the actual text field.. and send the text to that..

    its much harder to know you have the right text field, but there may be a windows function that allows you to enumerate the child windows of a particular window.

    heres the windowfinder code:

    Code:
    Option Explicit
    
    Private targetString As String
    Private windowString As String
    Private targetHwnd As Long
    Private windowStrLen As Integer
    Private targetStrLen As Integer
    
    Const VK_RCONTROL = &HA3
    Const VK_CONTROL = &H11
    Const KEYEVENTF_EXTENDEDKEY = &H1
    Const KEYEVENTF_KEYUP = &H2
    
    Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    
    Public Declare Function GetForegroundWindow Lib "user32" () As Long
    Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    
    ' Find a window with a title containing target_string
    ' and return its hWnd.
    Public Function FindWindowStartingWithText(ByVal s As String) As Long
      targetString = s
      targetStrLen = Len(targetString)
      windowString = s & " "  'space becomes a null char in the case of overflowed text
      windowStrLen = Len(windowString)
      targetHwnd = 0
    
    
      ' Enumerate windows.
      EnumWindows AddressOf EnumCallback, 0
    
      ' Return the hWnd found (if any).
      FindWindowStartingWithText = targetHwnd
    End Function
    
    ' Check a returned task to see if it's the one we want.
    Public Function EnumCallback(ByVal app_hWnd As Long, ByVal param As Long) As Long
    
      GetWindowText app_hWnd, windowString, windowStrLen
    
      ' See if the title starts with the target string.
      If Left$(windowString, targetStrLen) = targetString Then
        ' This is the one we want.
        targetHwnd = app_hWnd
    
        ' Stop searching.
        EnumCallback = 0
      Else
        ' Continue searching.
        EnumCallback = 1
      End If
    End Function

    there IS some extra stuff in there.. strictly speaking, SetForegroundWindow is not necessary to the window finder... its there cause i added it to solve a problem in a project i was working on.. here's the project, as an idea of how windowfinder works:
    Attached Files Attached Files

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2003
    Posts
    509
    Inva
    Last edited by raladin; Mar 29th, 2014 at 10:15 PM.

  8. #8
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,630
    Window handles will change but their positions won't. Once you've found the correct control by using FindWindow & FindWindowEx, it'll always work.

    I've made a little app for you. Basically, it clicks a buttonn on calc.exe. I'm not sure if that's what you need.
    Attached Files Attached Files
    Please rate my post.

  9. #9
    Member
    Join Date
    Mar 2004
    Location
    Texas
    Posts
    53
    raladin have you figured out what needs to be done? If not post again here and I can tyr to help, as for all I've been doing is getting HWND from components of other apps ALL week lol.
    Good programming site:
    *http://www.planet-source-code.com

    Our CS Clan Page:
    *http://h2p.inter-gamer.com/index.html

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width