shainekim
-
Posts
2 -
Joined
-
Last visited
Content Type
Blogs
Gallery
Downloads
Events
Profiles
Forums
Articles
Media Demo
Posts posted by shainekim
-
-
Hi guys, I recently bought Alfred and trying to make a workflow of my taste, but I'm having a real hard time. I'm new to programming in general, but I'm trying my best so any help would be appreciated!
Here's my Goal: I want to create a workflow that is triggered by a key word, with optional arguments, so that when there are no argument, a specific (not the default) browser to open a specific (not the homepage) URL, in a new window regardless the web browser app is running or not. When provided with an argument, I want to search for the argument. So for example, if I type "yy" , then Chrome opens Youtube in a new window, and if I type "yy alfred" then Chrome does a search on alfred on Youtube.
The first issue I ran into was that when apps are not running in the background and are activated, if I activate the app and give it an URL, I get 2 new windows. I looked it up and I did fix it (I think).
The real problem is that I cannot find how to retrieve? import? the argument as {query} and search for the argument. I've tried what the default web search does on alfred, but no luck at all. Here's my script
on alfred_script(q) if q is equal to "" then if application "Google Chrome" is running then run script "tell application \"Google Chrome\" activate open location \"https://www.youtube.com\" end tell" else set theApp to quoted form of "Google Chrome" do shell script "open -n -a " &theApp & " 'https://www.youtube.com'" end if else set query to q if application "Google Chrome" is running then run script "tell application \"Google Chrome\" activate open location \"https://www.youtube.com/search?q={query}\" end tell" else set theApp to quoted form of "Google Chrome" do shell script "open -n -a " &theApp & " 'https://youtube.com/search?q={query}'" end if end if end alfred_script
I'd love some hints on how I can make my workflow work! Thanks
I'm trying to create a workflow to do custom web browsing
in Workflow Help & Questions
Posted
@GuiB
Thanks for the simple example! One thing is that I want to open the search in a new window, instead of a new tab. That's why I started to use applescript in the first place. Is there a way to improve your example so that it does that?
@deanishe
Thanks, I appreciate your help!
The purpose is to make sure my workflow opens a new window, both when the app is running and not running. If I execute
when the app is not running, (running it for the first time after reboot), it then activates a new window on the homepage, and another window on Youtube. That's why I decided to put
that do shell line. But after your help, I changed my script around, and here's my result : \
I think I'm almost done here, the only problem is
1. if used q quoted form of q, then youtube searches for the actual quoted form of what I've typed in. So if I search apple, it searches for 'apple'
2. if i don't use quoted form of q, then I can't search for multiple words!
Oh, and I have no idea where to upload my workflow, I did save it as a file.
I really feel like I'm bugging you guys out with something not important at all, I really appreciate your help thanks