Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267

    Unanswered: Hooking another application

    Has anyone done anything with hooking into other applications?

    Here is what I would like to do...I have a database where I query out some information from an SQL server. I would then like to be able to select a row from a form and click a button to paste the info into the appropriate fields in another application (non MS Office app). I'm thinking hooking the application is the way to go but I'm not having much luck finding any good info on how to do it.

    Any help is appreciated. Thanks.

    C

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    unless there is some form of API for the destination application then I doubt you will be able to do this automatically.

    however if its coming from an SQL db then if the destiantion application can query SQL then that would be the preferred route in my books

    failing that you could try the 'copy and paste' buffer. not to sure if you can do this automatically, but woudl be a breeze to instruct the user to do so. persoanlly I like those sort of solutions where its development time nil, testing time nil. my sort of win:win
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If the target application is build on the COM model, chances are that it implements an Automation (formerly called OLE Automation) interface which can expose its features to scripting tools and other applications. Although not necessarily easy, communicating with such applications is usually rather straightforward.

    If such Automation interface is not present in the taget application, it's theorically possible to implement a callback mechanism using the API functions GetWindowSubclass, SetWindowSubclass and RemoveWindowSubclass. From there you're on your own. This would require an in-depth knowledge of the Windows operating system, of the target application, and probably also countless hours of trials and errors. I would not recommend this approach.
    Have a nice day!

  4. #4
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    Hey all--

    I was actually able to get it to work using the following API calls.


    Code:
    Declare Function SetFocusAPI Lib "user32" Alias "SetForegroundWindow" _
        (ByVal hwnd As Long) As Long
       
    Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _
        ByVal wCmd As Long) As Long
    
    Declare Function GetDesktopWindow Lib "user32" () As Long
    
    Declare Function GetWindowLW Lib "user32" Alias "GetWindowLongA" _
        (ByVal hwnd As Long, ByVal nIndex As Long) As Long
       
    Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
       
    Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
        (ByVal hwnd As Long, ByVal lpClassName As String, _
         ByVal nMaxCount As Long) As Long
       
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
        (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) _
         As Long
    Wasn't really as hard as I thought it would be. Only about 2 hours of trial and error and I got it working. Gotta love Google.


    C

  5. #5
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    Forgot this call...probably the most important one.

    Code:
    Public Declare Function SendMessage Lib "user32" Alias _
       "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _
       wParam As Long, lParam As Any) As Long

Posting Permissions

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