开发者

How to get URL from Safari browser

开发者 https://www.devze.com 2023-01-11 07:37 出处:网络
How can I access the Safari browser from C# to get the current开发者_高级运维 URL?It\'s not exactly the best answer, but I\'ve accomplished this by bringing focus to the safari window, and then using

How can I access the Safari browser from C# to get the current开发者_高级运维 URL?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消