Jump to content

shainekim

Member
  • Posts

    2
  • Joined

  • Last visited

shainekim's Achievements

Helping Hand

Helping Hand (3/5)

0

Reputation

  1. @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 tell application "Google Chrome" activate open location "https://www.youtube.com" end tell 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 : \ on alfred_script(q) if q is equal to "" then if application "Google Chrome" is running then tell application "Google Chrome" activate make new window open location "https://www.youtube.com" end tell else tell application "Google Chrome" to open location "https://youtube.com" end if else if application "Google Chrome" is running then tell application "Google Chrome" make new window open location "https://www.youtube.com/search?q=" & q end tell else tell application "Google Chrome" to open location "https://youtube.com" & q end if end if end alfred_script 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
  2. 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
×
×
  • Create New...