开发者

how to keep track of webpage opened

开发者 https://www.devze.com 2023-01-14 00:36 出处:网络
Just wondering if there\'s a way to keep track of what website the user is browsing to via Cocoa or Webkit?

Just wondering if there's a way to keep track of what website the user is browsing to via Cocoa or Webkit?

Sort of like the开发者_运维百科 TrackTime.app?

Thanks


I'm developing a time tracking app without timers called Lapsus.

Mike is correct - the answer lies in the following AppleScript:

tell application "Safari"
    URL of current tab of window 1
end tell   

I'm doing this right now in my app and it works like a charm.

If you're building a Cocoa app as I am, you can execute this with NSAppleScript, the Scripting Bridge or, more ideally, with the Objective C bindings for AppScript.

I check if window 1 exists first, but if you want to run this script as one, you might want to surround it with a @try @catch block to catch any exceptions NSAppleScript throws.


Well this has nothing to do with WebKit. You'd have to use AppleScript or similar to track what Safari's up to. Alternatively, might be able to monitor it's history storage on-disk.

0

精彩评论

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