自动打开浏览器并登录网站?

时间:2015-04-02 00:59:54

标签: batch-file

我有一个70岁的奶奶,不习惯使用电脑,但她有一个电子邮件和Facebook,每次她想访问这些网站,我必须帮助她完成整个过程。所以,我有了一个想法,我知道一些编程,所以我试着做一个批处理文件来自动化这个打开Firefox的过程,键入" www.exemple.com",并登录她的帐户。有了这个,她至少可以看看是否有任何电子邮件或Facebook通知,但我可以只批量打开电子邮件网站,我想知道是否有办法登录程序。 批处理文件:

ECHO OFF
START FIREFOX "WWW.EXAMPLE.COM" "WWW.EXAMPLE2.COM"
EXIT

2 个答案:

答案 0 :(得分:3)

今天想出来,如何在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}"

作为一种更简单的方式来完成登录过程。任何这一点的唯一缺点是,如果她决定更改登录,您将不得不在程序中更改她的密码。

答案 1 :(得分:2)

这实际上对我有用,我参考了jouster500的答案,几乎没有我纠正的错误,就像一个护身符。

@if (@CodeSection == @Batch) @then


@echo off

rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
START CHROME "https://login.classy.org/"
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 10
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.
rem %SendKeys% "{TAB}"
rem now you can have it send the actual username/password to input box
%SendKeys% "{TAB}"
%SendKeys% "{TAB}"
%SendKeys% "username"
%SendKeys% "{TAB}"
%SendKeys% "password"
%SendKeys% "{ENTER}"

goto :EOF

@end
// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
相关问题