Outlook 苹果书;无法获取窗口中的元素

Outlook 苹果书;无法获取窗口中的元素,outlook,applescript,Outlook,Applescript,我试图检查并报告Mac上Microsoft Outlook窗口(v 15.41)的大小。我知道该窗口包含一个滚动视图和一个webarea tell application "System Events" tell process "Microsoft Outlook" set position of the front window to {10, 10} set size of the front window to {1366,

我试图检查并报告Mac上Microsoft Outlook窗口(v 15.41)的大小。我知道该窗口包含一个滚动视图和一个webarea

tell application "System Events"
        tell process "Microsoft Outlook"
            set position of the front window to {10, 10}
            set size of the front window to {1366, 768}
            set i to entire contents of the front window
        end tell
    end tell
尽管窗口中肯定有子控件,但上面的代码仍会放入结果窗口
{}

有趣的是,在运行applescript命令之后,MS Outlook窗口似乎崩溃了。如果我尝试检查窗口的已知子元素,窗口会立即关闭,然后我会收到一个错误,即子元素不存在。如果我尝试使用“bounds”而不是显式的size和position命令,窗口就会崩溃。非常有趣的是,如果我使用Accessibility inspector,并尝试使用鼠标光标来标识窗口部分,如果我将鼠标悬停在拆分组/窗口本身上,它会崩溃(但窗口底部的滚动区域不会崩溃)。我想知道这是否是一个权限问题

这是一个很难重现的问题。我有两台运行相同操作系统版本的Mac电脑,一台可以访问窗口内容并检查前窗口的子窗口,另一台不能。两者都在同一版本的OSX上运行同一版本的Outlook

更新: 我能够识别在尝试检查窗口的子元素时发生的错误 我也在使用MS的最新版本Outlook 16.9

我现在90%确定这与权限有关。我有三台机器,其中两台表现出这种行为。没有的是10.13.3上的2014款Mac,我每次都升级了操作系统。另外两台是全新的机器,全新的安装版本为10.13.3,所有机器都在运行Loook 16.9

更新2:
在不同的MacMini上重新安装OSX似乎解决了最初的applescript问题。然而,我看到了
屏幕截图
实用程序的怪异行为。见附件

使用最新版本的Sierra和Outlook v,这对我来说很有效。15.13.3

property theBounds : {10, 10, 1366, 768}
property uiElems : {}

tell application "Microsoft Outlook"
    set bounds of every window to theBounds
    my getEntireContents()
end tell

on getEntireContents()
    activate application "Microsoft Outlook"
    delay 0.5
    tell application "System Events"
        tell front window of application process "Microsoft Outlook"
            set uiElems to entire contents
        end tell
    end tell
end getEntireContents

下面是一些不同的代码…如果Microsoft Outlook打开了多个窗口,此版本将允许您选择(从打开的窗口列表中)在哪个窗口上运行脚本操作

global resultValue
property theBounds : {10, 10, 1366, 768}
property windowNames : {}
property uiElems : {}

tell application "Microsoft Outlook"
    set windowNames to name of every window
    my chooseFromList()
    try
        set bounds of window (item 1 of resultValue) to theBounds
    end try
    my getEntireContents()
end tell

on getEntireContents()
    activate application "Microsoft Outlook"
    delay 0.5
    tell application "System Events"
        tell front window of application process "Microsoft Outlook"
            set uiElems to entire contents
        end tell
    end tell
end getEntireContents

on chooseFromList()
    set resultValue to choose from list windowNames ¬
        with title ¬
        "Choose Window To Process" with prompt ¬
        "You want the UI elements of which window?" OK button name ¬
        "OK" cancel button name ¬
        "CANCEL" without empty selection allowed
end chooseFromList

请注意,除非菜单栏被隐藏,否则将
位置
边界
属性的
列表
中的
项2
设置为小于23的值不会将其移动到,因此我看到的关闭窗口问题与边界值无关,10,10工程和以下@wch1zpink工程的答案,如果我做窗口1,而不是主窗口1<代码>将前窗口的位置设置为{10,10}仅在菜单栏隐藏时有效!不幸的是,Outloook 15.41是我一直使用的版本,它是Office 365作为下载提供给您的。以下是我的总体工作流程:打开microsoft outlook。关闭主窗口从桌面打开一个.eml文件,其中一个窗口显示.eml消息运行您提供的脚本错误消息:“Microsoft Outlook出现错误:无法获取主窗口1。索引无效。”如果我将“主窗口1”切换到“窗口1”,将执行调整大小操作,但
整个内容
位返回
{}
而不是窗口的children@Richthofen在我将delay.5添加到代码中之前,我还收到错误消息“无法获取主窗口1.无效索引”。请尝试将delay 0.5更改为delay 1或delay 1.5。在运行脚本之前,我实际上是通过打开一个.eml文件手动打开outlook窗口的。这不是窗口打开的延迟,因为在我运行脚本之前,窗口是打开的,并且是最前面的。