Need Help - Autosaving a file/Folder

sameera

Member
Joined
Jun 16, 2005
Messages
20
Programming Experience
Beginner
Hi all,

I'm trying to develope an application which will abutamatically save the current working application (Something like autosave in MSWord).
Ex : I have a programe (or windows service) and after i run that, when i'm working on word it should save the document at the given intervals. Automatically.

And the main thing should be it has to be handlled automatically without prompting to the user. (User may select the source and destination once)

Can anyone help me on this or an new ideas are also welcome
thankx in advance

regards

sameera
 
You want it to be able to save any program your working on or just say.. microsoft word. If it's the former it could prove a touch complicated. to get you started in the right direction you'll need a timer to fire your save event at the given interval. Then your save event will have to determine what the currently running application is the and file path of the document being currently worked on. You may need a bit of old fashioned API for this, I'd have to think about it myself.
 
The following code snippet will determine the currently active window and the window caption.

VB.NET:
Expand Collapse Copy
private Declare Function GetForegroundWindow Lib "user32" () _
        as Long
private Declare Function GetWindowText Lib "user32" _
    Alias "GetWindowTextA" (byval hwnd as Long, _
       byval lpString as string, byval cch as Long) as Long
'
private Sub Form_Load()
    Timer1.Interval = 100
End Sub
'
private Sub Timer1_Timer()
    static lHwnd as Long
    Dim lCurHwnd as Long
    Dim sText as string * 255
'
    lCurHwnd = GetForegroundWindow
    If lCurHwnd = lHwnd then Exit Sub
    lHwnd = lCurHwnd
    If lHwnd <> hwnd then
        Caption = "ActiveWidow: " & Left$(sText, _
            GetWindowText(lHwnd, byval sText, 255))
    else
        Caption = "ActiveWindow: Form1"
    End If
End Sub
 
I don't think that would be possible, because most applications hold the working copy of their document in memory and there is usually no means to trigger any application to make a save from the outside.

The MS Office suite is probably one this actually could be done because of its automation, but they also got auto-save as an option.

Mind you, sameera, any decent application that needs this feature already got it incorporated, just enter their options and set you desired auto-save interval there.
 
Autosaving - Still not complete - Can anyone help !

Thank you very much for both of you! (vis781 and JhonH) And I also agreed that necessary applications already has that option. But i want to create a common application (Specially to save thing when i'm doing programming (coding , Design Etc...)).

And if posibble please send me a link (Or code) or any kind of referance where i can do auto saving (I think as VIS said) an API or something

Thanks again guys ! Hope to get an answer for this also

regards

sameera
 
Below is a link to an article relevant to all the applications in the MS Office suite, once you got a reference to an automation server (Word,Excel etc) you can use the Save or SaveAs methods of Workbook object of Excel and similar for Word and so on. But beware, user may NOT want to have the document in edit overwriting an existing document, even if it's the same document that was opened!
"How to use Visual C# to automate a running instance of an Office program"
http://support.microsoft.com/?scid=kb;en-us;316126&spid=2530&sid=47
 
Back
Top