Private Declare Function FindWindow Lib ″user32″ Alias ″FindWindowA″ ByVal lpClassName As String ByVal lpWindowName As String As Long Dim i As Integer Private Sub Command1_Click Me.WindowState = 1 Timer1.Enabled = True End Sub Private Sub Form_Load Form1.Caption = ″记事本自动保存″ Text1.Text = ″″ Text1.Text = 1 Shell ″notepad.exe″ vbNormalFocus '打开记事本,并使之成为当前窗口 Timer1.Enabled = True '激活时钟控件 Form1.WindowState = 0 End Sub Private Sub Timer1_Timer If FindWindow″Notepad″ vbNullString Then Dim b As Integer b = UpDown1.Value i = i + 1 If i Mod b 60 = 0 Then '设置自动存盘的时间间隔为分钟,可以根据需要进行更改。 SendKeys ″%FS″ True '调用文件菜单的保存命令,显示文件保存对话框 End If Else Unload Me End If End Sub