我有一个70岁的奶奶,不习惯使用电脑,但她有一个电子邮件和Facebook,每次她想访问这些网站,我必须帮助她完成整个过程.所以,我有了一个想法,我知道一些编程,所以我试着做一个批处理文件来自动化这个打开Firefox的过程,键入"www.exemple.com",并登录她的帐户.有了这个,她至少可以看到是否有任何电子邮件或Facebook通知,但我可以只是批量打开电子邮件网站,我想知道是否有任何方法可以登录程序.批处理文件:
ECHO OFF
START FIREFOX "WWW.EXAMPLE.COM" "WWW.EXAMPLE2.COM"
EXIT
Run Code Online (Sandbox Code Playgroud)
小智 8
今天弄清楚了,如果需要,如何在 Windows 计算机上使用批处理文件将键盘命令推送到网站或其他应用程序。有关原始编码信息,请参见此处。
您将在此处找到的命令的核心结果为
@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));
Run Code Online (Sandbox Code Playgroud)
虽然我自己仍在不同应用程序上试验和测试这个批处理文件程序,但我不确定这个程序实际执行的内部工作原理。我所知道的是它使用安装在每台 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));
Run Code Online (Sandbox Code Playgroud)
从而将您的祖母登录到特定网站。虽然这是我尝试运行的代码的粗略近似值,但它应该仍然有效。如果没有,请使用我提供的链接从头开始。此外,如果您需要包含这些特殊字符的方法,请在此处查看。
*编辑:
后来我为自己做了这样的事情,并找到了一种更简单的方法,而不是输入所有那些 %SendKeys%。你可以简单地做
%SendKey% "Username{TAB}"
%SendKey% "Password{ENTER}"
Run Code Online (Sandbox Code Playgroud)
作为通过登录过程的更简单的方式。唯一的缺点是,如果她决定更改她的登录名,您必须在程序中更改她的密码。
这实际上对我有用,我提到了 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));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
62701 次 |
| 最近记录: |