Keystroke command to Show All Bookmarks in Safari not working - applescript

I am trying a simple Keystroke command to Show All Bookmarks in Safari 5.0.2 but it is not working -
tell application "Safari" to activate
tell application "System Events"
keystroke "B" using {option down, command down}
end tell
end
Can anyone suggest me where I may be wrong?
Thanks,
Miraaj

Try a little 'b':
tell application "Safari" to activate
tell application "System Events"
keystroke "b" using {option down, command down}
end tell
The big B translates to Shift+B.

Related

How do I make an applescript that switches tabs one to the right

I have tried using the code;
tell application "Google Chrome"
activate
end tell
tell application "System Events"
keystroke 124 using {command down, option down}
end tell
is there anything wrong with this script because command option arrow normally switches tabs
tell application "Google Chrome"
activate
end tell
tell application "System Events"
key code 124 using {command down, option down}
end tell

pressing alt+s key combination using applescipt

how do I tell applescipt to hit alt?
I want to press simultaneously alt+s
This code does not work:
tell application "System Events" to keystroke "s" using alt
Thanks in advance
The answer is
tell application "System Events" to keystroke "s" using option down
or
tell application "System Events" to keystroke "s" using {option down}
You can use the list option if you want to simulate multiple keys like command down/‌control down/‌option down/‌shift down.
Easily found in the scripting dictionary of System Events
Enjoy, Michael / Hamburg

How to make finder run a keyboard shortcut in applescript?

This is my current code:
tell application "Finder"
tell application "System Events" to keystroke "k" using {command down}
end tell
But it won't work.
Any tips?
You do not tell the Finder to tell system events to do stuff.
You need to just make sure the Application that you want to intercept the keystrokes is active. Then tell System events to do the keystroke.
tell application "Finder" to activate
tell application "System Events"
keystroke "k" using {command down}
end tell

Open URL in current tab in Firefox via Applescript

I use this script to open a URL in a new tab but I would like it to open in the current tab instead. Is there a way to do this?
tell application "Firefox"
open location "http://www.yubnub.org"
end tell
Firefox's Applescript support appears not very existent.
Try this workaround using System Events and key strokes.
tell application "Firefox"
activate
set the clipboard to "http://www.yubnub.org"
tell application "System Events"
keystroke "l" using {command down}
keystroke "v" using {command down}
key code 36 -- return key
end tell
end tell
I upvoted the accepted answer, it's great and led me to my solution, but using the clipboard to enter the URL seems unnecessary when you can simply send the URL via keys
tell application "Firefox"
activate
tell application "System Events"
keystroke "l" using {command down}
keystroke "http://www.yubnub.org"
key code 36 -- return key
end tell
end tell
A line shorter, more understandable, and doesn't have the unwanted side effect of overwriting your clipboard.

Applescript click on save button

I got error; Can’t get button "save" of process "TextEdit".
activate application "TextEdit"
tell application "System Events" to tell process "TextEdit"
keystroke "s" using {command down}
click button "save"
end tell
I was also tring to include like "of window 1" still I can't get this working. Any help will be much appreciated. thanks
why not just talk to the app directly ?
tell application "TextEdit"
tell document 1 to save
end tell
if you must use the GUI you need the correct hierarchy ( but it is best to talk to the app directly)
activate application "TextEdit"
tell application "System Events"
tell process "TextEdit"
keystroke "s" using {command down}
delay 1
click button "Save" of sheet 1 of window 1
end tell
end tell

Resources