Jump to content

Search the Community

Showing results for tags 'applescript'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Alfred 3
  • Make the Most of Alfred
    • Discussion & Help
    • Bug Reports
    • Alfred Feature Suggestions
    • Themes
  • Alfred Workflows
    • Share your Workflows
    • Workflow Help & Questions
  • Alfred v2 Themes
  • Alfred Remote for iOS
    • Alfred Remote Discussion & Help
    • Remote Connection Troubleshooting


  • Articles
    • Forum Integration
    • Frontpage
  • Pages
  • Miscellaneous
    • Databases
    • Templates
    • Media

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start




Website URL




  1. I’ve been seeing a lot of workflows that need to interact with a browser via AppleScript (usually to get a page’s url), but most of them seem to settle on a single browser (usually Safari), which is a shame. I can understand — applescript is a pain, and since each browser implements these functions however they want, finding the best way to do it with each one can be difficult, so here’s the code for most of them. The code for this may seem massive, but it is not. Read the comments to understand when to use what. You can find the latest version of this as a gist. -- AppleScript -- -- This example is meant as a simple starting point to show how to get the information in the simplest available way. -- Keep in mind that when asking for a `return` after another, only the first one will be output. -- This method is as good as its JXA counterpart. -- Chromium variants include "Google Chrome", "Chromium", "Opera", "Vivaldi", "Brave Browser", "Microsoft Edge". -- Specific editions are valid, including "Google Chrome Canary", "Microsoft Edge Dev". -- "Google Chrome" Example: tell application "Google Chrome" to return title of active tab of front window tell application "Google Chrome" to return URL of active tab of front window -- "Chromium" Example: tell application "Chromium" to return title of active tab of front window tell application "Chromium" to return URL of active tab of front window -- Webkit variants include "Safari", "Webkit". -- Specific editions are valid, including "Safari Technology Preview". -- "Safari" Example: tell application "Safari" to return name of front document tell application "Safari" to return URL of front document -- "Webkit" Example: tell application "Webkit" to return name of front document tell application "Webkit" to return URL of front document -- This example returns both the title and URL for the frontmost tab of the active browser, separated by a newline. -- For shorter code inclusive of all editions, only the start of the application name is checked. -- Keep in mind that to be able to use a variable in `tell application` — via `using terms from` — we’re basically requiring that referenced browser to be available on the system. -- That means that to use this on "Google Chrome Canary" or "Chromium", "Google Chrome" needs to be installed. Same for other browsers. -- This method also does not exit with a non-zero exit status when the frontmost application is not a supported browser. -- For the aforementioned reasons, this method is inferior to its JXA counterpart. tell application "System Events" to set frontApp to name of first process whose frontmost is true if (frontapp starts with "Google Chrome") or (frontApp starts with "Chromium") or (frontApp starts with "Opera") or (frontApp starts with "Vivaldi") or (frontApp starts with "Brave Browser") or (frontApp starts with "Microsoft Edge") then using terms from application "Google Chrome" tell application frontApp to set currentTabTitle to title of active tab of front window tell application frontApp to set currentTabUrl to URL of active tab of front window end using terms from else if (frontApp starts with "Safari") or (frontApp starts with "Webkit") then using terms from application "Safari" tell application frontApp to set currentTabTitle to name of front document tell application frontApp to set currentTabUrl to URL of front document end using terms from else return "You need a supported browser as your frontmost app" end if return currentTabUrl & "\n" & currentTabTitle // JavaScript for Automation (JXA) // // This example is meant as a simple starting point to show how to get the information in the simplest available way. // Keep in mind that when asking for a value after another, only the last one one will be output. // This method is as good as its AppleScript counterpart. // Chromium variants include "Google Chrome", "Chromium", "Opera", "Vivaldi", "Brave Browser", "Microsoft Edge". // Specific editions are valid, including "Google Chrome Canary", "Microsoft Edge Dev". // "Google Chrome" Example: Application('Google Chrome').windows[0].activeTab.name() Application('Google Chrome').windows[0].activeTab.url() // "Chromium" Example: Application('Chromium').windows[0].activeTab.name() Application('Chromium').windows[0].activeTab.url() // Webkit variants include "Safari", "Webkit". // Specific editions are valid, including "Safari Technology Preview". // "Safari" Example: Application('Safari').windows[0].currentTab.name() Application('Safari').windows[0].currentTab.url() // "Webkit" Example: Application('Webkit').windows[0].currentTab.name() Application('Webkit').windows[0].currentTab.url() // This example returns both the title and URL for the frontmost tab of the active browser, separated by a newline. // For shorter code inclusive of all editions, only the start of the application name is checked. // This method is superior to its AppleScript counterpart. It does not need a "main" browser available on the system to reuse the command on similar ones and throws a proper error code on failure. const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0] const frontmost_app = Application(frontmost_app_name) const chromium_variants = ['Google Chrome', 'Chromium', 'Opera', 'Vivaldi', 'Brave Browser', 'Microsoft Edge'] const webkit_variants = ['Safari', 'Webkit'] if (chromium_variants.some(app_name => frontmost_app_name.startsWith(app_name))) { var current_tab_title = frontmost_app.windows[0].activeTab.name() var current_tab_url = frontmost_app.windows[0].activeTab.url() } else if (webkit_variants.some(app_name => frontmost_app_name.startsWith(app_name))) { var current_tab_title = frontmost_app.documents[0].name() var current_tab_url = frontmost_app.documents[0].url() } else { throw new Error('You need a supported browser as your frontmost app') } current_tab_url + '\n' + current_tab_title Other browsers Firefox Absent since although it’s possible to get the window’s title, it’s not possible to get its URL (it used to be, before version 3.6). It’s possible via hacky ways that consist of sending keystrokes, but those can be unreliable. This bug is being tracked in Bugzilla.
  2. Custom Terminal AppleScripts to Integrate iTerm and Alfred iTerm version 3 beta: The iTerm 3 beta version is the same version we have had for quite some time, which is also known as 2.9. Therefore the v2.9 branch of the script will work just fine with the v3 (aka 2.9) beta and v3 when it is released (any major changes to iTerm's applescript not withstanding). In a blog post released recently (19th August 2015) Vero (Alfred's Mum ) has announced that as of the next version of Alfred, these custom terminal scripts will be the available mechanism for integrating Alfred and iTerm: "With the upcoming release of Alfred 2.7.2, the default iTerm integration has been replaced by the "Custom" scripts option. This allows for a more up-to-date and more flexible way to handle the iTerm integration, using scripts created by one of our fantastic users, Stuart Ryan." I would like to thank Vítor for helping to clean up the applescripts and submitting some great pull requests . There are two versions of the script available: iTerm 2 Branch (tested up to 2.1.1) - view the v2.1 script on Github - updated December 14, 2015 iTerm 2.9 Branch (tested up to 2.9.20150626) - view the v2.9 script on Github - Updated December 14, 2015 Each of these can be inserted into Alfred by following these steps: Load the Alfred control panel Click the Features Button/Tab Click on the "Terminal/Shell" menu on the left hand side Select "Custom" under application, and replace the text in the new box that appears with the code as per the version of iTerm you are running. Alternatively, check out the official YouTube video on how to set them up: iTerm 2.1 Branch Custom Terminal Script Features: The 2.1 branch script is very basic and just corrects the opening of iTerm and creating a new session properly. Change Log: V0.4 Release - Vítor's submitted pull request for simplifying the check for if iTerm is already running. - December 14, 2015 (apologies for the delay in merging) V0.3 Release - Added version number and Vítor has done some great work standardising the scripts. No functionality changes in this release - August 14, 2015 Remove Trailing Whitespace (Vítor Galvão) - August 10, 2015 Initial Release - July 31, 2015 iTerm 2.9 Branch Custom Terminal Script Features: The 2.9 Branch goes a bit further to utilise some of the new features of iTerm 2.9 (which is in beta at the moment and can be downloaded if you are feeling adventurous from the iTerm download page). The script has been designed to achieve the following: Open the correct iTerm binary under /Applications/iTerm.app regardless of if another iterm/iTerm binary exists on the system Always create a new tab/session, unless iTerm is not running, in which case use the default session. If the user has selected to not create a default session on iTerm startup, detect and create a default session. Change Log V0.6 Release - Vítor's submitted pull request for simplifying the check for if iTerm is already running. - December 14, 2015 (apologies for the delay in merging) V0.5 Release - Added version number and Vítor has done some great work standardising the scripts. No functionality changes in this release - August 14, 2015 Removed bug introduced in last update (quotes around parameter) - August 12, 2015 Fix Whitespace (Vítor Galvão) + Fixed Search for iTerm/iTerm 2 Running (Stuart Ryan) - August 10, 2015 Updated to Fix Multiple iTerm Binaries - August 6, 2015 Initial Release - July 31, 2015 Donations If you love the scripts, and get use out of them every day, if you would like to donate as a thank you to buy me more caffeine giving Diet Coke, some Cake, or to put towards a shiny new gadget you can donate to me via Paypal. Future Updates: As new versions come out of the 2.9 branch I will keep the scripts up to date, if anyone finds issues with the 2.1 branch please let me know and I will test things out. If there are any changes to the scripts, I will post an update in this thread to let everyone know. If you would like to look at/contribute to the official repository please check it out on Github --> https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred. As always, I welcome ideas/thoughts/feedback etc. Cheers, Stuart
  3. Can I use an Apple script to mark a particular item in a reminder as complete?
  4. I am using the 'Play song' from iTunes as a workflow. The debugger shows" I know this is an issue with Mojave and the new 'sandbox' security bubble they put around interacting with the OS; I just don't know how to give it access. Alfred is already enabled in the seurity section. Any thoughts?
  5. I wrote a workflow which queries System Events for the currently active application. The result is used in a tell block to query the application for the path of the file corresponding to the top window. Finally this path is used to pop up Alfred's file action menue. Short Snippet to show the principle and describe my question: tell application activeApp set the_doc to front document set the_name to the name of the_doc set the_result to path of the_doc end tell When run outside Alfred, the snippet works as expected. But it throws AppleScript error -1728 when included inside Run NSAppleScript and Run Script (/usr/bin/osascript). The error is thrown at the third set command, that is, I am able to get the front document and its name property, but I fail to access the document's property path. -1728:„TextEdit“ hat einen Fehler erhalten: „path of document "alfred"“ kann nicht gelesen werden. Running the script from Sripteditor works fine. Running the compiled AppleScript with osascript from terminal also works fine. Running the AppleScript text with osascript (I think, this is how Alfred is doing it) from terminal yields -1728 as in the Alfred case. To make it work in a workflow, I have to compile the script with the help of Scripteditor and run the resulting scpt-file with osascript in a shell in Run Script: query=$1 echo -n $(osascript frontfile.scpt "$query") I provide two workflow-files on Github: frontmostdoc.alfredworkflow is the released and working workflow frontmostdoc-prototype.alfredworkflow shows how I started and demonstrates the issues describes above: keywords "wo" and "ou" are failing, keyword "where" works. Is there a bug in osascript or did I run into some kind of restriction in the AppleScript Language macOS BigSur Version 11.4 - Hans-Peter
  6. About Workflow As someone pretty new to the world of scripting, automations and Alfred, I found myself constantly referring to the AppleScript key code list for certain GUI automations (I'm sure many of these are easily done via other language, but I'm learning to walk first!) After a while of doing this, I decided to look for a key code workflow but really couldn't find one that had all the keys mapped. While I was building it, I also thought I'd shave off a couple of seconds of typing by outputting the text including any appropriate modifier keys (such as key code 12 using {command down, shift down}), created icons for each key, and now thought someone else could benefit from this fun little build. Dependencies None Usage Hotkey + Space followed by any letter on the keyboard. If you need modifiers, press any combination and hit enter. The workflow will paste the result in the application with focus and include any modifiers such as {command down, option down}. I'm sure there are cleaner ways to make it work in Alfred that doesn't involve so many modifier paths, so I would love to learn how I might be able to do that (keeping in mind I'm still elementary school with AppleScript only). Download The workflow can be downloaded from GitHub here. The icons used in this workflow (an icon for each letter of the keyboard) can also be downloaded from the same source).
  7. I'm trying to make a universal hotkey workflow that will "un-minimize" an app's windows- the ones with those pesky diamonds next to them e.g. No matter what I've tried, it's failing to work. I spent a good 3 hrs on this today and basically got nowhere. Here's a snippet of code that (mostly) works when run from Script Editor, but it fails miserably when put inside an Alfred osascript of NSAppleScript object: tell application (path to frontmost application as text) try set miniaturized of windows to false end try try set collapsed of windows to false end try try set minimized of windows to false end try end tell This works (again, in Script Editor only...) with Safari, Chrome, Messages.app, Apple Remote Desktop, Calendar, Contacts, and others. It does NOT work for Finder.app, Sublime Text (and probably a bunch of others). Anyone know of a way to do this? Even if it only works 90% of the time? Right now I am stuck at 0.
  8. Hey folks, I'm wondering if anyone can help me with this, I have pretty simple script to un-minimize all windows of formost application. tell application (path to frontmost application as text) try set miniaturized of every window to false on error errorMessage display alert errorMessage try set collapsed of every window to false on error errorMessage display alert errorMessage reopen end try end try end tell I bind this script to Hotkey (I tried both "Run script" /usr/bin/osascript and "Run NSAppleScript"), but It's not working as in AppleScript Editor. For example for Finder with Alfred workflow, I'm getting error message "Finder got an error: Can’t set |collapsed| of every window to false." That is not happening when I'm testing this script in AppleScript Editor.. OSX 10.9 Alfred 2.1
  9. This workflow starts with a keyword input and save the query as a variable named "amount". I want to use this variable inside a NSAppleScript later in the same process. I've tried set theAmount to (system attribute "amount") But it doesn't get this variable.
  10. I wanted to share a couple Zoom Scripts I made: https://github.com/BradDuns/ZoomScripts Tested with Zoom Version: 5.2.0 (42634.0805) Leave Zoom Leave a zoom meeting with Alfred... Keyword: LZ This uses Applescript GUI scripting to leave the active zoom meeting. I didn't see this one posted to the site but it's by Aaron Saray from https://www.aaronsaray.com/2020/leave-zoom-with-alfred Dial Into Zoom I prefer using my phone vs computer audio on zoom so this will dial my phone for me... Keyword: dialin Dial-in Setup: You need to be able to dial phone numbers from your mac to your iPhone. Similar to if you click a phone number in Safari and have the option to "Call using your iPhone" I believe this is by having both logged into iCloud. The Zoom Phone number is set to San Jose. If you would like to pick a different local number edit the 2nd line of the applescript. Join the meeting but don't pick computer audio, select Phone Call and you should see a dialog with the dial-in numbers, Meeting ID & Participant ID. This is where you run the workflow. It will pull the meeting and participant Id and dial it on your phone.
  11. I have a workflow where I copy 6 different lines of text and then paste them into 6 different browser fields. I am trying to write an Alfred workflow using Applescript to do this for me automatically. Therefore I need to copy the six different lines of text, invoke the workflow, so that it: Invokes the Alfred clipboard history viewer. Paste the sixth entry. Tabs to the next field. Repeats.... I have this script so far which invokes the Alfred clipboard history viewer, but the next "System Events" line in which command-6 keyboard shortcut is executed still targets the browser....and not the Alfred clipboard history viewer prompt window: tell application "System Events" keystroke "v" using {command down, option down} end tell tell application "System Events" keystroke "6" using {command down} end tell I tried targeting the app itself "Alfred 4" like below, but it does nothing: tell application "System Events" keystroke "v" using {command down, option down} end tell tell application "System Events" tell application "Alfred 4" to activate keystroke "6" using {command down} end tell Can someone help? Thank you!
  12. I was ecstatic when I found a workflow to add the currently playing track any playlist of my choice. So fast and efficient! But, alas, the workflows out there do not seem to work with Apple Music. I have looked at AppleScript API for iTunes (god I hate AS) and the small proof of concepts I have made have failed miserably. Has anybody gotten close to doing this? I am so sick of adding songs to playlists like a mere mortal! Thanks! -Christian
  13. I’m struggling to get a script filter to work which outputs a variable containing a mixture of text and emojis. In the output, Alfred just spits out empty characters for the emojis (⍰ question mark in a box). There’s obviously an encoding issue I’m overlooking, and I haven’t been able to quite put my thumb on it. To explain, I’ve created a script filter with AppleScript that’s supposed to let the user select a playlist from their Apple Music library (to play it, move it, etc). I recently moved over from Spotify to Apple Music, and I have a ton of playlists (put that's a separate problem - ha)! And, as you might guess, some of my playlists include emojis. When I run the script filter, Alfred’s output just shows empty characters where the emoji’s used to be. Consider the following example: Playlist: Radiohead ⭐ Faves Script Filter/Alfred Output: Radiohead ⍰ Faves Debug: Radiohead \u2b50 Faves So, while most of this is over my head, from what I understand, my JSON output is being spit out as formatted for C/C++/Java Src (when it should be in the usual utf8 unicode format). Any suggestions for fixing it? I've never tinkered around with JSON.scpt file that does all of the heavy lifting, so hopefully it's just a minor issue with my code. Admittedly, I’ve always been confused about how JSON and AppleScript work together. Although I’ve been able to create script filters in the past thanks to everyone’s help, I’ve never made one that dealt with text that containing emojis. Thanks for any help you can lend! For testing purposes, I’ve uploaded a test workflow here: https://share.getcloudapp.com/xQuDN0dl. And, here's screenshot of its script filter:
  14. iMessage Workflow V3 My workflow has been easily surpassed by others, please use theirs ---------> http://www.alfredfor...red/?hl=unicall However, I'm updating this workflow to Alfred 3 for posterity's sake. Sorry for taking so long guys... Archive Change log: 2/12/2017 - Because of a specific error, I've updated this app. Alongside the minor bug, thanks to Amos Manneschmidt's workflow "Call or SMS contact", I learned how to use OSX's built in Contact app to feed out contacts. Furthermore, I updated this app to be compatible with Alfred 3. 4/30/13 - Non-Latin languages are now supported! I have verified Korean, Chinese, and Japanese. If it works for your language, please tell me! 11/27/13 - My extension prioritizes numbers that have been used before. This should allow Alfred to choose the correct number associated with a contact MUCH more accurately. Works only with phone numbers, not email addresses; A notification is now displayed when contacts are not updated successfully (mostly a response to Exceptions thrown when trying to update) 11/21/13 - Emoticons should now work; Alfred now opens up iMessage if its closed ------------------------------------------------------------------------------------------------------------------------------------------------ If using the OLD way: Setup: Run command 'IMU' before you start using the workflow Find Contacts and Send Messages: Keyword: "im" 1b. Send a message to the aforementioned contact 2. Reply to most recent iMessage or Group Message (Thanks to David Ferguson's Workflow) Keyword: ".." Download Link: https://github.com/NolanChan/iMessageWorkflow/raw/master/iMessage.alfredworkflow Please post up bugs in the comments below!
  15. I've created a workflow that adds a reminder to a pre-determined list in Reminders. E.g. if I type "buy Apples" into Alfred, it adds the item "Apples" to the list called "shopping list" in Reminders. The workflow uses an AppleScript to create the reminder. The workflow looks like this: "Keyword > Run AppleScript > Post Notification" This is the AppleScript: on alfred_script(q) tell application "Reminders" tell list "Einkauf" set newremin to make new reminder set name of newremin to q end tell end tell end alfred_script If I run this script by itself in the Script Editor, it takes 2 to 3 seconds to execute. However, if I run the workflow, it takes about 40 seconds before the Notification at the end appears. During this time neither Alfred nor Reminders will respond. Is there a way to speed up this process? Maybe there's a better way to execute scripts from within a workflow? It could be that the fault is entirely on Reminders' side; in which case I'd love to know if a workaround exists.
  16. I'm thinking specifically of maybe an applescript command that would let you pass input to a text based service and get the output from it.
  17. I know this is a total noob question, but how do I pass the contents of the clipboard to an Applescript that I want to trigger in Alfred? I have a script that works fine if I copy some text to the clipboard and then run the script. Now that it works, I would like to be able to trigger the script from Alfred. I just cannot work out how to pass the contents of the clipboard to the script, the first line of which is `set theText to the clipboard`. Is there a way to select the text in the document and then trigger the script? I suppose that would mean changing the first line, but that's no problem. I'm happy to read a tutorial, but I'm just not sure where to look, as this seems to basic. Thanks Jeremy
  18. I have a very basic question about how script filters work that I haven’t been able to find a direct answer to on this forum or on Alfred’s support page. To be fair, there’s a ton of fantastic information on both, but I simply haven’t found one dumbs its explanation down enough for me to follow it. I've been using Alfred for quite some time, but have never been able to understand much about script filters. In short, I was wondering how to get items from an AppleScript list to show up as JSON formatted items in a script filter’s output (so that I can select one of them, and have it operate like the argument in a subsequent object)? For simplicity, let’s say I have an AppleScript that generates the following list: {"Red", "Green", "Blue”} But, in practice, that list will be dynamically produced and longer. In other words, I can't get away with just manually listing each item in the script filter (like in Alfred's jsonformat workflow example: Getting Started/Script Filter). Based on this example, how do I get the script filter’s output to operate like the following? Item 1 Title: Red SubTitle: Same Words Red Argument: Red Item 2 Title: Green SubTitle: Same Words Green Argument: Green Item 3 Title: Blue SubTitle: Same Words Blue Argument: Blue To illustrate, here’s what the output might look like when created with a list filter: *** @deanishe, I tried following your helpful advice and added a json.scpt file from another workflow that also used this approach. However, I couldn’t quite figure it out. Is there any way that I could talk you - or anyone else - into walking me through this, using the following example? 🙏 Based on the example above, I’ve created a very basic workflow to help illustrate things (for myself and others): Download Workflow. The workflow contains: (1) a script filter and (2) a list filter. The script filter has been stripped down to a single line of code that sets a variable to the afore mentioned list above (set theList to {"Red", "Green", "Blue"}) (AppleScript). In other words, I removed all of my failed attempts, and have only included this line in the AppleScript as a starting point (I understand there’s more to be done here). As for the list filter, it was included to illustrate how I’d like the script filter to perform (i.e., its output). I understand that if the string/list was fixed, that I could always just use it (instead of a script filter). Again, this was added strictly for illustrative purposes. To keep things simple, both filters simply copy their output to the clipboard. So, if you select the “Green” item from Alfred’s output, it would copy the word “Green” to the clipboard. In practice, this would be connected to another object that would do something else with the variable. But this struck me as an easiest way to test things. Can someone help walk me through how to set up the script filter so that it operates like the list filter (using an applescript list of variables)? Thanks in advance for any help you can lend! I really appreciate it.
  19. Does just what it says on the tin: toggles Bluetooth on or off depending on the current state. It's built to work with OS X Yosemite and Yosemite alone. To use, just type bt and press enter. If Bluetooth is on, it will be turned off. If Bluetooth is off, it will be turned on. The original AppleScript was written by fartheraway in response to a question on StackExchange. I just packaged it and gave it a simple icon that will work equally well on dark and light themes. Known shortcomings: - Current state (on or off) not shown - New state not shown/notified Download “Bluetooth Toggle” workflow (via CloudApp) Packal
  20. Hey, I've been trying to convert this launchbar script into an Alfred Workflow. The script is meant to take the current selection of Alfred, and activate the window behind, open the "Go To Folder" dialogue, paste in the path and press enter. I got it working in the AppleScript Editor, but for some reason I can't get it to perform on through Alfred. It even opens up the "Go To Folder" dialogue but stops there each time. Do you guys have any ideas? on alfred_script(q) set filePath to POSIX file of q tell application "System Events" set theApplication to application processes whose frontmost is true set target to item 1 of theApplication set target to a reference to front window of target set target to a reference to front sheet of target delay 0.5 tell target to keystroke "g" using {command down, shift down} -- Activate goto field tell target try set value of text field 1 to filePath delay 0.5 key code 36 -- simulate pressing the Enter key end try end tell end tell end alfred_script
  21. Search and insert the built in or user created clippings from Alfred 3 in a flash! Download at: http://www.packal.org/workflow/script-debugger-insert-clippings
  22. With the risk of reinventing the wheel, I created a Alfred workflow that move the selected items to a group from a list of predefined (and definable in the config!) groups. The options are: - setting a hotkey (optional) - setting the trigger command (default: dtm (as in devonthink move)) - create your own list of groups sorted in most used or fixed Try it, improve on it and let me know. If there are any questions just post a comment! Download: https://www.dropbox.com/s/8mv5bcwzj8qsach/DEVONthink move item.alfredworkflow?dl=0
  23. I'm wondering if I can run AppleScript/terminal commands automatically in Alfred workflow. is that possible? any ideas?
  24. To make a long story short, I updated a workflow. It has a long action that is done by an Alfred Script object in AppleScript. In certain cases, I want to do some of the work via a python script rather than in AppleScript. To do this I added the following which checks a variable already set and if so tries to run a python script I put in the workflow folder. (The argument passed is encapsulated in quotes) --check if online and if so, use Python. if contents of online is "online" then --run script to put passage onto the clipboard do shell script "python ./get_verse.py \"" + passageRef + "\"" --paste the passage into the current app keystroke "v" using command down else The réponse I'm getting back in Alfred debugging is: [2019-01-16 15:18:30][ERROR: action.script] /Users/samuel/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Scripts/27C48708-2D1A-4008-BCBF-CCABCD6247DC:801:811: execution error: Can’t make "python ./get_verse.py \"" into type number. (-1700) This tells me it's not executing the python script. I'm sure there's something simple here I'm missing but cannot figure out what it is.
  25. 2015-09-17: Major update to version 2 Alfred AppScripts Workflow List, search and run/open AppleScripts for the active application. Download The workflow can be downloaded from GitHub or Packal. The source code is also available on GitHub. Usage .as [<query>] — Show/search list of AppleScripts for the active application ↩ — Run the selected script. ⌘+↩ — Open the selected script in Script Editor. ⌥+↩ — Reveal the selected script in Finder. appscripts [<query>] — Show workflow configuration. Help – Open this file in your browser. (No) Update Available — Whether or not the workflow can be updated. Action the item to update or force an update check. Search Directories Recursively – Whether the script directories should be searched recursively. Use with some caution. Edit Script Directories — Open the configuration file in your default editor. The file contains a detailed description of how it works. Reset to Defaults — Delete configuration and cache files. Where are these scripts? The workflow comes with a default set of directories. These are defined in a settings file that you can edit yourself. Use the Edit Script Directories option in the configuration (keyword appscripts) to open the file in your editor. These are the default directories. {app_name} will be replaced with the name of the currently active application, e.g. BBEdit or OmniFocus, and {bundle_id} with the application's bundle ID, e.g. com.barebones.bbedit or com.omnigroup.OmniFocus2: ~/Library/Scripts/Applications/{app_name} ~/Library/Scripts/Applications/{bundle_id} ~/Library/Application Scripts/{app_name} ~/Library/Application Scripts/{bundle_id} ~/Library/Application Support/{app_name}/Scripts ~/Library/Application Support/{bundle_id}/Scripts ~/Library/Containers/{bundle_id}/Data/Library/Application Support/{app_name}/Scripts Any .scpt, .applescript or *.scptd (script bundle) files found within the above directories will be shown. If you add a directory path that doesn't contain {app_name} or {bundle_id}, it will match every application and the scripts will always be shown. See the settings file (AppScript Directories.txt) for more information. Licence, thanks The workflow code and the bundled Alfred-Workflow and docopt libraries are all licensed under the MIT Licence. The workflow icon was kindly donated by @Jono.
  • Create New...