vbs實現開啟記事本,寫入一些文字,複製然後關閉

2022-01-30 10:41:52 字數 882 閱讀 2126

原來vbs的功能也很強大。現在才發現

dimwshshell, onotepad

setwshshell

=createobject("

wscript.shell")

'建立wscript.shell物件

setonotepad

=wshshell.exec(

"notepad")

'執行記事本

'啟用記事本

wscript.sleep

300wshshell.sendkeys

"cccc

"wscript.sleep

300wshshell.sendkeys

"cccc

"wscript.sleep

300wshshell.sendkeys

"cccc

"wscript.sleep

300wshshell.sendkeys "^a

"'ctrl+a組合鍵——全選

wscript.sleep

200wshshell.sendkeys "^c

"'ctrl+c組合鍵——複製

wscript.sleep

200wshshell.sendkeys "%

"'關閉當前的記事本窗體

wscript.sleep

300wshshell.sendkeys "!n

"'關閉當前的記事本窗體,不儲存

wscript.sleep

200set

onotepad

=nothing

'釋放記憶體

setwshshell

=nothing

C 實現記事本

今天我用c 編了乙個記事本,效果如下 開啟txt openfiledialog1.filter 文字檔案 txt txt if openfiledialog1.showdialog dialogresult.ok 有乙個openfiledialog1元件 儲存txt 檔案不為空才可以儲存if thi...

VBS指令碼教程 寫入記事本檔案及輸出

dim wshshell set wshshell createobject wscript.shell wshshell.run notepad wscript.sleep 1500 wscript.sleep 500 wshshell.sendkeys fs wscript.sleep 500 ...

小型記事本的VB實現

上面是程式執行的介面!程式執行介面已上傳到相簿的vb6欄目 以下就是 vb6的源 依次新增 5個按鈕控制項,乙個 timer 控制項和乙個 microsoftcommondialogcontrol6.0控制項 private sub command1 click 輸入文字 dim n on erro...