Alfred Workflows の Automation Task automaion: hkob の雑記録 (81)

はじめに

hkob の雑記録の第80回目は、Alfred Workflow の Automation Task automation を解説します。

Automation Task automation

Automation Taskは automations の一番最初にあります。これは Alfred 5 から登場した新機能でコードを書くことなく複雑なワークフローを構築できる新機能です。macOS の Shortcut アプリと同様なものが用意されている感じです。

Automations

このオブジェクトの解説として、英語のマニュアルが用意されています。

www.alfredapp.com

私の場合は、コードを書いてしまうのであまりこの機能を使うことはなさそうです。ただ、PDF の連結などはコードを書くより便利なので使いそうな感じがします。ネタを見つけてみたいと思います。

Automation Task

Automation Task automation の設定

Automation Task automation は以下のような設定画面になっています。

Automation Task の設定

ここには大量のツールがあり、全ての機能は説明しきれません。しかも毎月アップデートされ続けています。今後使うものがあったときにその機能だけ解説したいと思います。ここでは上記のマニュアルに載っている現在の機能一覧のリストだけ引用しておきます。

Core Automation Tasks (Alfred’s main collection of Automation Tasks)

  • Appearance
    • Set Dark Mode (Enable, disable, or toggle Dark Mode)
    • Is Dark Mode On? (Check if Dark Mode is enabled)
    • Current Wallpaper (Get path to current wallpaper)
    • Change Wallpaper (Set the Desktop wallpaper)
    • Change Wallpaper at Random (Set wallpaper at random from current wallpaper folder)
  • Arguments Processing (Modify the Stream Arguments)
    • Append to Arguments (Append text to every argument)
    • Count Arguments (Get number of arguments)
    • First Argument (Get first argument)
    • Leading Arguments (Get number of arguments from start)
    • Matching Arguments (Get arguments matching a pattern)
    • Non-matching Arguments (Get arguments not matching a pattern)
    • Prepend to Arguments (Prepend text to every argument)
    • Randomise Arguments (Get arguments in random order)
    • Random Argument (Get one random argument)
    • Reverse Argument Order (Get arguments in inverse order)
    • Sort Arguments (Sort arguments alphabetically)
    • Strip First Argument (Get all arguments but the first)
    • Strip Leading Arguments (Get all arguments but a number of them from start)
    • Strip Last Argument (Get all arguments but the last)
    • Strip Trailing Arguments (Get all arguments but a number of them from end)
    • Last Argument (Get last argument)
    • Trailing Arguments (Get number of arguments from end)
  • Date Manipulation
    • Convert Time Format (Convert time to a different format)
    • Current Time (Get the current time in a specific format)
    • Convert Timezone (Convert time to a different timezone)
  • Files and Folders (Interact with your files, folders, and the Finder)
    • Folder Contents (Get contents of folders)
    • Most Recently Added Path (Get path most recently added to folder)
    • Is Folder? (Check if paths are folders)
    • New Folder (Make new folders, including intermediary paths)
    • Sync Folder Contents (Replace the contents of a folder to match another)
    • File Checksum (Get cryptographic hash functions of files)
    • Binary Decode File (Make files from binary-encoded representations)
    • Binary Encode File (Get binary encodings of files)
    • Is File Executable? (Check if files are executable)
    • Make File Executable (Enable, disable, or toggle executable permission of files)
    • Is File? (Check if paths are files)
    • File MIME Type (Get MIME type of files)
    • Matching File MIME Type (Get files matching MIME type)
    • Non-matching File MIME Type (Get files not matching MIME type)
    • New Empty File (Make new empty files, including intermediary folders)
    • Open in Quick Look (Preview paths in Quick Look)
    • File Contents (Get contents of files)
    • File UTI (Get Uniform Type Identifier of files)
    • Matching File UTI (Get files matching Uniform Type Identifier)
    • Non-matching File UTI (Get files not matching Uniform Type Identifier)
    • Copy With the Finder (Copy paths leveraging the Finder’s behaviour)
    • Move With the Finder (Move paths leveraging the Finder’s behaviour)
    • Selection in Finder (Get paths selected in the Finder)
    • Path to Front Finder Window (Get path to frontmost valid Finder window)
    • New Finder Window (Open Finder windows)
    • Abbreviate with Tilde in Path (Replace home folder path with “”)
    • New Finder Alias (Make alias shortcuts to paths)
    • Path Basename (Get path names without folder portion)
    • Path Basename Without Extension (Get path names without extension and folder portion)
    • Path Dirname (Get folder paths without name portion)
    • Duplicate Path (Make duplicates of paths next to the originals)
    • Does Path Exist? (Check if paths exist)
    • Expand Tilde in Path (Replace leading “” with home folder path)
    • File Extension (Get path extensions)
    • Filter Paths for Folders (Exclude files from path list)
    • Filter Paths for Files (Exclude folders from path list)
    • Filter for Paths Newer Than (Exclude paths which were modified before a time frame from path list)
    • Filter for Paths Older Than (Exclude paths which were modified after a time frame from path list)
    • Finder Comment (Get Finder comment of paths)
    • Delete Finder Comment (Unset Finder comment of paths)
    • Write Finder Comment (Set Finder comment of paths)
    • Is Path Newer? (Check if paths were modified before a time frame)
    • Is Path Older? (Check if paths were modified after a time frame)
    • Pick Path (Pass through the configured file or folder)
    • List Tags (Get tags from paths)
    • Add Tags (Add tags to paths)
    • Clear Tags (Delete all tags from paths)
    • Remove Tags (Delete select tags from paths)
    • Set Tags (Replace all tags in paths)
    • Path Access Time (Get when paths were last accessed, in Epoch time)
    • Path Creation Time (Get the birth time of the inode of paths, in Epoch time)
    • Path Modification Time (Get when paths were last modified, in Epoch time)
    • Send to Trash (Trash paths)
  • Image Manipulation (Modify and get information from images)
    • Crop Image from Centre (Crop images from centre origin)
    • Crop Image from Corner (Crop images from top-left corner origin)
    • Image Dimensions (Get images pixel width, height, or both)
    • Flip Image (Mirror images horizontally or vertically)
    • Image Format (Get format of images)
    • Convert Image Format (Convert images to other formats)
    • Optimise Image Colour (Optimise image colours for sharing)
    • Resize Image Exactly (Alter image proportions, ignoring aspect ratio)
    • Resize Image by Height (Alter image proportions from height, maitaining aspect ratio)
    • Resize Image by Longest Side (Alter image proportions, constrained to longest side)
    • Resize Image by Percentage (Alter image proportions from percentage, maitaining aspect ratio)
    • Resize Image by Width (Alter image proportions from width, maitaining aspect ratio)
    • Rotate Image (Rotate images by degrees)
  • iWork
    • Current Keynote Document (Get name or path of current Keynote document)
    • Export Current Keynote Document (Export current Keynote document to another format)
    • Identify Open Keynote Documents (Get name or path of documents open in Keynote)
    • Export Open Keynote Documents (Export documents open in Keynote to another format)
    • Current Numbers Document (Get name or path of current Numbers document)
    • Export Current Numbers Document (Export current Numbers document to another format)
    • Identify Open Numbers Documents (Get name or path of documents open in Numbers)
    • Export Open Numbers Documents (Export documents open in Numbers to another format)
    • Current Pages Document (Get name or path of current Pages document)
    • Current Pages Document Text (Get body text of current Pages document)
    • Export Current Pages Document (Export current Pages document to another format)
    • Identify Open Pages Documents (Get name or path of documents open in Pages)
    • Export Open Pages Documents (Export documents open in Pages to another format)
  • JSON Processing
    • Format JSON (Pretty print JSON text)
    • JSON Value (Get value from a JSON key path)
    • JSON Keys (Get keys from JSON object)
  • macOS
    • Identify Running Apps (Get names, bundle identifiers, or paths of running applications)
    • Identify Front App (Get name, bundle identifier, or path of frontmost application)
    • Identify Front Browser (Get name, bundle identifier, or path of frontmost browser)
    • Click Menubar Item in Front App (Click menubar items in frontmost application)
    • Open Apps (Open passed-in and configured apps)
    • Quit Apps (Quit passed-in and configured apps)
    • Quit All Apps, with Exceptions (Quit every app except ones passed-in and configured)
    • Relaunch Apps (Quit and reopen passed-in and configured apps)
    • Is App Running? (Check if apps are running)
    • Clear Clipboard (Remove clipboard contents)
    • Save Clipboard (Export clipboard representations to a binary blob)
    • Restore Clipboard (Import clipboard representations from a binary blob)
    • Copy Image to Clipboard (Save images to clipboard as data)
  • PDF Manipulation (Modify and get information from PDFs)
    • Merge to PDF (Combine Images and PDFs into a single PDF)
    • Extract PDF Pages as Images (Save PDF pages to individual images)
    • Extract PDF Pages as PDFs (Save PDF pages to individual PDFs)
    • Extract PDF Text (Get all text from PDF)
  • Safari
    • Safari Tab List (Get name and URL of tabs open in Safari)
    • Current Safari Tab (Get URL or title of Safari’s current tab)
    • Close Current Safari Tab (Close Safari’s current tab)
    • Run JavaScript in Safari Tab (Execute JavaScript in Safari’s current tab)
    • Change Current Safari Tab URL (Replace URL of Safari’s current tab)
    • Safari Tabs Matching URL (Get Safari tabs with specified text in URL)
    • Switch to Safari Tab Matching URL (Switch to Safari tab with specified text in URL)
    • Close Safari Tabs Matching URL (Close Safari tabs with specified text in URL)
    • Safari Tabs Not Matching URL (Get Safari tabs without specified text in URL)
    • Close Safari Tabs Not Matching URL (Close Safari tabs without specified text in URL)
    • Open New Safari Window (Make new Safari window with URL)
  • Screen Capture (Take screenshots of your screen)
    • Custom Area Screenshot (Save image of custom screen area)
    • Full Screen Screenshot (Save image of the entire screen)
    • Interactive Screenshot (Interactively save image of custom screen area)
  • Shortcuts (Get information from the Shortcuts app)
    • Shortcut Folders (Get names of created shortcut folders)
    • Is Shortcut Installed? (Check if shortcuts are installed)
    • Shortcut Names (Get names of installed shortcuts)
    • View Shortcut (Open shortcuts for editing)
  • Text Processing
    • Text Checksum (Get cryptographic hash functions of text)
    • Binary Decode Text (Make files from binary-encoded representations)
    • URL Decode Text (Get percent-decoded text)
    • Binary Encode Text (Get binary encodings of text)
    • URL Encode Text (Get percent-encoded text)
    • Shell Escape Text (Get escaped text to use in a Terminal Command)
    • Append to Lines (Append text to every line)
    • Delete Empty Lines (Get text with empty lines removed)
    • Get First Line (Get first line from text without trailing newline)
    • Leading Lines (Get number of lines from start of text)
    • Matching Lines (Get lines matching a pattern)
    • Non-matching Lines (Get lines not matching a pattern)
    • Number Lines (Preppend the line number to every line)
    • Prepend to Lines (Prepend text to every line)
    • Randomise Line Order (Get text lines in random order)
    • Random Line (Get one random line from text)
    • Reverse Line Order (Get text lines in inverse order)
    • Sort Lines (Sort lines alphabetically)
    • Column from Text (Split lines on a delimiter and get a column)
    • Strip First Line (Get all lines from text but the first)
    • Strip Leading Lines (Get all lines but a number of them from start of text)
    • Strip Last Line (Get all lines from text but the last)
    • Strip Trailing Lines (Get all lines but a number of them from end of text)
    • Last Line (Get last line from text without trailing newline)
    • Trailing Lines (Get number of lines from end of text)
    • Trim Line Whitespace (Remove surrounding whitespace from every line)
    • Text Metrics (Get word, line, or character count from text)
  • URL Processing
    • Expand Short URL (Get the final destination of URLs)
    • URL Hostname (Get hostname from URLs)
    • URL Response Code (Get the numeric status code of HTTP requests)
    • Shorten URL (Use is.gd to shorten URLs)
    • New Web Shortcut (Make .webloc files from URLs)
  • Window Management (Resize and reposition the topmost window)
    • Screen Bounds (Get screen bounds)
    • Window Bounds (Get the topmost window’s bounds)
    • Set Custom Window Bounds (Set custom bounds for topmost window)
    • Move Window (Set custom position for topmost window)
    • Custom Resize Window (Set custom size for topmost window, anchored to its centre)
    • Resize Window from Preset (Set topmost window’s bounds relative to screen dimensions)
    • Send Window to Different Screen (Centre topmost window on specified screen)

Extra Automation Tasks (Alfred’s secondary collection of Automation Tasks)

  • Git
    • Clean Repository (Discard repository state and go back to previously saved state)
    • Commit All in Repository (Adds and commits all files in repository)
    • Is Repository Clean? (Check if repository contains uncommited or untracked files)
    • Is Repository? (Check if folders are Git repositories)
    • Repository Root (Get path to repository root folder)
  • Keyboard Simulation (Simulate keyboard inputs)
    • Press Keyboard Brightness Keys (Simulate pressing keyboard top-row keyboard brightness keys)
    • Press Media Keys (Simulate pressing keyboard top-row media keys)
    • Press Screen Brightness Keys (Simulate pressing keyboard top-row screen brightness keys)
    • Press Volume Keys (Simulate pressing keyboard top-row volume keys)
    • Type Text (Simulate typing text)
  • Web Browsers
    • Chromium Browsers (Interact with Chromium-based browsers, such as Google Chrome and Microsfot Edge)
      • Chromium Browser Tab List (Get name and URL of tabs open in Chromium browser)
      • Current Chromium Browser Tab (Get URL or title of Chromium browser’s current tab)
      • Close Current Chromium Browser Tab (Close Chromium browser’s current tab)
      • Run JavaScript in Chromium Browser Tab (Execute JavaScript in Chromium browser’s current tab)
      • Change Current Chromium Browser Tab URL (Replace URL of Chromium browser’s current tab)
      • Chromium Browser Tabs Matching URL (Get Chromium browser tabs with specified text in URL)
      • Switch to Chromium Browser Tab Matching URL (Switch to Chromium browser tab with specified text in URL)
      • Close Chromium Browser Tabs Matching URL (Close Chromium browser tabs with specified text in URL)
      • Chromium Browser Tabs Not Matching URL (Get Chromium browser tabs without specified text in URL)
      • Close Chromium Browser Tabs Not Matching URL (Close Chromium browser tabs without specified text in URL)
      • Open New Chromium Browser Window (Make new Chromium browser window with URL)
  • Frontmost Browser (Interact with the frontmost supported browser)
    • Front Browser Tab List (Get name and URL of tabs open in frontmost browser)
    • Current Front Browser Tab (Get URL or title of frontmost browser’s current tab)
    • Close Current Front Browser Tab (Close frontmost browser’s current tab)
    • Run JavaScript in Front Browser Tab (Execute JavaScript in frontmost browser’s current tab)
    • Change Current Front Browser Tab URL (Replace URL of frontmost browser’s current tab)
    • Front Browser Tabs Matching URL (Get frontmost browser tabs with specified text in URL)
    • Switch to Front Browser Tab Matching URL (Switch to frontmost browser tab with specified text in URL)
    • Close Front Browser Tabs Matching URL (Close frontmost browser tabs with specified text in URL)
    • Front Browser Tabs Not Matching URL (Get frontmost browser tabs without specified text in URL)
    • Close Front Browser Tabs Not Matching URL (Close frontmost browser tabs without specified text in URL)
    • Open New Front Browser Window (Make new frontmost browser window with URL)
  • Webkit Browsers (Interact with Webkit-based browsers, such as Safari Technology preview)
    • Webkit Browser Tab List (Get name and URL of tabs open in Webkit browser)
    • Current Webkit Browser Tab (Get URL or title of Webkit browser’s current tab)
    • Close Current Webkit Browser Tab (Close Webkit browser’s current tab)
    • Run JavaScript in Webkit browser Tab (Execute JavaScript in Webkit browser’s current tab)
    • Change Current Webkit Browser Tab URL (Replace URL of Webkit browser’s current tab)
    • Webkit Browser Tabs Matching URL (Get Webkit browser tabs with specified text in URL)
    • Switch to Webkit Browser Tab Matching URL (Switch to Webkit browser tab with specified text in URL)
    • Close Webkit Browser Tabs Matching URL (Close Webkit browser tabs with specified text in URL)
    • Webkit Browser Tabs Not Matching URL (Get Webkit browser tabs without specified text in URL)
    • Close Webkit Browser Tabs Not Matching URL (Close Webkit browser tabs without specified text in URL)
    • Open New Webkit Browser Window (Make new Webkit browser window with URL)

おわりに

Automation Task の中には Script で書くのは難しい機能などもたくさんありそうです。何か GUI に絡むような処理を書くようなことがあったら調べて使ってみたいと思います。

hkob.notion.site