2014-02-05 24 views
0

我有一個名爲DVRJavaView.jar的DVR的程序。程序打開,請求IP地址,按回車鍵,插入用戶名,按Tab鍵,輸入密碼,按回車鍵。我發現一個網站討論這個包含代碼的問題,然而,它是用applescript編寫的,而且我正在使用Windows。腳本打開java應用程序並插入文本

的討論在這裏找到:https://discussions.apple.com/message/16253980#16253980

這是AppleScript的:

on run 
do shell script "/usr/bin/open '/Applications/DVRJavaView4.1.jar'" 

tell application "System Events" to tell (first process whose frontmost is true) 
     repeat until exists window "Please Input DVR address" 
      delay 1 
     end repeat 
     keystroke "millapt.ddns.specoddns.net" 
     keystroke return 
     repeat until exists button "OK" of window 1 
      delay 1 -- wait until the login window is frontmost 
     end repeat 
     keystroke "user" 
     keystroke tab 
     delay 0.1 
     keystroke "4321" 
     delay 0.1 
     keystroke return 
     repeat until name of window 1 starts with "DVRJavaView" 
      delay 1 --wait while the login window is frontmost 
     end repeat 
     click button 2 of window 1 -- zoom 
end tell 
end run 

我不是很見地有關編程,但願意學習。

是否有任何方向可以幫助我在Windows環境中實現這個腳本?我不確定我是否應該使用VB或Javascript。我不相信蝙蝠文件可以實現這樣的事情,但我可能是錯的。

任何幫助,將不勝感激。

謝謝!

回答

1

你肯定是要調整這一點,但是這是基本的想法:

Set objShell = WScript.CreateObject("WScript.Shell") 
objShell.Run "C:\Program Files\Java\jre[version number]\bin\java.exe C:\DVRJavaView4.1.jar" 
Do Until Success = True 
    Success = objShell.AppActivate("java") 
    Wscript.Sleep 1000 
Loop 
objShell.SendKeys "millapt.ddns.specoddns.net" 
objShell.SendKeys "{ENTER}" 
Wscript.Sleep 1000 
objShell.SendKeys "user" 
objShell.SendKeys "{TAB}" 
Wscript.Sleep 1000 
objShell.SendKeys "4321" 
objShell.SendKeys "{ENTER}" 
Wscript.Sleep 1000 
objShell.SendKeys "{ENTER}" 
+1

太感謝你了!我拿了你的代碼,做了一點研究,並且能夠修改它以便100%工作。 – user3276164

+0

聽到這真是太棒了!您應該在此重新發布您的工作代碼,以便其他人可以使用它。您可以點擊我的帖子下方的「修改」並更新它,以便其他人可以從您的更改中學習。 –