如何从Safari浏览器获取网址 [英] How to get URL from Safari browser

查看:602
本文介绍了如何从Safari浏览器获取网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从C#访问Safari浏览器来获得当前的网址是什么?

How can I access the Safari browser from C# to get the current URL?

推荐答案

这不正是最好的答案,但我已经通过将焦点转移到Safari浏览器窗口,然后使用的SendKeys发送CTRL + L做到了这一点它选择的地址栏,CTRL + C这copys的内容复制到剪贴板。然后抓住剪贴板中的内容,并将其保存为一个字符串,也可以将其保存到字符串列表,并把焦点回到窗口,Ctrl + Tab键,重复上述过程。当然,这要求你允许该程序完成其工作,你也可以把它放到一个轻微的延迟在循环迭代之间。的SendKeys并不是一个很好的解决方案,但如果你允许足够的延迟,并规定对循环的每个迭代激活对焦它的工作。除此之外,有可能是,可以使用常规的前pressions解析的会话的文件

It's not exactly the best answer, but I've accomplished this by bringing focus to the safari window, and then using SendKeys to send a "Ctrl + l" which selects the URL Bar, "Ctrl + C" which copys the contents to the clipboard. Then grab the contents of the clipboard and save it to a string, or you can save it to a list of strings, and bring focus back to the window, "Ctrl + Tab" , Repeat above process. This would of course require that you allow the program to do its job, and you may also want to put a slight delay in between iterations of that loop. SendKeys is not a good solution, but it does work if you allow for sufficient delay and provision for activating focus on each iteration of the loop. Other than that, there may be a sessions file that can be parsed using regular expressions

这篇关于如何从Safari浏览器获取网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆