Jump to content


  • Posts

  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

JGC's Achievements

Helping Hand

Helping Hand (3/5)



  1. This is useful as far as it goes ... but I want to take it further. Namely to automatically select the most recent tab of the most recently used browser. So I spent some considerable time working out how to do this, and fixing other things in this that gave me errors, at least for my two installed browsers, Google Chrome and Safari. You can follow some of the discussion and help on StackOverflow. Here's the conclusion suitable for use in Alfred. on alfred_script(q) property nil : "" set [currentTabTitle, currentTabUrl] to [nil, nil] set cmd to "lsappinfo metainfo | grep -E -o 'Safari|Google Chrome' | head -1" set frontmostBrowser to do shell script cmd if the frontmostBrowser = "" then return nil if the frontmostBrowser = "Google Chrome" then tell application "Google Chrome" to tell ¬ (a reference to the front window) to tell ¬ (a reference to its active tab) if not (it exists) then return nil set currentTabTitle to its title set currentTabUrl to its URL end tell else if the frontmostBrowser = "Safari" then tell application "Safari" to tell ¬ (a reference to the front document) if not (it exists) then return nil set currentTabTitle to its name set currentTabUrl to its URL end tell end if return "[" & currentTabTitle & "](" & currentTabUrl & ")" end alfred_script However, this doesn't work when embedded as an Alfred "RunNSAppleScript" workflow item, and I can't tell why. (I had it triggered by snippet '\\url' but of course there are other ways of doing this.)
  2. No reason, other than someone else suggested it. What's the reason for favouring 'Run Script'?
  3. Thanks so much, @vitor. I've implemented that, including one second delays, and it works on my laptop (though for some reason not on my MacMini yet). Posting screenshot of it here in case others can use it.
  4. Thanks, @vitor. The problem is that ⌘⇥ can't be issued by the 'Key Combo' action. I can't see an action that can do this, but perhaps there's a 'System Command' or AppleScript that can do it?
  5. Is it possible to create a workflow in Alfred that does the following? - Copy selected text to clipboard - Switch to last used app - Paste text from clipboard - Switch back to the first app This is an action I've realised I do lots of times a day. If it isn't possible, and I suspect it isn't in Alfred, has anyone come across a different app that can do this? Many thanks.
  6. Hearted as well! BTW, try Job 12:23-25 which seems uncomfortably apt at the moment. Thanks.
  7. @deanishe very many thanks for your help on this. It's now working fine, without needing the OpenSSL libraries. Community Hero indeed
  8. OK done `pip install requests --target=.` (which Is what I think you meant) in the workflow subdirectory, and `pip install requests` for the general python install (I hope). When I run either your version or @emmanuel's I still hit errors, the last of which (for your version) is: user.workflow.748EA499-B00B-45DF-800C-498A7F2CC500 jonathan$ python ESVPassageFilter-newer.py Jude Traceback (most recent call last): File "ESVPassageFilter-newer.py", line 55, in <module> r = requests.get(baseUrl, params, headers=headers) File "/Users/jonathan/Dropbox/Alfred.alfredpreferences/workflows/user.workflow.748EA499-B00B-45DF-800C-498A7F2CC500/requests/api.py", line 72, in get return request('get', url, params=params, **kwargs) File "/Users/jonathan/Dropbox/Alfred.alfredpreferences/workflows/user.workflow.748EA499-B00B-45DF-800C-498A7F2CC500/requests/api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "/Users/jonathan/Dropbox/Alfred.alfredpreferences/workflows/user.workflow.748EA499-B00B-45DF-800C-498A7F2CC500/requests/sessions.py", line 508, in request resp = self.send(prep, **send_kwargs) File "/Users/jonathan/Dropbox/Alfred.alfredpreferences/workflows/user.workflow.748EA499-B00B-45DF-800C-498A7F2CC500/requests/sessions.py", line 618, in send r = adapter.send(request, **kwargs) File "/Users/jonathan/Dropbox/Alfred.alfredpreferences/workflows/user.workflow.748EA499-B00B-45DF-800C-498A7F2CC500/requests/adapters.py", line 490, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer')) I get this when I run the code outside Alfred as well (`python ESVPassageFilter-newer.py Jude`). Feels more like a problem with the web service itself, rather than the code? I confirm I've tweaked your code to include the `key` from @emmanuel; could it be that I need my own API key? Thanks for your help on this.
  9. Thanks. I first tried substituting @deanishe's updated script. As soon as I typed the '1' of "esv Eph1" in Alfred, the debug log showed: [2017-11-20 09:37:58][ERROR: input.scriptfilter] Code 1: Traceback (most recent call last): File "ESVPassageFilter.py", line 8, in <module> import requests ImportError: No module named requests This sounded like my python install was incomplete, and as I know very little about python and its libraries, I decided it was then easier to attempt to install 2.7.13. Well, I found 2.7.14 on https://www.python.org/downloads/mac-osx/ so have installed that. Unfortunately I then get the same errors as posted when I run either version. @emmanuel I was attempting to run "Eph 1.15-23" but it wasn't working with the screen shot text of "pr31:30".
  10. I'm getting the following debug messages whenever I run it: [2017-11-20 00:21:08][ERROR: input.scriptfilter] Code 1: Traceback (most recent call last): File "ESVPassageFilter.py", line 37, in <module> resp = urllib2.urlopen(req) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open response = self._open(req, data) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open '_open', req) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain result = func(*args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1240, in https_open context=self._context) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open raise URLError(err) urllib2.URLError: <urlopen error [Errno 54] Connection reset by peer> Am I running the wrong version of python or a library? When I type just `python` it says I'm running v2.7.10.
  11. Sorry to be thick, but the only download links I can find for this workflow are broken. Can someone please point in the right direction? Thanks.
  • Create New...