Jump to content

Search the Community

Showing results for tags 'Applescript'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

Categories

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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Twitter


Website URL


Jabber


Location


Interests

Found 144 results

  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').documents[0].name() Application('Safari').documents[0].url() // "Webkit" Example: Application('Webkit').documents[0].name() Application('Webkit').documents[0].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. 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.
  3. 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!
  4. 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
  5. 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:
  6. 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!
  7. 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
  8. 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.
  9. 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.
  10. 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
  11. 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?
  12. 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.
  13. 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
  14. I am trying to write an workflow that will do following things in github page: - go to the bottom of the page - click commit button The main thing is whenever we are editing a file in github online to commit the chages we have to go to the bottom of the page and click "Commit changes" button. The github does not have that button on the top of the webpage and also does not have keyboard shortcut to do that. Commiting and Pushing edited files from a terminal is pretty simple a simple bash function in `bash_profile` will do that easily, but while working on online pages, we need to scroll down each time if we need to commit the changes. It will not save a heavy amount of time but if it is possible, the Alfred workflow to do it worth it. Thanks.
  15. 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
  16. 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
  17. I'm wondering if I can run AppleScript/terminal commands automatically in Alfred workflow. is that possible? any ideas?
  18. 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.
  19. Hi forum. I recently purchased the Alfred PowerPack and am looking forward to leveraging its power. I've added a few custom workflows that are triggered by hotkeys which run some NSAppleScripts. I'd like to do the same for a few more, but triggered automatically at a specific time each week (e.g. "every Friday @ 6pm"). I don't see a workflow object that is triggered by date or time. Is this possible in Alfred?
  20. 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.
  21. Hey I'm trying to make an AppleScript to be run from Alfred, that should quickly set a specified speaker as audio output device if it is currently connected (in example below "My Awesome Speaker"), and otherwise don't do anything. I have gotten most of the functionality down (toggling between speaker/internal speaker), but I'm having a problem in the instance that the speaker isn't connected. When this is the case, the script has already clicked on the audioMenu, making the dropdown be there until a mouse click. I thought I could make it go away by branching with an "if else" and then if the speaker isn't connected, then just clicking the audioMenu again (because I've seen similar behaviour (with succes) for other menu bar scripts). But if I instead do this, the audio dropdown will still be staying until a click has been made, and then the script clicks the audio icon again making it doubly annoying. on alfred_script(q) set speakerName to "My Awesome Speaker" set internalSpeakers to "Internal Speakers" activate application "SystemUIServer" tell application "System Events" tell process "SystemUIServer" -- Working CONNECT Script. Goes through the following: -- Clicks on Audio Menu (OSX Top Menu Bar) -- Clicks your speaker if not connected -- Else if connected, then disconnects by clicking Internal Speakers set audioMenu to menu bar item 4 of menu bar 1 tell audioMenu click if exists menu item speakerName of menu 1 then set speakerMenuItem to menu item speakerName of menu 1 if value of attribute "AXMenuItemMarkChar" of speakerMenuItem is "✓" then click menu item internalSpeakers of menu 1 return "Disconnecting from " & speakerName & "..." else click speakerMenuItem return "Connecting to " & speakerName & "..." end if else -- Doesn't work for now. Just clicks it again after you deselect menu, making it double annoying --click audioMenu return "Doesn't look like you're connected to " & speakerName & "..." end if end tell end tell end tell end alfred_script How can I fix this, so the dropdown actually goes away if speaker is not connected?
  22. Hi, I have a simple workflow I’m to toggle the new Mac OS Mojave Dark Mode on and off. Create a new workflow with a keyword trigger e.g. “dark”. Set up an action to run an Apple Script: tell application “System Events” tell appearance preferences set dark mode to not dark mode end tell end tell end alfred_script However, what I’d like to do is customise the script to also toggle Aldred's appearance from "Alfred macOS" to "Alfred macOs Dark" if dark mode is enabled and then switch back to "Alfred macOS" when disabled. And if anyone knows how I'd love to customise the script to toggle from the dynamic Mojave desktop to the dark version as well. Any ideas on how I could do this?
  23. Update: The MWE workflow can be found here. tldr; Needed help using appplescrip to edit string, I know how to do in python. (The required workflow is working help needed to make it better.) I was writing an Alfred Workflow to render ipython notebooks `.ipynb` files nicely using nbviewer of github. For that we need to use the website: https://nbviewer.jupyter.org For example to render a ipynb file: https://github.com/bhishanpdl/pdl_practice/blob/master/a.ipynb We need to open https://nbviewer.jupyter.org and paste the above notebook url there. i.e. From: https://github.com/bhishanpdl/pdl_practice/blob/master/a.ipynb To: https://nbviewer.jupyter.org/github/bhishanpdl/pdl_practice/blob/master/a.ipynb Then, we just need to open the new url in safari. ---------- I did following: - applescrip to find frontmost tab url and copy to clipboard - edit the url using python - again use applescript to open edited url This seems to be bit of too much of a work. Is there way it can be done in only one applescript. The only thing I don't know is how to edit the string in applescript. I am only comfortable working with python and use it for most of the work. The codes used are following: # First applescript tell application "Safari" ignoring case set theURL to URL of front document set the clipboard to theURL end ignoring end tell # Second python script to edit url import sys query = sys.argv[1] query = 'https://nbviewer.jupyter.org/github'+ query.split(r'github.com')[1] sys.stdout.write(query) """ From: https://github.com/bhishanpdl/pdl_practice/blob/master/a.ipynb To : https://nbviewer.jupyter.org/github/bhishanpdl/pdl_practice/blob/master/a.ipynb """ # Last applescript to open url on alfred_script(q) set theURL to the clipboard tell application "Safari" open location theURL activate end tell end alfred_script How can all these codes can be written in only one applescript?
  24. Good Morning Alfred App Dev's, I look up MAC addresses hundreds of times a week at work. Can anyone help/create me a workflow where I can quickly lookup the Mac address to see what manufacture router a customer has. Kind Regards,
  25. 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
×
×
  • Create New...