2016-07-09 1 views
-2

これはStackoverflowの最初の投稿です。私はどのように起動するのか分からないが、ここでは 私の質問です:私は、RPGゲームを使用してvbscriptを使用しています。私はメモ帳 を使用していますが、文字は、このような一つ一つ表示されました:vbscriptを使って、メモ帳に文字を1つずつ表示させる方法

Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "notepad.exe", 3 
WshShell.SendKeys ". L" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys "t'" 
WScript.Sleep(100) 
WshShell.SendKeys "s" 
WScript.Sleep(100) 
WshShell.SendKeys " m" 
WScript.Sleep(100) 
WshShell.SendKeys "a" 
WScript.Sleep(100) 
WshShell.SendKeys "k" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys " a" 
WScript.Sleep(100) 
WshShell.SendKeys "n" 
WScript.Sleep(100) 
WshShell.SendKeys " e" 
WScript.Sleep(100) 
WshShell.SendKeys "x" 
WScript.Sleep(100) 
WshShell.SendKeys "a" 
WScript.Sleep(100) 
WshShell.SendKeys "m" 
WScript.Sleep(100) 
WshShell.SendKeys "p" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys "e:" 
WScript.Sleep(100) 
WshShell.SendKeys "{ENTER}" 
WshShell.SendKeys "{ENTER}" 
WScript.Sleep(100) 
WshShell.SendKeys "Y" 
WScript.Sleep(100) 
WshShell.SendKeys "o" 
WScript.Sleep(100) 
WshShell.SendKeys "u" 
WScript.Sleep(100) 
WshShell.SendKeys " a" 
WScript.Sleep(100) 
WshShell.SendKeys "r" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys " i" 
WScript.Sleep(100) 
WshShell.SendKeys "n" 
WScript.Sleep(100) 
WshShell.SendKeys " a " 
WScript.Sleep(100) 
WshShell.SendKeys "f" 
WScript.Sleep(100) 
WshShell.SendKeys "o" 
WScript.Sleep(100) 
WshShell.SendKeys "r" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys "s" 
WScript.Sleep(100) 
WshShell.SendKeys "t" 
WScript.Sleep(100) 
WshShell.SendKeys " w" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "t" 
WScript.Sleep(100) 
WshShell.SendKeys "h" 
WScript.Sleep(100) 
WshShell.SendKeys " l" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "m" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "t" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys "d" 
WScript.Sleep(100) 
WshShell.SendKeys " r" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys "s" 
WScript.Sleep(100) 
WshShell.SendKeys "o" 
WScript.Sleep(100) 
WshShell.SendKeys "u" 
WScript.Sleep(100) 
WshShell.SendKeys "r" 
WScript.Sleep(100) 
WshShell.SendKeys "c" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys "s." 
WScript.Sleep(100) 
WshShell.SendKeys " W" 
WScript.Sleep(100) 
WshShell.SendKeys "h" 
WScript.Sleep(100) 
WshShell.SendKeys "a" 
WScript.Sleep(100) 
WshShell.SendKeys "t" 
WScript.Sleep(100) 
WshShell.SendKeys " w" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys " y" 
WScript.Sleep(100) 
WshShell.SendKeys "o" 
WScript.Sleep(100) 
WshShell.SendKeys "u" 
WScript.Sleep(100) 
WshShell.SendKeys " d" 
WScript.Sleep(100) 
WshShell.SendKeys "o?" 
WScript.Sleep(100) 
WshShell.SendKeys "{ENTER}" 
WshShell.SendKeys "{ENTER}" 
WshShell.SendKeys "1-" 
WScript.Sleep(100) 
WshShell.SendKeys "I" 
WScript.Sleep(100) 
WshShell.SendKeys " w" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys " t" 
WScript.Sleep(100) 
WshShell.SendKeys "r" 
WScript.Sleep(100) 
WshShell.SendKeys "y" 
WScript.Sleep(100) 
WshShell.SendKeys " t" 
WScript.Sleep(100) 
WshShell.SendKeys "o" 
WScript.Sleep(100) 
WshShell.SendKeys " f" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "n" 
WScript.Sleep(100) 
WshShell.SendKeys "d" 
WScript.Sleep(100) 
WshShell.SendKeys " s" 
WScript.Sleep(100) 
WshShell.SendKeys "o" 
WScript.Sleep(100) 
WshShell.SendKeys "m" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys " r" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys "s" 
WScript.Sleep(100) 
WshShell.SendKeys "o" 
WScript.Sleep(100) 
WshShell.SendKeys "u" 
WScript.Sleep(100) 
WshShell.SendKeys "r" 
WScript.Sleep(100) 
WshShell.SendKeys "c" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys "s." 
WScript.Sleep(100) 
WshShell.SendKeys "{ENTER}" 
WshShell.SendKeys "{ENTER}" 
WshShell.SendKeys "2-" 
WScript.Sleep(100) 
WshShell.SendKeys "I" 
WScript.Sleep(100) 
WshShell.SendKeys " w" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys " b" 
WScript.Sleep(100) 
WshShell.SendKeys "u" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys "d" 
WScript.Sleep(100) 
WshShell.SendKeys " a " 
WScript.Sleep(100) 
WshShell.SendKeys "s" 
WScript.Sleep(100) 
WshShell.SendKeys "m" 
WScript.Sleep(100) 
WshShell.SendKeys "a" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys "l" 
WScript.Sleep(100) 
WshShell.SendKeys " h" 
WScript.Sleep(100) 
WshShell.SendKeys "o" 
WScript.Sleep(100) 
WshShell.SendKeys "u" 
WScript.Sleep(100) 
WshShell.SendKeys "s" 
WScript.Sleep(100) 
WshShell.SendKeys "e" 
WScript.Sleep(100) 
WshShell.SendKeys " w" 
WScript.Sleep(100) 
WshShell.SendKeys "i" 
WScript.Sleep(100) 
WshShell.SendKeys "t" 
WScript.Sleep(100) 
WshShell.SendKeys "h" 
WScript.Sleep(100) 
WshShell.SendKeys " m" 
WScript.Sleep(100) 
WshShell.SendKeys "y" 

これは素晴らしい作品が、それはそんなに時間がかかるです。だから、どうすれば同じことを行うことができます多くの行なしで 。

注:コーディングがわからないので、基本について説明することができます。

+2

やり直して、SendKeysを使ってメモ帳にテキストを挿入しないでください。代わりにコンソールプログラムを作ることができます。 – crashmstr

+0

@crashmstr世界初のメモ帳RPGを作成しない限り、その目的はありますか? ; p – Lankymart

答えて

0

疑問がある場合は、 SendKeys Method

スペースを送信するには、文字列 ""を送信します。 SendKeysを使用して、一度に複数のキーストロークを送信することができます()。これを行うには、 シーケンスの各キーストロークを の前に追加することによって、 キーストロークシーケンスを表す複合文字列引数を作成します。たとえば、キーストロークa、b、およびcを送信するには、 文字列引数 "abc"を送信します。

Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "notepad.exe", 3 
WScript.Sleep 500   ' give Notepad enough time to start and activate its window 
WshShell.SendKeys ". Let's make an example" 
WScript.Sleep 500 
+0

それは各キーストロークを遅らせますか、それが起動した分メモ帳にすべてのテキストを書きますか? – Lankymart

0

あなたは、このコードで遊ぶことができます:)

Set Ws = CreateObject("WScript.Shell") 
Ws.run "Notepad.exe" 
wscript.sleep 1000 
ws.AppActivate "Notepad" 
Msg = "HELLO !"& vbCRLF &_ 
"I'M WRITING RIGHT NOW THIS SPECIAL MESSAGE FOR YOU Letter by Letter !"& vbCRLF &_ 
"Good luck and Good bye from Hackoo !" 

For x = 1 To Len(Msg) 
    WScript.Sleep 100 
    Ws.SendKeys Mid(Msg,x,1) 
    WScript.Sleep 100 
Next 

Call SpeakVoice(Msg) 

'--SpeakVoice-- 
Function SpeakVoice(msg) 
Dim voice 
Set Voice=CreateObject("SAPI.SpVoice") 
voice.speak msg 
end Function 
+0

私は 'Else'が重複したコードとは別に何をしているのか分かりません。 – Lankymart

+0

@Lankymart私は私の答えを編集する! – Hackoo

+0

'SpeakVoice()'部分は、OPのオリジナルの質問に関連していますか? – Lankymart

0

わかりましたみんなに感謝しそう!私は自分のためにプログラムを作りました!誰かが文字を1つ1つvbscriptを使って表示したい場合は、ここにプログラムがあります。download

関連する問題