HanneMaes Posted June 15, 2020 Share Posted June 15, 2020 I have a few workflows to open specific url's on my macbook. When the browser app has no open windows, the workflow open the correct url but also opens a second windows with the default startpage. Is there a way I can counter this? When the browser already has an open windows everything works fine. Link to comment
deanishe Posted June 15, 2020 Share Posted June 15, 2020 Hi @HanneMaes, welcome to the forum. Assuming you're using Alfred's own Open URL action, this is something the browser is doing itself. It might be possible to write a custom AppleScript that prevents that behaviour, but that would depend on which browser you're using. When you have a question about an application's behaviour, please always mention which application you're talking about. Link to comment
HanneMaes Posted June 15, 2020 Author Share Posted June 15, 2020 Firefox is set as my default browser, in Chrome I don't have the problem. So I guess it's a Firefox issue? Link to comment
vitor Posted June 15, 2020 Share Posted June 15, 2020 8 hours ago, HanneMaes said: So I guess it's a Firefox issue? Appears so. And you can’t use AppleScript to fix it because Firefox doesn‘t support it. You should be able to verify it’s indeed Firefox’s issue by opening a terminal and (assuming it’s your default browser) running open 'https://example.com'. After verification, you should go to Mozilla’s bug reporter, see if the issue is already reported, and report it if it isn’t. Until it’s fixed (which may never happen), try going around the problem. If the issue doesn’t occur when a browser window is already open, open it yourself with a Launch Apps and Files Action before opening the URL. Link to comment
HanneMaes Posted June 17, 2020 Author Share Posted June 17, 2020 I reported the bug. But the workaround isn't working. I'll keep looking for a new workaround. Thanks for the help! Link to comment
deanishe Posted June 17, 2020 Share Posted June 17, 2020 (edited) 3 hours ago, HanneMaes said: But the workaround isn't working. I'll keep looking for a new workaround. You'll need to add a long enough delay for Firefox to open before opening the URL. If it doesn't have a window open, it will open the extra empty window. Because you don’t want to be waiting a few seconds when Firefox is running, you can use this AppleScript to open your URL: property _delay_after_launch : 3 on is_running(_name) tell application "System Events" to return count of (processes whose name is _name) end is_running on run (argv) set _url to first item of argv set _running to is_running("Firefox") log "_running=" & (_running as text) if _running = 0 then activate application "Firefox" delay _delay_after_launch end if tell application "Firefox" to open location _url end run Put it in a Run Script action with Language = "/usr/bin/osascript (AS)" and "with input as argv", then use it instead of the Open URL action (and Launch Apps and Files). Edited June 17, 2020 by deanishe Link to comment
vitor Posted June 17, 2020 Share Posted June 17, 2020 Quote on is_running(_name) tell application "System Events" to return count of (processes whose name is _name) end is_running Why not application "Firefox" is running (returns true of false) instead? Link to comment
deanishe Posted June 17, 2020 Share Posted June 17, 2020 (edited) 2 hours ago, vitor said: Why not application "Firefox" is running (returns true of false) instead? Habit, I guess. I just always avoid passing a variable to application because it historically has often not worked. Edited June 17, 2020 by deanishe Link to comment
HanneMaes Posted June 18, 2020 Author Share Posted June 18, 2020 Thanks for the script! But I can't get it working. The workflow opens Firefox but keeps it minimized, and when I open Firefox it opens the startpage only? I now have just the Run script action, I deleted the open Url action. With this code property _delay_after_launch : 3 on is_running(_name) tell application "System Events" to return count of (processes whose name is _name) end is_running on run (argv) set _url to first item of argv set _running to is_running("Firefox") log "_running=" & (_running as text) if _running = 0 then activate application "Firefox" delay _delay_after_launch end if tell application "Firefox" to open https://www.blender.org/ end run Link to comment
deanishe Posted June 18, 2020 Share Posted June 18, 2020 (edited) 2 hours ago, HanneMaes said: With this code Your code is invalid. Alfred is doubtless printing an error message in its debugger, which you should always check when something isn't working. The command is open location, not open (that’s for local files), and you need to put the URL in quotation marks: tell application "Firefox" to open location "https://www.blender.org" Edited June 18, 2020 by deanishe Link to comment
HanneMaes Posted July 9, 2020 Author Share Posted July 9, 2020 Still can't get it to work. I get this error /Users/hannemaes/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/1A04F040-6513-45A3-B5C8-3DA9A874F533:196:206: execution error: Can’t get item 1 of {}. (-1728) And I have this code: property _delay_after_launch : 3 on is_running(_name) tell application "System Events" to return count of (processes whose name is _name) end is_running on run (argv) set _url to first item of argv set _running to is_running("Firefox") log "_running=" & (_running as text) if _running = 0 then activate application "Firefox" delay _delay_after_launch end if tell application "Firefox" to open location "https://www.blender.org" end run Link to comment
deanishe Posted July 9, 2020 Share Posted July 9, 2020 2 hours ago, HanneMaes said: Can’t get item 1 of {}. (-1728) Here: 2 hours ago, HanneMaes said: on run (argv) set _url to first item of argv The script I gave you expects you to pass in the URL to open from a previous workflow element. Link to comment
Nox974 Posted October 2, 2020 Share Posted October 2, 2020 Hey , Does it work now for you ? I nhave the same problem with firefox and brave but not safari. At forst it was working and now since I started configure alfred, install some workflow I get this error. I'm still trying to figure it out. 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