Jump to content

Subject22

Member
  • Posts

    171
  • Joined

  • Last visited

  • Days Won

    10

Posts posted by Subject22

  1. I suspect it has something to do with the thread being moved to this sub-forum.

    EDIT: Wait!! I lie! I can change it from the mobile site! I swear I wasn't able to do that from the desktop version. But perhaps I just missed it at the time :-)

  2. I've modified my version and can't check the original at the moment, but if I recall correctly there are two action panels in the workflow each linked to a different hotkey. One provides the long 'direct' link (which, frustratingly, expires after 4 hours), and the other provides the short 'share' link. Just set a hotkey for the short link and you should be fine :-)

  3. No problem :-) You know about Alfred's built in feature for emptying the trash don't you? The keyword emptytrash will do that for you :-) But if you want this workflow to automatically empty the trash after clearing your downloads folder, find it in Alfred, double click the Run Script action and paste the following code on a new line under the existing code: osascript -e 'tell app "Finder" to empty'

  4. That sounds perfectly reasonable to me. It was an honest mistake on my part :-) I've got a workaround, fortunately (thanks to Carlos-Sz), I just thought it was peculiar that it worked once the script was cached, and if it was called from outside Aflred (which I suppose includes the case where it is cached). Thanks for looking into this anyway!

  5. Sure. Sorry, I thought that's what I'd done, given that things seemed to have gone quiet in that thread :-) In future you'd rather I wait a bit longer?

     

    Ugh, maybe it's a good thing this is being closed. I just noticed that spelling mistake in the title. It'll bug me every time I look at it now :P

  6. Carlos-Sz's version uses that exact method, if I recall correctly. But that still fails when run directly from Alfred, it has to be saved as a .scpt in the workflow's directory and called with a bash script.

     

    EDIT: I lie. He tested a similar method, but neither way works properly when run from within Alfred. Both work fine from AppleScript Editor.

     

    This isn't really relevant, but we might as well be looking at the same thing. Here's the version of the code I'm using at the moment. I got rid of references to window 1 and started using front window instead, along with some other slight improvements.

     

    if application "Safari" is running then
    	tell application "Safari"
    		try
    			set theURL to URL of current tab of front window
    			set pageName to name of current tab of front window
    		on error
    			return "There are no pages open in Safari at the moment"
    		end try
    	end tell
    	
    	tell application "Google Chrome"
    		activate
    		
    		if URL of active tab of front window is not theURL then
    			if (count of windows) is 0 then
    				make new window
    			else
    				make new tab at end of tabs of front window
    			end if
    			
    			set URL of active tab of front window to theURL
    		else
    			return "The current Safari tab is already open in Chrome"
    		end if
    	end tell
    	
    	# Enable the following line to post notifications after sending URLs to Chrome
    	--return "Opening '" & pageName & "' in Chrome"
    else
    	return "Safari is not open at the moment"
    end if
    
  7. Perhaps I haven't understood you correctly, but how would that help? The problem is that when Safari is not open the script fails to respect the if statement, causing Safari to launch. It ought to just return "Safari is not open at the moment" - which it does when the script is run from AppleScript Editor. I tried your suggestion, just in case. No luck :-/ If Safari's not open when I invoke the workflow it still launches, even though it should just post a notification.

     

    EDIT: Whoops. I thought I was in a different thread D: Excuse me while I adjust my reply :-) Done.

  8. When I ask Alfred to open a URL (for example, from a standard search which returned bookmarks, a workflow which returned a URL, or a manually typed URL), he sometimes opens the URL in a new window rather than a new tab. I seem to remember the same thing happening with V1, so it's a long-standing issue. I've tried to find ways to reproduce the problem reliably, but I've come up short. All I can say is that it happens frequently (a few times a day) and that I haven't been able to discern a pattern.

     

    If the problem occurs (i.e.: I tell Alfred to open a URL and he opens it in a new window rather than a new tab) then it will keep happening with subsequent URLs until I open a new tab manually. That said, Alfred does seem to fix himself after a varying period of time.

     

    Sorry to be vague on details, I wouldn't have posted it until I had something more concrete but it's been such a long time, and it's been really annoying me. I did a quick google search and found a reference to a Get Satisfaction page which seemed to be relevant, but annoyingly I can't get it to load (asterisk added to prevent the link from being shrunk).

     

    h*ttp://getsatisfaction.com/alfredapp/topics/alfred_not_putting_web_search_in_a_new_tab_in_safari_but_does_in_chrome/edit+alfred+opening+url+in+new+window&cd=2&hl=en&ct=clnk&gl=nz

     

    Details

    OS X 10.8.3

    Safari 6.0.3

    Alfred 2.0.2 (178)

  9. Handy workflow! I made a context aware equivalent triggered by a hotkey. If you're in Finder when you use it it'll open the current directory in Terminal, if you're in Terminal when you use it it'll open the current directory in Finder. I didn't bother including iTerm as I never use it. I'm sure that anyone who's using this kind of workflow will be more than capable of adding support for iTerm, should they need it :-) I'd appreciate any critiques of the AppleScript code I wrote. It's fairly messy, but anything neater (in terms of code) was less robust in actual use.

     

    Download: Directory Switcher

  10. Things have probably run as far as they're going to in this thread, so I thought I'd post it as a bug report. Here's a quick summary:

    An AppleScript I wrote does not behave as expected when run from Alfred's Run Script action. The same script runs as expected from AppleScript Editor. The script runs as expected via Alfred's NSApplescript action once it has been cached in memory (i.e.: the initial run with caching fails, but all subsequent runs behave as expected, until Alfred is restarted). Saving the script to the workflow's directory and calling it with a bash script via Alfred's Run Script action seems to be the best workaround. See the linked thread for more details and examples.

  11. I just tested it on my machine and it definitely does. Are you 100% sure the total isn't changing? Alfred Preferences only updates the usage total when it starts up, and it seems to sometimes take Alfred a second to update the counter (i.e.: if you call a workflow and immediately open Alfred Preferences it may not show a change).

  12. Is it possible the execute the 'do shell script...' without a visible Terminal window?

     

    David's infinitely more qualified than I am to answer your questions, so I'll take the easy one :-) The do shell script command normally does run without creating a Terminal window, the only reason it's doing it here is because you included it in a tell application "Terminal" block. Try this:

     

    #/usr/bin/osascript
    
    try
        tell application "Safari" to tell document 1
    	set theLink to (get URL)
        end tell
    end try
    
    try
        do shell script "python youtube-dl -o ~/Downloads/movie.mp4 " & theLink
    end try
    
    return "Download Finished... "
    
    

    For the record, if you are using AppleScript to tell Terminal to run a shell script, you can actually do it with do script rather than the full do shell script command :-)

     

    EDIT: I'm also not sure what the duplicate try blocks are meant to accomplish. Couldn't you achieve the same thing with just one?

    #/usr/bin/osascript
    
    try
        tell application "Safari" to tell document 1
    	set theLink to (get URL)
        end tell
    
        do shell script "python youtube-dl -o ~/Downloads/movie.mp4 " & theLink
    end try
    
    return "Download Finished... "
    
×
×
  • Create New...