AppleScripting the Contextual Menu for Folders & Listings

This AppleScript will trip the Sort By Title in ascending order.

tell application "GarageSale 9.8.1" to activate

delay 1

tell application "System Events" to tell application process "GarageSale"
	
	set selectedFile to value of attribute "AXFocusedUIElement"
	tell selectedFile to perform action "AXShowMenu"
	
	try
		perform action "AXPress" of menu item "Sort By Title" of menu 1 of selectedFile
		delay 1
		
	end try
	
end tell

Sort in Descending order.

tell application "System Events" to tell application process "GarageSale"
	
	set selectedFile to value of attribute "AXFocusedUIElement"
	tell selectedFile to perform action "AXShowMenu"
	
	try
		key down option
		perform action "AXPress" of menu item "Sort By Title" of menu 1 of selectedFile
		delay 1
		key up option
		
	on error
		key up option
	end try
	
end tell

I’ve tried this on other contextual menu items.

Menu Items ending in “three dots” require you to type the ellipsis symbol - option key + ; (semicolon).

Remove the two hyphens from any of the single lines of code below to initiate that menu selection.

The items with four hyphens did not work.

Some of the items are for folders, some for listings and some for both.

Menu selections that depend on dynamically generated content such as “Start 344 Listings…” are not included as that would probably require retrieving the current folder count of internal items.

tell application "GarageSale 9.8.1" to activate

delay 0.5

tell application "System Events" to tell application process "GarageSale"
	
	set selectedFile to value of attribute "AXFocusedUIElement"
	tell selectedFile to perform action "AXShowMenu"
	
	try
		
		--perform action "AXPress" of menu item "New eBay Listing" of menu 1 of selectedFile
		--perform action "AXPress" of menu item "Generate SKUs…" of menu 1 of selectedFile
		--perform action "AXPress" of menu item "Sort By Title" of menu 1 of selectedFile
		--perform action "AXPress" of menu item "Sort By State" of menu 1 of selectedFile
		--perform action "AXPress" of menu item "Show Listing in Browser" of menu 1 of selectedFile
		--perform action "AXPress" of menu item "Copy Listing Link" of menu 1 of selectedFile
		--perform action "AXPress" of menu item "Move Selected Items To…" of menu 1 of selectedFile
		--perform action "AXPress" of menu item "New Group" of menu 1 of selectedFile
		
		----perform action "AXPress" of menu item "Import from GarageSale Scout…" of menu 1 of selectedFile
		----perform action "AXPress" of menu item "Erase Deleted Listings…" of menu 1 of selectedFile
		----perform action "AXPress" of menu item "New Smart Group…" of menu 1 of selectedFile
		----perform action "Duplicate Listing" of menu 1 of selectedFile
		----perform action "New Event from Selected Listing" of menu 1 of selectedFile
		----perform action "Delete Listing" of menu 1 of selectedFile
		
		delay 1
		
	end try
	
end tell