I am trying to use python package appscript to control applications in my MacBook. Unfortunately I am really confused.
For example, I am trying to control one of my excel files. I want to get the position and scroll to certain roll. Here is my code
# -*- coding:utf-8 -*-
from appscript import *
file = app('Microsoft Excel').documents[u'test.csv']
position = file.window.left_position()
print position
The code is only trying to get the position but it is not working. I download the ASDictionary to check the command but I still can not fix it. Here is the screenshot of the command:
Thank you so much for your help.
Excel’s Apple event (“AppleScript”) support is atypical and quirky.
Avoid using
documents
; it doesn’t work correctly. Useworkbooks
instead.Workbooks don’t have a
window
property. They do, however, havewindows
elements (since you can view a workbook in more than one window).Corrected Python code:
Or, in AppleScript: