Click to See Complete Forum and Search --> : save automatically from an application


inluvwitiou
March 29th, 2001, 12:51 AM
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

cksiow
March 29th, 2001, 02:17 AM
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

Iouri
March 29th, 2001, 07:18 AM
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
iouri@hotsheet.com

inluvwitiou
March 30th, 2001, 12:26 AM
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

cksiow
March 30th, 2001, 04:07 AM
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

inluvwitiou
April 1st, 2001, 01:37 AM
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

cksiow
April 2nd, 2001, 12:57 AM
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.