代码之家  ›  专栏  ›  技术社区  ›  Ru Hasha

Applescript一个窗口调整大小,另一个不调整大小

  •  0
  • Ru Hasha  · 技术社区  · 7 年前

    通过applescript调整窗口大小时,我得到了一个不同寻常的结果。

    我试图设置Excel窗口的位置和大小,但在一个窗口中,它工作,而在另一个窗口中,它不工作。

    以下是代码:

    tell application "System Events"
    get the name of every application process whose class of windows contains window
    repeat with P in the result
        get (every window of process (contents of P) whose value of attribute "AXMinimized" is false)
        repeat with W in the result
            set win_name to name of W
            log P & ":" & win_name
    
            if (win_name is equal to "VBA-Web - Blank") then
                log "CASE1"
                tell W
                    set {position, size} to {{0, 0}, {1100, 500}}
                end tell
            end if
    
            if (win_name is equal to "Microsoft Visual Basic - VBA-Web - Blank.xlsm - [ThisWorkbook (Code)]") then
                log "CASE2"
                tell W
                    set {position, size} to {{0, 0}, {1120, 520}}
                end tell
            end if
    
        end repeat
    end repeat
    end tell
    

    在上面的代码中,CASE1可以正常工作,但是CASE2什么都不做。 我怀疑VBA编辑器窗口有些不同。。。但是怎么做呢?

    有什么建议可以解决这个问题吗?

    0 回复  |  直到 7 年前