通过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编辑器窗口有些不同...但是如何?
关于我可以尝试解决的任何建议?