문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top