open any url in popup Safari window

346 views
Skip to first unread message

Ahmad AlTwaijiry

unread,
Sep 23, 2014, 1:21:08 AM9/23/14
to blacktree-...@googlegroups.com
Hello Everyone

This is a small applescript that I found and I would like to share it with you

function: open any url in popup Safari window and pass any text in QA 1st panel 

This is an action script with QS you can modify it 

using terms from application "Quicksilver"

on process text query

tell application "Safari"

activate

make new document with properties {URL:" https://example.com/?q=" & query & "&ZZ=1"}

do JavaScript ("self.resizeTo(500,480);") in document 1

end tell

end process text

end using terms from


Lisa Brown

unread,
Feb 7, 2015, 2:07:56 AM2/7/15
to blacktree-...@googlegroups.com
Is there any way to use Quicksilver to open a URL in a new window instead of a new tab? I have my Safari preference set to "Automatically" open new tabs instead of new windows. When I use the previous script with a Quicksilver trigger, it opens the URL in a new tab. If I put only these two lines in a script:

tell application "Safari"

activate

make new document with properties {URL:""}

end tell



And then if I run the script from Script Editor, the URL opens in a new window only. If I run it from Quicksilver, the URL opens in a new tab and a new window. There's something about how Quicksilver handles URLs that always makes them open in tabs (when Safari is set to automatic tabs). Does anyone know a way around this?

Regards,
Lisa

Rob McBroom

unread,
Feb 7, 2015, 11:17:45 AM2/7/15
to blacktree-...@googlegroups.com

On 7 Feb 2015, at 1:07, Lisa Brown wrote:

Is there any way to use Quicksilver to open a URL in a new window instead of a new tab?

Quicksilver doesn’t do anything special. It just tells OS X to open the URL, and the behavior is determined by the OS and browser from there.

If I run it from Quicksilver, the URL opens in a new tab and a new window.

Can’t explain that. What do you mean by “run it from Quicksilver”? As text in the first pane using the “Run as AppleScript” action? Saving it to a file and using Quicksilver to run that?

I tried both, and just got the URL in a new window.

If you can figure out something that works, you can make your own “Open URL in new window” action using AppleScript and put it in ~/Library/Application Support/Quicksilver/Actions.

--
Rob McBroom
http://www.skurfer.com/

Lisa Brown

unread,
Feb 7, 2015, 3:23:17 PM2/7/15
to blacktree-...@googlegroups.com
Hi Rob,

Thanks for your reply. I'm using Safari 8.0.3 with Mac OS X Yosemite 10.10.2. In Safari Preferences > Tabs, I have "Open pages in tabs instead of windows" set to "Automatically".

When I said "run in Quicksilver", I was creating a HotKey in Quicksilver to run the script, and then I was typing the HotKey.

After restarting my system, it seems to be working now. It's not opening the URL in both a new tab and window, just a new window.

There is a caveat, however: If I am in a different space/desktop from the main Safari app, the new window opens in the current space, but I am moved to the space where the other Safari windows are located. This is a little inconvenient. If I run the script from within Script Editor (by pressing the play button when the script is open), the new window opens in the current space, and I stay in the current space. The simplest way to fix the issue was to assign Safari to a single space. When I use my Quicksilver HotKey to run the script, now I am moved to the space that is assigned to Safari, the new window opens in that space, and it gets the focus.

The script I'm using is this simplified one (with google as an example webpage):

tell application "Safari"

activate

make new document with properties {URL:"http://www.google.com"}

end tell


If I wanted to have different Safari windows open in different spaces, and I did not want to get automatically moved to a different space when I use a Quicksilver HotKey to run this script, could I add another line of code to ensure that I stay in the current space? (I know the spaces feature in OS X has been a bit finicky since it was first introduced, so I wouldn't be surprised if this is unavoidable.)

Regards,
Lisa


Lisa



--
You received this message because you are subscribed to a topic in the Google Groups "Quicksilver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blacktree-quicksilver/GRYHOfZq0Ro/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blacktree-quicks...@googlegroups.com.
To post to this group, send email to blacktree-...@googlegroups.com.
Visit this group at http://groups.google.com/group/blacktree-quicksilver.
For more options, visit https://groups.google.com/d/optout.

Rob McBroom

unread,
Feb 8, 2015, 1:30:56 PM2/8/15
to blacktree-...@googlegroups.com
On 7 Feb 2015, at 14:22, Lisa Brown wrote:

> There is a caveat, however: If I am in a different space/desktop from
> the main Safari app, the new window opens in the current space, but I
> am moved to the space where the other Safari windows are located.

Probably because the script tells Safari to activate first, which will
focus whatever’s currently open. You could try reversing the two
commands, so it opens the URL first, then activates. Or just take
“activate” out altogether and see what happens. You might not even
need it.

If that doesn’t work, I’m sure there’s some AppleScript way to
select the new window, but I don’t use AppleScript so I can’t be
specific.

Lisa Brown

unread,
Feb 8, 2015, 1:59:01 PM2/8/15
to blacktree-...@googlegroups.com
It worked! Reversing the commands does the trick:

tell application "Safari"

make new document with properties {URL:"http://www.google.com"}

        activate

end tell


Now even if Safari is not assigned to a certain space, everything works as it should when using the Quicksilver HotKey. The new window with the URL opens in the current space, I stay in the current space, and the window gets the focus. If I leave the activate command out altogether, the window with the new URL does open, but it does not get the focus.

Thanks for your help!

Regards,
Lisa


Lisa



--
You received this message because you are subscribed to a topic in the Google Groups "Quicksilver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blacktree-quicksilver/GRYHOfZq0Ro/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blacktree-quicksilver+unsub...@googlegroups.com.
To post to this group, send email to blacktree-quicksilver@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages