# Open Calculatoragent-native open Calculator# Take a snapshot to see available buttonsagent-native snapshot Calculator --interactive# Click buttons using refs from snapshotagent-native click @n5 # 5agent-native click @n12 # +agent-native click @n7 # 3agent-native click @n18 # =# Get the resultagent-native get text Calculator --role AXStaticText
# Open TextEditagent-native open TextEdit# Wait for window to appearagent-native wait TextEdit --role AXWindow --timeout 5# Take snapshot to find text areaagent-native snapshot TextEdit --interactive# Fill the text areaagent-native fill @n3 "This is my document content.It has multiple paragraphs.Created with agent-native."# Save the document (Cmd+S)agent-native key TextEdit cmd+s# Wait for save dialogagent-native wait TextEdit --role AXTextField --label "Save As" --timeout 3# Fill filenameagent-native fill TextEdit --role AXTextField --label "Save As" "my-document.txt"# Click Save buttonagent-native click TextEdit --role AXButton --title "Save"
# Open TextEditagent-native open TextEdit# Type some textagent-native fill TextEdit --role AXTextArea "Hello, world!"# Select all (Cmd+A)agent-native key TextEdit cmd+a# Make it bold (Cmd+B)agent-native key TextEdit cmd+b# Increase font sizeagent-native key TextEdit cmd+plus cmd+plus cmd+plus# Take a screenshotagent-native screenshot TextEdit ~/Desktop/formatted-text.png
# Open Finderagent-native open Finder# Use Cmd+Shift+G to open "Go to Folder"agent-native key Finder cmd+shift+g# Wait for path fieldagent-native wait Finder --role AXTextField --timeout 3# Enter pathagent-native fill Finder --role AXTextField "~/Documents"# Press Enteragent-native key Finder return# Wait for folder to loadsleep 1# Take a screenshotagent-native screenshot Finder ~/Desktop/documents-folder.png
# Open Finderagent-native open Finder# Navigate to location (see above)agent-native key Finder cmd+shift+gagent-native wait Finder --role AXTextField --timeout 3agent-native fill Finder --role AXTextField "~/Desktop"agent-native key Finder returnsleep 1# Create new folder (Cmd+Shift+N)agent-native key Finder cmd+shift+n# Wait for folder name fieldagent-native wait Finder --role AXTextField --timeout 3# Name the folderagent-native fill Finder --role AXTextField "My New Folder"# Press Enter to confirmagent-native key Finder return
# Open Finderagent-native open Finder# Focus search field (Cmd+F)agent-native key Finder cmd+f# Wait for search fieldagent-native wait Finder --role AXSearchField --timeout 3# Enter search queryagent-native fill Finder --role AXSearchField "*.pdf"# Wait for resultssleep 2# Get count of resultsagent-native get text Finder --role AXStaticText
# Open Finderagent-native open Finder# Take snapshot to see view optionsagent-native snapshot Finder --interactive# Switch to list viewagent-native click Finder --role AXButton --label "List View"# Or use keyboard shortcuts# Icon view: Cmd+1# List view: Cmd+2 # Column view: Cmd+3# Gallery view: Cmd+4agent-native key Finder cmd+2
# Open Safariagent-native open Safari# Focus address bar (Cmd+L)agent-native key Safari cmd+l# Type URLagent-native key Safari "example.com" return# Wait for page loadsleep 3# Execute JavaScript to get page titleagent-native js Safari "document.title"# Get all linksagent-native js Safari "Array.from(document.querySelectorAll('a')).map(a => a.href).join('\\n')"# Take screenshotagent-native screenshot Safari ~/Desktop/webpage.png
# Open System Settingsagent-native open "System Settings"# Wait for windowagent-native wait "System Settings" --role AXWindow --timeout 5# Take snapshotagent-native snapshot "System Settings" --interactive# Click on Appearanceagent-native click "System Settings" --role AXButton --title "Appearance"# Wait for pane to loadsleep 1# Take screenshotagent-native screenshot "System Settings" ~/Desktop/appearance-settings.png
#!/bin/bash# Open multiple apps in parallelagent-native open Calculator &agent-native open TextEdit &agent-native open Safari &# Wait for all to finishwaitecho "All apps opened"# Take screenshots of all windowsagent-native screenshot Calculator ~/Desktop/calc.png &agent-native screenshot TextEdit ~/Desktop/textedit.png &agent-native screenshot Safari ~/Desktop/safari.png &waitecho "All screenshots captured"
#!/bin/bash# Wait for element with custom conditiontimeout=30interval=1elapsed=0while [ $elapsed -lt $timeout ]; do # Check if element exists and is enabled if agent-native find Safari --role AXButton --title "Done" --max 1 2>/dev/null | grep -q "Done"; then enabled=$(agent-native is enabled Safari --role AXButton --title "Done") if [ "$enabled" = "true" ]; then echo "Element found and enabled" break fi fi sleep $interval elapsed=$((elapsed + interval))doneif [ $elapsed -ge $timeout ]; then echo "Timeout waiting for element" exit 1fi