Jump to content

JGC

Member
  • Posts

    18
  • Joined

  • Last visited

Everything posted by JGC

  1. Sorry, but I'm still not figuring this out. I need both {query} and result of the script I gave above. I can't see how to trigger the AppleScript and still have the {query} passing through to where I need it. So I've changed to having just AppleScript form the whole URL. Now I'm getting ``` ERROR: Announcement[Run Script] /Users/jonathan/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/9D8F8837-E6B8-4C41-AB82-5D505F841E95:408:412: script error: Can’t set URL to "noteplan://x-callback-url/addText?noteDate=" & theDate & "&mode=append&openNote=no&text=" & argv. Access not allowed. (-10003) ``` I thought I had all the relevant Monterey permissions turned on for Alfred. But perhaps there's another I need for this particular app?
  2. Thanks Vero ... but this doesn't solve my problem which requires either the snippet expanding, or its equivalent processing. The snippet definition is ``` set theDate to (current date) + 1 * days repeat until weekday of theDate = Sunday set theDate to theDate + 1 * days end repeat set theDate to year of theDate & (text -2 thru -1 of ("0" & (month of theDate as integer))) & (text -2 thru -1 of ("0" & (day of theDate as integer))) as string ``` From your experience what's the best way to replicate that in the workflow?
  3. Thanks. I hope it's available at https://transfer.sh/(/d0clS9/TEST snippet in workflow.alfredworkflow).zip
  4. @vitor thanks. Version = 4.6.4. I've tried many different versions of this workflow, all to no avail. The common factor is what I have distilled out ... the snippet is not getting expanded in the > step. I've created a simpler non-working-example ... though you'll need to setup a dummy snippet as well, of course. It should just show a Large Type "{your snippet contents}_{query}". However, I can't see how to post it here, and pastebin doesn't seem to be an option either.
  5. I have a snippet 'nextsun' defined that produces a YYYYMMDD date, e.g. 20220501. I would like to combine this with a {query} input term along with a URI ready to use in an x-callback. But I can't seem to combine these things together. The URI that is opened is almost correct, but it still includes ...{snippet:nextsun}... in the middle of it. https://www.alfredapp.com/help/workflows/advanced/placeholders/ says this should work since 4.1, and I'm on the latest release. What am I missing, please?
  6. 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.)
  7. No reason, other than someone else suggested it. What's the reason for favouring 'Run Script'?
  8. 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.
  9. 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?
  10. 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.
  11. Hearted as well! BTW, try Job 12:23-25 which seems uncomfortably apt at the moment. Thanks.
  12. @deanishe very many thanks for your help on this. It's now working fine, without needing the OpenSSL libraries. Community Hero indeed
  13. 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.
  14. 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".
  15. 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.
  16. 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...