pyatom

How to find cursor position of a currently focused text editable element on Mac OS X?

喜夏-厌秋 提交于 2021-01-29 08:03:48
问题 I need to perform the following task on Mac OS X: Find an application window that user is currently working in Find a currently focused element within it If the element is text editable, find current cursor position I'd like to use ATOMac, but I cannot figure out how to do this, i.e. what are correct attributes etc. Any ideas? 回答1: from atomac import getFrontMostApp def GetInsertionPoint (): try: app = getFrontmostApp() except: return -1 for element in app.textFieldsR()+app.textAreasR(): if

macOS Sierra - how to enable “Allow Remote Automation” using command line

跟風遠走 提交于 2019-12-03 15:08:07
问题 I am working on an automation stuff in macOS Sierra (10.12.2). By using python's atomac support I can launch the safari browser and make the settings enabled via Safari -> Preferences -> Advanced -> check "enable Develop Menu" and then select "Develop -> Allow Remote Automation". Looks like this is not so consistent for automation perspective. I would like to know if there is any shell command to make this possible. 回答1: Hmm ok, so as per my comment: You could do defaults write com.apple

macOS Sierra - how to enable “Allow Remote Automation” using command line

China☆狼群 提交于 2019-12-03 04:45:58
I am working on an automation stuff in macOS Sierra (10.12.2). By using python's atomac support I can launch the safari browser and make the settings enabled via Safari -> Preferences -> Advanced -> check "enable Develop Menu" and then select "Develop -> Allow Remote Automation". Looks like this is not so consistent for automation perspective. I would like to know if there is any shell command to make this possible. Montmons Hmm ok, so as per my comment: You could do defaults write com.apple.Safari IncludeDevelopMenu YES to activate the development menu via terminal. You could get python to