Что такое Apple OS? Это MacOS ??? Моя версия Microsoft Outlook - «версия 16.29 (19090802)», код ниже работает на моем MacOS 10.12.6. Вы можете попробовать, работает ли он на вашем компьютере.
tell application "Microsoft Outlook"
activate
delay 0.3
end tell
tell application "System Events"
tell process "Microsoft Outlook"
set theExportAsName to "Outlook for Mac Archive.olm"
set theExportToFolder to "/Users/admin/Desktop"
--input the file name and the destination folder path you want to export as
tell menu item "Export..." of menu "File" of menu bar item "File" of menu bar 1
click
delay 0.5
end tell
--show the Export dialog (1/3), we need to deal with three dialogs totally.
--knowledge point 1: how to click menu item in APP menu bar
tell group 1 of group "What do you want to export?" of front window
if value of radio button "Items of these types:" is not 1 then
click radio button "Items of these types:"
end if
end tell
--1st we choose export items
tell group 1 of group 1 of group "What do you want to export?" of front window
if value of checkbox "Mail" is not 0 then
click checkbox "Mail"
end if
if value of checkbox "Calendar" is not 1 then
click checkbox "Calendar"
end if
if value of checkbox "Contacts " is not 0 then
click checkbox "Contacts "
end if
end tell
tell group 2 of group 1 of group "What do you want to export?" of front window
if value of checkbox "Notes" is not 0 then
click checkbox "Notes"
end if
if value of checkbox "Tasks" is not 0 then
click checkbox "Tasks"
end if
end tell
--2nd we check Calendar, uncheck all the others
click button "Continue" of front window
delay 0.5
--3rd click Continue button to go to next dialog window (2/3)
tell text field 1 of sheet 1 of front window
set value to theExportAsName
end tell
--1st we set the file name we want to use
set the clipboard to theExportToFolder
keystroke "G" using {command down, shift down}
delay 0.5
keystroke "v" using {command down}
delay 0.5
keystroke return
delay 0.5
--2nd we set the destination folder path we want to use
tell sheet 1 of front window
click button "Save"
delay 0.5
end tell
--3rd click Save button to go to the last dialog window (3/3)
tell front window
click button "Finish"
end tell
--1st click Finish button to finish this task
end tell
end tell
Примечание 1: длительность задержки больше, чем необходимо, я установил ее на большое число, чтобы код работал медленно, чтобы вы увидели, что произошло. Вы можете проверить, а затем установить меньшее значение задержки для ускорения работы.
Примечание 2: в этих трех диалоговых окнах я все использую код ниже, чтобы получить информацию об элементах пользовательского интерфейса - чтобы увидеть, как на них ссылаться.
tell application "Microsoft Outlook"
activate
delay 0.3
end tell
tell application "System Events"
tell process "Microsoft Outlook"
tell front window
set uiElems to entire contents
end tell
end tell
end tell
Примечание 3: Я пишу некоторые комментарии, чтобы объяснить каждый шаг кода. Вы можете проверить это на своей машине. Пожалуйста, дайте мне знать, если это поможет.