CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2000
    Posts
    33

    save automatically from an application

    Hello everybody,

    I'd like to know if it's possible in VB to access an application to make it execute some actions based on some specific events. For example, i'm using the yahoo messenger as a chat, and i'd like to make it save all the received and sent messages automatically in a specific file.doc when
    exiting. This is already possible with it but it has to be done manually by clicking on the save button.

    Thanks,

    Ilw





  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: save automatically from an application

    I think you gonna to find out what sort of windows message that the save function response (I think you can use spy utility to get it).

    Once you got that, you can then get the window handle of the program by using FindWindow API and then use SendMessage API to send the message that u get using spy to that window handle.

    hope this help

    cksiow
    http://vblib.virtualave.net - share our codes



  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: save automatically from an application

    In order to execute different tasks based on the specific events you can strat your app with parameters. YourApp.exe param1 or YourApp.exe param2 etc.
    Command$ statement in your app will accept your parameters. Now you can do case, if or something else.

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Oct 2000
    Posts
    33

    Re: save automatically from an application

    Hi,
    thanks for replying. I understand the concept but i think i need a little bit more details. I mean,
    how do i get this spy utility ? And something else i don't understand is how my vb program will
    be able to interact with the app. do i need to
    create an application object in VB ?

    Thanks

    Ilw


  5. #5
    Join Date
    Apr 2000
    Posts
    737

    Re: save automatically from an application

    the utility should come with visual studio, "D:\Program Files\DevStudio\VC\bin\SPYXX.EXE" should be the program name if you have standard installation.

    Your vb program doesn't have to interact with that app. what your vb need to do is to tell the OS, windows, that you want to tell the application to do something with SendMessage API.

    That's is why you need to ask spy to "capture" the message that the application looking for saving somethings.

    If you still not sure, let me know the application that you want to interact and what is that you want it to perform automatically. Maybe I got that application and able to help.

    hope this help.

    cksiow
    http://vblib.virtualave.net - share our codes


  6. #6
    Join Date
    Oct 2000
    Posts
    33

    Re: save automatically from an application

    It's the yahoo messenger chat, i'd like
    to try to make it save all the messages
    i send and receive automatically in a file.doc when exiting. Normally, it's done with file
    menu, save as ...
    I admitt that's it's not too much useful but the code in VB interests me.

    Thanks.

    Ilw


  7. #7
    Join Date
    Apr 2000
    Posts
    737

    Re: save automatically from an application


    private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, lParam as Any) as Long
    private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (byval lpClassName as string, byval lpWindowName as string) as Long

    Const WM_COMMAND = &H111


    private Sub Command1_Click()
    Dim hwnd as Long

    hwnd = FindWindow("IMClass", vbNullString)
    SendMessage hwnd, WM_COMMAND, 32970, 0&



    End Sub





    I can only get this code for this moment of time, I hope you can work thru all the code from here.


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

Featured