今天想通了这一点,我们可以如何使用Windows计算机上的批处理文件,如果需要推键盘命令,网站或其他应用程序。有关原始编码信息,请参阅here。
的命令,你会发现这里的核心只是结果
@if (@CodeSection == @Batch) @then
@echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
%SendKeys% "{ENTER}"
goto :EOF
@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
虽然我本人还是试验和测试不同的应用这个批处理文件的程序,我不知道作为内部运作这个程序实际上做了什么。我只知道它使用安装在每台Windows计算机上的java脚本来推动键盘命令的执行。然而在我的实验中,我发现它也可以作为填写密码和用户名的一种手段。
@if (@CodeSection == @Batch) @then
@echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
START FIREFOX "WWW.EXAMPLE.COM"
rem the script only works if the application in question is the active window. Set a timer to wait for it to load!
timeout /t 5
rem use the tab key to move the cursor to the login and password inputs. Most htmls interact nicely with the tab key being pressed to access quick links.
%SendKeys% "{TAB}"
rem now you can have it send the actual username/password to input box
%SendKeys% "{U}"
%SendKeys% "{s}"
%SendKeys% "{E}"
%SendKeys% "{r}"
%SendKeys% "{N}"
%SendKeys% "{a}"
%SendKeys% "{M}"
%SendKeys% "{e}"
%SendKeys% "{TAB}"
%SendKeys% "{P}"
%SendKeys% "{4}"
%SendKeys% "{S}"
%SendKeys% "{S}"
%SendKeys% "{W}"
%SendKeys% "{O}"
%SendKeys% "{R}"
%SendKeys% "{D}"
%SendKeys% "{ENTER}"
goto :EOF
@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
因此记录你的祖母到特定的网站。虽然这是我试图运行的代码的粗略近似值,但它仍然可以工作。如果不是,请从我提供的链接重新开始。另外,如果您需要包含这些特殊字符的方法,请检查here。
*编辑:
后来我做这样的事情我自己,发现一个简单的方法,而不是打字了所有%的SendKeys%。你可以简单地做
%SendKey% "Username{TAB}"
%SendKey% "Password{ENTER}"
为通过登录过程会更加简单的方法。唯一的缺点是,如果她决定更改登录名,则必须在程序中更改密码。
你不需要。只需设置主页,然后将其放入启动。 – SLaks 2015-04-02 01:02:29
[自动通过批处理文件登录到Windows 7/Chrome上的网站]可能的重复(http://stackoverflow.com/questions/14204623/automatic-login-to-a-website-on-windows-7-chrome-通过批处理文件) – SomethingDark 2015-04-02 01:06:25
我知道还有其他方式的人,但我想要做一个程序,这对她来说会更容易。而且,有时我母亲的电子邮件已登录,我必须注销才能与她联系。对她来说这很复杂,我只想做一个“输入我的电子邮件”程序,这样她就不必担心这些情况。 – 2015-04-02 01:07:36