使用 C# 或 PowerShell 在“连接到 ServerName”中自动输入用户名和密码对话框
我有一个网页,要求用户在“连接到“服务器名称””对话框中输入其凭据,然后单击“确定”。我想使用 C# 或 PowerShell 自动执行此登录过程。这可能吗?如果没有,是否有另一种方法可以实现自动化?
I have a webpage that requires users to enter their credentials in a 'Connect to "ServerName"' dialog box and click OK. I want to automate this login proccess using C# or PowerShell. Is this possible? If not, is there another way of automating this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您正在尝试自动执行网页,而该弹出窗口阻止您执行此操作,如果是这种情况,您可以使用 SendKeys 在框中键入 此外,
由调度程序任务触发的宏记录器也可以执行此操作。
您还可以通过 C# 应用程序传递 credentials ,这将导致您得到相同的结果...
问候
Looks like you are trying to execute the webpage automatically and that popup is blocking you from doing that, if that the case you can use SendKeys to type in the boxes
Also a macro recorder being fired by a scheduler task will do it.
you can also instead of trying to open the webpage make a WebRequest from a C# application passing the credentials , that will lead you to the same results...
regards
这是可能的,但使用 AutoHotkey 可能要容易得多。
可以编写脚本来监视特定名称的窗口,然后自动将击键发送到该窗口。或者,您可以设置脚本,以便用户只需按该窗口中的某个键或一系列键,它就会转换为一组击键。
下载的内容还包括一个编译器,因此一旦您获得正确的脚本,您就可以将其编译为 .exe 进行分发。
It is possible, but it is probably far easier to use AutoHotkey.
It can be scripted to watch for a window of a certain name and then send keystrokes to that window automatically. Alternatively, you can set up the script so that the user just has to press some key or series of keys in that window and it will be converted to a set of keystrokes.
The download also includes a compiler, so once you get your script right you can compile it to an .exe to distribute.