UPDATE สิ่งนี้จะทำงานใน 10.7.x แต่ 10.6 มีข้อมูลองค์ประกอบอยู่
ปุ่ม (ดร็อปดาวน์) ในแผ่นพิมพ์มีคำอธิบายเพื่ออธิบายฟังก์ชั่น
ในการตรวจสอบการเข้าถึง ; คุณเห็นสิ่งนี้เมื่อวางตัวชี้เมาส์เหนือองค์ประกอบ (ปุ่ม) คุณสามารถล็อค มุมมองของผู้ตรวจสอบการเข้าถึงด้วย cmd + F7
คำอธิบายจะแสดงเป็นAXDescription

ในกรณีสำหรับเครื่องพิมพ์มันคือเครื่องพิมพ์สำหรับค่าที่ตั้งไว้มันเป็นค่าที่ตั้งไว้ล่วงหน้า
หากคุณรู้จักAXDescriptionคุณสามารถหลีกเลี่ยงตัวเลขที่ใช้สิ่งนี้ แต่นี่ไม่ใช่วิธีเดียว เพียงแค่ตัวอย่างเดียว
activate application "Preview"
tell application "System Events"
tell process "Preview"
click ((pop up buttons of sheet 1 of window 1) whose description is "Printers")
end tell
end tell
เพื่อให้การทำงานด้านบนในตัวอย่างนี้ต้องแสดงแผ่นข้อมูลพร้อมกับ 'แสดงรายละเอียด'
ปุ่ม / เลื่อนลงมีเมนู เพื่อให้คุณสามารถเลือกหรือคลิกได้โดยหมายถึงรายการเมนูของเมนูของปุ่ม
โดยใช้หมายเลขหรือใช้หัวเรื่อง / AXTitle
activate application "Preview"
tell application "System Events"
tell process "Preview"
click ((pop up buttons of sheet 1 of window 1) whose description is "Presets")
click menu item "Last Used Settings" of menu of ((pop up buttons of sheet 1 of window 1) whose description is "Presets")
end tell
end tell
คุณสามารถย่อรหัสซ้ำได้โดยใช้ตัวแปรสำหรับปุ่มและเรียกมันว่า เมื่อทำมันเหมือนตัวอย่างของฉันด้านล่าง;
activate application "Preview"
tell application "System Events"
tell process "Preview"
set Presets_button to item 1 of ((pop up buttons of sheet 1 of window 1) whose description is "Presets")
click Presets_button
click menu item "Last Used Settings" of menu of Presets_button
end tell
end tell
UI elementsคำสั่งจากที่นี่มีประโยชน์เช่นกัน: n8henrie.com/2013/03/a-strategy-for-ui-scripting-in-applescript