Skip to content

Problem Installing on Sierra + python3.6 (execfile not defined) #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
segalion opened this issue Mar 21, 2019 · 7 comments
Open

Problem Installing on Sierra + python3.6 (execfile not defined) #166

segalion opened this issue Mar 21, 2019 · 7 comments

Comments

@segalion
Copy link

Im having problems with install with pip3 install atomac with the same error reported as python3.5:

name 'execfile' is not defined

I have succcesfully installed pyobjc:
sudo pip3 install -U pyobjc-core
sudo pip3 install -U pyobjc

but I dont know if it is really necesary.

I have another great question about Xcode requirement:
Are you saying that atomac needs more than 3GB!!! to run!!! Sure? Im not a OSX user, but I cant understand this. How you suppose you can distribute a program to work with this: "Please install Xcode and after two hours and 5 GB of disk space wasted install this little app". Its a joke?

@daveenguyen
Copy link
Contributor

atomac 1.1.0 on pypi does not support python 3.
The changes in the master branch should make it work on python 3.
pip3 install git+https://github.com/pyatom/pyatom/

To the best of my knowledge, the one with access to publish releases is no longer active.
Because of that, I've forked a stripped down version of this project (atomacos).

Prior to #160 merge, the project had c-extensions.
I think that might be the reason for the xcode requirements so the extensions can be compiled.

@segalion
Copy link
Author

Thanks a lot daveenguyen

Master git installed and working fine (at least first import and launch automator app example)

I have seen your atomacos fork!!! Do you recomend me atomacos or pyatom (atomac)?
I havent clear if xcode is required or not.

Another question...
The documentation of the project seems terrible.
I am trying to:

  1. Get the window under the mouse (maybe not the active window).
  2. Get the visible control in the tree just under the mouse.
  3. Get all text info related to the control (text under mouse).

I have working some with the great pyatspi and I would know if you could make things like get the word, line, sentence or paragraph under the mouse i.e. in a page document. Get selected text, etc.

Thanks for your support.

@daveenguyen
Copy link
Contributor

I think getElementAtPosition with NativeUIElement.getSystemObject()
should get you what you want. (https://github.com/pyatom/pyatom/blob/master/atomac/AXClasses.py#L921)

Texts are typically available in element.AXTitle or element.AXValue

I don't think atomac provides a way to get the current mouse position.
In my project I use pyautogui which can get the mouse position with pyautogui.position()

@segalion
Copy link
Author

segalion commented Mar 26, 2019

Thanks a lot.
Seems It works fine with getElementAtPosition.

mouse position its getting from tkinter ( root.winfo_pointerx() & root.winfo_pointery() ), so no problem.

I sucessfully find the text under mouse (mainly with element.AXValue)

It works really fine even in Safari. But now I am searching for the associated link behind the text.
There are a AXParent and AXFocusableAncestor that points to a 'AXLink' object, but inside this object there arent any info about the (http) link.

w = uiatomac.getElementAtPosition([x,y])
for attr in w.getAttributes():
            try:
                print ("w.%s=%s" %(attr, eval("w." + attr)) )
            except:
                print ("w.%s unsuported" %attr)
for attr in w.AXParent.getAttributes():
        try:
            print ("PARENT.%s=%s" %(attr, eval("w." + attr)) )
        except:
            pass

Do you have any clue?
Thanks.

@daveenguyen
Copy link
Contributor

daveenguyen commented Mar 27, 2019

Looksl ike a bug in your code

- print ("PARENT.%s=%s" %(attr, eval("w." + attr)) )
+ print ("PARENT.%s=%s" %(attr, eval("w.AXParent." + attr)) )

I also recommend using getattr(w, attr) for this

This is the results I got
assuming safari is opened, google page loaded and the "About" link is at coordinate "50, 120"

>>> safari = atomacos.getAppRefByBundleId("com.apple.Safari")
>>> element = safari.getElementAtPosition((50, 120))
>>> element.AXParent.AXURL
https://www.google.com/intl/en/about/?fg=1&utm_source=google-US&utm_medium=referral&utm_campaign=hp-header

@segalion
Copy link
Author

Ops... I can see the problem:

importig your atomacos and executing... it reports correctly the link URL

importing atomac (this pynput code installed from this master github) and executing the same (safari = atomac.getAppRef...) it report:

'atomac._a11y.ErrorUnsupported: Return value not supported yet...'

So I recomend install your 'atomacos' (simply with 'pip3 install atomacos') instead of 'pyatom'

I have seen that you depend on pyautogui<0.9.42 (for some reason?). Its needed this depend? For me pyautogui a more top level library than pyatom.

@daveenguyen
Copy link
Contributor

Can you create an issue for ErrorUnsupported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants