Sanket Tagalpallewar
Sanket Tagalpallewar

Reputation: 133

How to programmatically open Safari->preferences pane

I m working on safari plugin. I have added some Qt code in it. Now I want to open "safari->preferences" pane when user clicks on QPushButton on my Qt dialog. If it is possible in Objective-C also, please tell me.

Upvotes: 3

Views: 1333

Answers (2)

Sanket Tagalpallewar
Sanket Tagalpallewar

Reputation: 133

Finally I got it. Here is my solution:

tell application "Safari" to activate

delay 4

tell application "System Events" to tell process "Safari"

    keystroke "," using command down

    tell window 1
        click button "Extensions" of tool bar 1
        activate "Extensions"
        keystroke return
    end tell
end tell

Using this AppleScript we can open Safari->Preferences programatically.

Upvotes: 5

Daij-Djan
Daij-Djan

Reputation: 50129

I dont know a direct api.

write an apple script and use ui scripting to tell safari 1) to open 2) to select the menuitem preferences (maybe even send key stroke cmd+,)

some script like:

tell application "System Events"
tell process "Safari"
tell menu bar 1
tell menu bar item "Safari"
tell menu "Safari"
click menu item "Preferences..."
end tell
end tell
end tell
end tell

Upvotes: 0

Related Questions