我有一个名为 DVRJavaView.jar 的 DVR 程序。程序打开,请求 IP 地址,按 Enter 键,插入用户名,按 Tab 键,输入密码,按 Enter 键。我找到了一个讨论这个问题的网站,其中包含代码,但是,它是用 applescript 编写的,而我使用的是 Windows。
讨论可以在这里找到:https://discussions.apple.com/message/16253980#16253980
这是苹果脚本:
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。我不相信bat文件可以实现这样的事情,但我可能是错的。
如有任何帮助,我们将不胜感激。
谢谢!
最佳答案
您肯定需要对此进行调整,但这是基本思想:
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}"
关于java - 用于打开 Java 应用程序并插入文本的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21583339/