前天早上的时候,手机突然响了起来,拿起来一看原来是以前设置的备忘-->提醒我两天后有分报告要交。。。然后又突然想到自己用vbs+html也可以做个自己的备忘录...
现在这个程序已经写好了,现在来和大家一起分享...
这个程序一共有4个文件edit.vbs,main.vbs,setup.vbs和main.hta
edit.vbs的源代码如下:
- Sub edit_file(filename,file_doc)
- Dim FSO,file
- Set FSO = CreateObject("SCripting.FileSystemObject")
- Set file=FSO.CreateTextFile("C:\我的备忘录\data\" & FormatDateTime(filename,2) & ".txt",1,False)
- file.Write file_doc
- file.Close
- Set file = Nothing
- Set FSO = Nothing
- End Sub
复制代码
main.vbs的源代码如下:
- Dim FSO,Folder,File,str,file1
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set Folder=FSO.GetFolder("C:\我的备忘录\data")
- For Each File In Folder.Files
- If Date() & ".txt" = File.Name Then
- Set file1=FSO.OpenTextFile(File.Path,1,true)
- str=file1.readall()
- MsgBox str,vbOKOnly,Date() & " 的备忘"
- file1.Close
- Set file1=Nothing
- End If
- Next
- Set Folder=Nothing
- Set FSO=Nothing
复制代码
setup.vbs的源代码如下:
- On Error Resume Next
- Dim FSO,WshShell
- Set FSO=CreateObject("Scripting.FIleSystemObject")
- FSO.CreateFolder("C:\我的备忘录")
- FSO.CreateFolder("C:\我的备忘录\Data")
- FSO.CopyFile "main.vbs","C:\我的备忘录\"
- FSO.CopyFile "main.hta","C:\我的备忘录\"
- FSO.CopyFile "edit.vbs","C:\我的备忘录\"
- Set WshShell = CreateObject("WScript.Shell")
- WshShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\备忘录","C:\我的备忘录\main.vbs"
- Set FSO = Nothing
- Set WSHSHELL=CreateObject("WSCript.SHELL")
- strDesktop = WshShell.SpecialFolders("Desktop")
- Set SC = wshshell.CreateShortcut(strDesktop & "\备忘录.lnk")
- SC.TargetPath="C:\我的备忘录\main.hta"
- SC.IconLocation="%SystemRoot%\system32\SHELL32.dll,41"
- SC.Description = "By 小朋友※乞丐"
- SC.Hotkey = "CTRL+SHIFT+F"
- SC.save
- If MsgBox("By 小朋友※乞丐" & vbNewLine & "QQ:229774166" & vbNewLine & vbNewLine & "是否访问其个人博客?",1,"安装完毕") = vbOK Then
- CreateObject("WSCript.SHELL").Run("http://hangzhou492.blog.51cto.com")
- End If
复制代码 main.hta的源代码如下:
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <HTML>
- <HEAD>
- <TITLE> New Document </TITLE>
- <hta:application sysmenu=no maximizebutton=no icon=%systemroot%\system32\cmd.exe>
- </HEAD>
- <SCRIPT LANGUAGE="vbscript" src="edit.vbs"></SCRIPT>
- <script language="vbscript">
- </script>
- <BODY onload="VBSCRIPT:bt.value=date()">
- <H2><CENTER><B>写备忘</B></CENTER></H2>
- <CENTER><TABLE>
- <TR>
- <TD><input id=bt type=text size=40></TD>
- </TR>
- <TR>
- <TD><textarea id=zw cols=40 rows=20></textarea></TD>
- </TR>
- </TABLE></CENTER>
- </BODY>
- <center>
- <input type=button value="保存" edit_file(bt.value,zw.value)">
- <input type=button value="关闭" onclick="VBScript:self.close">
- </center>
- </HTML>
复制代码
我已经上传了源代码,安装的时候只要直接运行setup.vbs就可以了,安装的时候程序会在C盘下建立一个文件夹,同时在桌面上创建快捷方式,还有就是杀毒软件可能会报告,应为里面涉及到了添加注册表启动项的代码...
http://hangzhou492.blog.51cto.com/67690/39915 |