jshin593 Posted February 17, 2016 Share Posted February 17, 2016 Hi, It seems like a basic thing, but, since I have no basis in even basic programming, I came to get some help here. Question What would be the script to open up a new chrome window (instead of the pre-set 'Launch Apps/Files' action in Alfred, which would toggle an already opened chrome window, if there is one)? Thanks in advance for those who can help. Link to comment
rice.shawn Posted February 18, 2016 Share Posted February 18, 2016 In the workflow, set it to Bash and have the command be: osascript activate.scpt "<INSERT URL HERE>" Create a file called "activate.scpt" and place it in the root of the workflow directory. on run argv set theUrl to item 1 of argv tell application "Google Chrome" if (count every window) = 0 then make new window end if set found to false set theTabIndex to -1 set theWindowIndex to 0 repeat with theWindow in every window set theWindowIndex to theWindowIndex + 1 set theTabIndex to 0 repeat with theTab in every tab of theWindow set theTabIndex to theTabIndex + 1 if the URL of theTab contains theUrl then set found to true exit repeat end if end repeat if found then exit repeat end if end repeat if found then set theWindow's active tab index to theTabIndex activate window theWindow tell application "System Events" to tell process "Google Chrome" delay 1 perform action "AXRaise" of window theWindowIndex end tell set the index of theWindow to 1 else tell window 1 to make new tab with properties {URL:theUrl} end if end tell end run This gets you there. It sometimes doesn't bring up the main window if multiple ones are there. I just haven't had time to debug it. Link to comment
jshin593 Posted February 26, 2016 Author Share Posted February 26, 2016 (edited) The other day, I've asked the same question and Shawn has made a reply for me thankfully, but, I couldn't quite get it. The usual actions that I wish to make into workflow are 1) Move a mouse cursor to the Chrome icon in the Dock, 2) Right click the Chrome icon, and 3) Select the New Window menu. Does anyone have idea on how to make the above actions into a single workflow and a script? I would really appreciate your help. Best regards, DJ Edited February 26, 2016 by jshin593 Link to comment
Vero Posted February 28, 2016 Share Posted February 28, 2016 The other day, I've asked the same question and Shawn has made a reply for me thankfully, but, I couldn't quite get it. Hi there, I've merged your question back with your original thread, as there's no benefit in starting a whole new thread, which clutters up the forum. If you're having issues with Shawn's advice, ask your further questions here to get help Cheers, Vero Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now