Electron apps include Slack, Discord, VS Code, Notion, Figma, and many other popular desktop applications.
Why Electron apps are different
Electron apps expose a minimal Accessibility tree compared to native macOS apps. Inner UI elements often appear as opaqueAXGroup elements with no labels or structure, making traditional AX-based automation challenging.
When you run snapshot -i on an Electron app, you may see very few interactive elements:
Automation strategies
Use keyboard shortcuts
Most Electron apps have rich keyboard support. This is the primary method for automating Electron apps.Identify available shortcuts
Check the app’s menu bar or documentation for keyboard shortcuts. Common patterns:
- Cmd+K: Quick switcher (Slack, Discord, VS Code)
- Cmd+N: New window/message
- Cmd+T: New tab
- Cmd+W: Close window/tab
- Cmd+F: Search
Send keystrokes with agent-native
Use the See KeyCommand.swift:36-44 for implementation details.
key command to send keyboard shortcuts:Use screenshots for visual context
When the AX tree doesn’t provide enough information, capture screenshots to understand what’s on screen:Check window titles
The window title often reflects the current navigation state:- Confirming successful navigation
- Determining which channel or conversation is active
- Verifying modal states
Paste files
For file uploads, use thepaste command to copy a file to the clipboard and paste it:
- Copying the file to the clipboard
- Sending Cmd+V to the app
Example: Automating Slack
Here’s a complete workflow for sending a message with an image to a Slack channel:Common keyboard shortcuts
Slack
| Shortcut | Action |
|---|---|
cmd+k | Quick switcher |
cmd+u | Upload file |
cmd+n | New message |
cmd+f | Search |
cmd+/ | Show shortcuts |
cmd+shift+k | Direct messages |
cmd+shift+a | All unreads |
VS Code
| Shortcut | Action |
|---|---|
cmd+p | Quick open |
cmd+shift+p | Command palette |
cmd+b | Toggle sidebar |
cmd+j | Toggle terminal |
cmd+k cmd+s | Keyboard shortcuts |
Discord
| Shortcut | Action |
|---|---|
cmd+k | Quick switcher |
cmd+n | Create/join server |
cmd+shift+t | Create thread |
cmd+i | Toggle inbox |
Best practices
Use delays between actions
Add small delays between rapid keystrokes to ensure the app processes each action:
Verify with screenshots
Capture screenshots before and after actions to debug automation failures:
Check window titles
Use window titles to confirm navigation:
Test shortcuts manually
Verify keyboard shortcuts work manually before automating them.
Troubleshooting
Keyboard shortcuts don't work
Keyboard shortcuts don't work
Possible causes:
- App is not focused/activated
- Shortcut requires different modifiers on your system
- App has custom keybindings
- Ensure the app is activated:
- Check the app’s keyboard shortcuts in Preferences
- Try alternative shortcuts (e.g.,
cmd+shift+kinstead ofcmd+k)
Text not typing correctly
Text not typing correctly
Possible causes:
- Special characters require escaping
- App processes input asynchronously
- Add delays between keystrokes:
- Use quotes for text with spaces or special characters:
Can't verify navigation state
Can't verify navigation state
Next steps
System Settings
Automate System Settings and native macOS apps
Safari automation
Interact with web content in Safari