vbs实现打开记事本,写入一些文字,复制然后关闭

原来vbs的功能也很强大。现在才发现
  
    
Dim WshShell, oNotepad
Set WshShell = CreateObject ( " WScript.Shell " ) ' 创建WScript.Shell对象
Set oNotepad = WshShell.Exec( " notepad " ) ' 运行记事本
WshShell.AppActivate oNotepad.ProcessID ' 激活记事本
WScript.Sleep 300
WshShell.SendKeys
" CCCC "
WScript.Sleep
300
WshShell.SendKeys
" CCCC "
WScript.Sleep
300
WshShell.SendKeys
" CCCC "
WScript.Sleep
300
WshShell.SendKeys
" ^a " ' CTRL+A组合键——全选
WScript.Sleep 200
WshShell.SendKeys
" ^c " ' CTRL+C组合键——复制
WScript.Sleep 200
WshShell.SendKeys
" %{F4} " ' 关闭当前的记事本窗体
WScript.Sleep 300
WshShell.SendKeys
" !n " ' 关闭当前的记事本窗体,不保存
WScript.Sleep 200
Set oNotepad = Nothing ' 释放内存
Set WshShell = Nothing

你可能感兴趣的:(vbs)