From jon.joseph at wgu.edu Sat Mar 5 16:39:20 2016 From: jon.joseph at wgu.edu (Jon Joseph) Date: Sat, 5 Mar 2016 21:39:20 +0000 Subject: [python-win32] questions Message-ID: <494FF63E65376D42A75350DB62CCE0F310C8436D@EXCMBX-VP01B.wgu.edu> To Whom It May Concern: Is there any semi-comprehensive resource on how to use win32gui or any of the other win32* modules? As a beginning example I'm just trying to: 1) Open notepad (done) 2) Automatically File->Exit A simple demo would be helpful. Jon Joseph, PhD Course Mentor, General Education Email: jon.joseph at wgu.edu, x7275 Team Contact: ql2 at wgu.edu or Math Help Line: 1-877-435-7948 ext. 1761 Help Line Hours: Mon. - Thurs. 9:00 am - 11:00 am; 1:00pm - 7:00pm (MT) Fri. - Sat. 9:00 am - 2:00 pm (MT) -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Sun Mar 6 06:31:07 2016 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 6 Mar 2016 11:31:07 +0000 Subject: [python-win32] questions In-Reply-To: <494FF63E65376D42A75350DB62CCE0F310C8436D@EXCMBX-VP01B.wgu.edu> References: <494FF63E65376D42A75350DB62CCE0F310C8436D@EXCMBX-VP01B.wgu.edu> Message-ID: <56DC14FB.3060408@timgolden.me.uk> On 05/03/2016 21:39, Jon Joseph wrote: > To Whom It May Concern: Is there any semi-comprehensive resource on how > to use win32gui or any of the other win32* modules? As a beginning > example I?m just trying to: > > 1)Open notepad (done) > > 2)Automatically File->Exit > > A simple demo would be helpful. Unfortunately, there really isn't. Years ago, Mark Hammond & Andy Robinson wrote a book for O'Reilly covering the toolkit: http://shop.oreilly.com/product/9781565926219.do Although it's 16 years old(!) a lot of it will still be entirely relevant. (I gave my copy away so I can't quote chapter & verse). My own pages might be handy, altho' they, too, are not the freshest on earth: http://timgolden.me.uk/python/win32_how_do_i.html And I'm sure there examples in places like the ActiveState cookbook: http://code.activestate.com/recipes/langs/python/ and, of course, StackOverflow: http://stackoverflow.com/ Feel free to come back here for more. TJG From laurent.solano at gmail.com Mon Mar 7 06:10:02 2016 From: laurent.solano at gmail.com (laurent solano) Date: Mon, 7 Mar 2016 12:10:02 +0100 Subject: [python-win32] equivalent selenium findElement(By.xpath...) with win32com In-Reply-To: References: Message-ID: Hi, For now, i make automation by simulating the keyboard. It's working, but not satisfying. What I want to do is the equivalent in Python win32 of this line of code (from java selenium) : - webDriver.findElement(By.name("valider")).click(); - confirmation = webDriver.findElement(By.xpath("//table[@id='tablename']/tbody/tr[1]/td[2]")).getText(); Using doc.valider.click() and doc.TheForm.valider.click() is not working. Using "createtree" method, i can find the first level (frameset), but nothing under this level. idem with "children" property. Any idea ? Laurent ---- Tim Roberts, timr at probo.com : Why don't you show us the code you have? The Internet Explorer COM object surface is very large, so we don't want to waste time explaining what you already know. 2016-02-22 9:46 GMT+01:00 laurent solano : > Hi, > > I'm automating ie webbrowser with win32com module. > > I need to locate some xpath elements to manipulate them. Is there a way to > do it ? > More or less, i need the same feature than findElement(By.xpath ...) from > selenium. > > Can anyone help ? > thanks in advance, > > Laurent, > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Mar 7 15:47:45 2016 From: timr at probo.com (Tim Roberts) Date: Mon, 7 Mar 2016 12:47:45 -0800 Subject: [python-win32] equivalent selenium findElement(By.xpath...) with win32com In-Reply-To: References: Message-ID: <56DDE8F1.3080104@probo.com> laurent solano wrote: > For now, i make automation by simulating the keyboard. It's working, > but not satisfying. > What I want to do is the equivalent in Python win32 of this line of code (from java selenium) : > - webDriver.findElement(By.name("valider")).click(); > - confirmation = webDriver.findElement(By.xpath("//table[@id='tablename']/tbody/tr[1]/td[2]")).getText(); > Using doc.valider.click() and doc.TheForm.valider.click() is not working. > Using "createtree" method, i can find the first level (frameset), but nothing under this level. idem with "children" property. You still haven't shown us any of your code. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Mar 7 15:51:43 2016 From: timr at probo.com (Tim Roberts) Date: Mon, 7 Mar 2016 12:51:43 -0800 Subject: [python-win32] questions In-Reply-To: <494FF63E65376D42A75350DB62CCE0F310C8436D@EXCMBX-VP01B.wgu.edu> References: <494FF63E65376D42A75350DB62CCE0F310C8436D@EXCMBX-VP01B.wgu.edu> Message-ID: <56DDE9DF.3090700@probo.com> Jon Joseph wrote: > > To Whom It May Concern: Is there any semi-comprehensive resource on > how to use win32gui or any of the other win32* modules? As a > beginning example I?m just trying to: > > 1) Open notepad (done) > > 2) Automatically File->Exit > > > > A simple demo would be helpful. > The Win32 modules are a Python binding of the Windows API. If you know how to do this in the Windows API, then it's a pretty straightforward mapping into Python. If you don't know the Windows API, then you're climbing two learning curves at once. How are you opening Notepad? There are several ways to do that, both with in native Python and in the API. To do #2, you can use win32ui.FindWindow to find the Notepad window handle, then use win32gui.PostMessage to send a WM_CLOSE message to that window. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chris at slort.org Mon Mar 7 19:19:40 2016 From: chris at slort.org (Christopher Nilsson) Date: Tue, 08 Mar 2016 00:19:40 +0000 Subject: [python-win32] equivalent selenium findElement(By.xpath...) with win32com In-Reply-To: References: Message-ID: Not really via the win32 api, but if you're looking for the python equivalent of this selenium use-case, you should check out Splinter ( http://splinter.readthedocs.org/en/latest/). You'll need phantomjs, or any other compatible web "driver" installed as well though for this to work. I imagine achieving similar functionality with just win32 api will be a pretty massive effort... On Mon, 7 Mar 2016 at 22:15 laurent solano wrote: > Hi, > > For now, i make automation by simulating the keyboard. It's working, but not satisfying. > > What I want to do is the equivalent in Python win32 of this line of code (from java selenium) : > > - webDriver.findElement(By.name("valider")).click(); > > - confirmation = webDriver.findElement(By.xpath("//table[@id='tablename']/tbody/tr[1]/td[2]")).getText(); > > > Using doc.valider.click() and doc.TheForm.valider.click() is not working. > > Using "createtree" method, i can find the first level (frameset), but nothing under this level. idem with "children" property. > > > Any idea ? > > > Laurent > > ---- > > Tim Roberts, timr at probo.com : > > Why don't you show us the code you have? The Internet Explorer COM > > object surface is very large, so we don't want to waste time explaining > what you already know. > > > 2016-02-22 9:46 GMT+01:00 laurent solano : > >> Hi, >> >> I'm automating ie webbrowser with win32com module. >> >> I need to locate some xpath elements to manipulate them. Is there a way >> to do it ? >> More or less, i need the same feature than findElement(By.xpath ...) from >> selenium. >> >> Can anyone help ? >> thanks in advance, >> >> Laurent, >> > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From forderud at gmail.com Tue Mar 8 07:18:47 2016 From: forderud at gmail.com (Fredrik Orderud) Date: Tue, 8 Mar 2016 13:18:47 +0100 Subject: [python-win32] Insufficient notification of installer failure Message-ID: I'm working in a corporate environment where user account control and corporate policies are used to restrict application installation privileges. As a consequence of this the PyWin32 installer fails when not being started from a command prompt with administrative privileges (right click and select "run as administrator" does not work). The installation failure is of course not PyWin32's fault, but it would help with a stronger indication of failure. Observed behavior after copying & compiling of files have completed: --- Postinstall script finished. Click the Finish button to exit the Setup wizard. --- close failed in file object destructor: sys.excepthook is missing lost sys.stderr --- Several of my colleagues failed to notice the subtle error message, and believed that the installer succeeded. This led way to many problems with PyWin32 not working later on. Could it be possible to somehow give a clearer user notification on installer failure? Thanks in advance Fredrik -------------- next part -------------- An HTML attachment was scrubbed... URL: From Colin.Blair at GDIT.com Tue Mar 8 14:06:18 2016 From: Colin.Blair at GDIT.com (Blair, Colin S) Date: Tue, 8 Mar 2016 19:06:18 +0000 Subject: [python-win32] pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) Message-ID: <1457463978788.2951@GDIT.com> All, Please assist me with this error: Traceback (most recent call last): print msg.Body File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 466, in __getattr__ return self._ApplyTypes_(*args) File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 459, in _ApplyTypes_self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) I have a script that worked fine on a Windows 7 64Bit system. It broke when we upgraded to Windows 8 64bit. I am using python 2.7 32bit and pywin32-220.win32-py2.7. The script iterates through messages and parses the msg body content. I am able to access other properties of the message like Mailitem.Subject. Here are some of the properties I am no longer able to access: .Body . To .SenderName .SenderEmailAddress Here is a test script I used to produce this error: import win32com.client oApp = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") def getFolder(obj, name): for folder in obj: if folder.Name == name: return folder inbox = getFolder(getFolder(oApp.Folders,"EMBOX").Folders,"Inbox") for msg in inbox.Items: print msg.Body Thank you for any assistance you can provide. Colin From timr at probo.com Tue Mar 8 16:06:46 2016 From: timr at probo.com (Tim Roberts) Date: Tue, 8 Mar 2016 13:06:46 -0800 Subject: [python-win32] pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) In-Reply-To: <1457463978788.2951@GDIT.com> References: <1457463978788.2951@GDIT.com> Message-ID: <56DF3EE6.1080606@probo.com> Blair, Colin S wrote: > Please assist me with this error: > > Traceback (most recent call last): > > print msg.Body > File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 466, in > __getattr__ > return self._ApplyTypes_(*args) > File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 459, in > _ApplyTypes_self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), > pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) That's 0x80004005, which for MAPI is MAPI_E_CALL_FAILED. Very generic. Have you run gentypes.py on Outlook? Perhaps you should try to generate a static proxy: ol = win32com.client.gencache.EnsureDispatch("Outlook.Application") -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Tue Mar 8 17:47:22 2016 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 9 Mar 2016 09:47:22 +1100 Subject: [python-win32] Insufficient notification of installer failure In-Reply-To: References: Message-ID: <60d6bc91-10c6-e1a5-d48d-ba2d207209c1@gmail.com> pywin32 is using the installer capabilities built into Python itself (as part of distutils), so the changes would need to be made there. Sadly, that capability is slowly rotting as the world moves to other ways of installing Python modules, and I no longer have the time to make improvements there. On 8/03/2016 11:18 PM, Fredrik Orderud wrote: > I'm working in a corporate environment where user account control and > corporate policies are used to restrict application installation > privileges. As a consequence of this the PyWin32 installer fails when > not being started from a command prompt with administrative privileges > (right click and select "run as administrator" does not work). The > installation failure is of course not PyWin32's fault, but it would help > with a stronger indication of failure. That's strange - the installer should just work by running it anywhere (eg, by double-clicking it in explorer) and should request elevation. > > Observed behavior after copying & compiling of files have completed: > --- > Postinstall script finished. > Click the Finish button to exit the Setup wizard. > --- > close failed in file object destructor: > sys.excepthook is missing > lost sys.stderr > --- Sadly things are very subtle, and that alone doesn't mean the installation failed. You should be able to find a pywin32_postinstall.log file in your %temp% directory that contains a detailed log (the log that *should* be shown in that installation window) > Several of my colleagues failed to notice the subtle error message, and > believed that the installer succeeded. This led way to many problems > with PyWin32 not working later on. > > Could it be possible to somehow give a clearer user notification on > installer failure? Depending on that you are trying to do with pywin32, it may be possible to just copy the pywin32 directories and files, then run "python pywin32_postinstall.py -install" as part of the installation process you use and skip the pywin32 installer completely. HTH, Mark > > Thanks in advance > Fredrik > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > From Colin.Blair at GDIT.com Wed Mar 9 07:33:42 2016 From: Colin.Blair at GDIT.com (Blair, Colin S) Date: Wed, 9 Mar 2016 12:33:42 +0000 Subject: [python-win32] pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) Message-ID: Thank for the response. I have tried using the static proxy. The same error occurs. I have also tried adding DISP_E_EXCEPTION to the ERRORS_BAD_CONTEXT list in dynamic.py Same result. R, Colin B. Blair, Colin S wrote: > Please assist me with this error: > > Traceback (most recent call last): > > print msg.Body > File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 466, in > __getattr__ > return self._ApplyTypes_(*args) > File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 459, in > _ApplyTypes_self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), > pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) That's 0x80004005, which for MAPI is MAPI_E_CALL_FAILED. Very generic. Have you run gentypes.py on Outlook? Perhaps you should try to generate a static proxy: ol = win32com.client.gencache.EnsureDispatch("Outlook.Application") -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From laurent.solano at gmail.com Wed Mar 9 12:34:48 2016 From: laurent.solano at gmail.com (laurent solano) Date: Wed, 9 Mar 2016 18:34:48 +0100 Subject: [python-win32] equivalent selenium findElement(By.xpath...) with win32com In-Reply-To: References: Message-ID: Thanks for your proposal. I had already identified and look at the documentation about splinter. Sound great, but there is one missing feature : i need to automate an already open browser, where i'm already log in. With win32com, i can do it. below my code: class WindowMgr: """ Source : http://stackoverflow.com/questions/2090464/python-window-activation Classe de gestion des fen?tres, notamment pour faire des recherche avec expressions r?guli?res """ def __init__ (self): """Constructor""" self._handle = None def find_window(self, class_name, window_name = None): """find a window by its class_name""" self._handle = win32gui.FindWindow(class_name, window_name) def _window_enum_callback(self, hwnd, wildcard): '''Pass to win32gui.EnumWindows() to check all the opened windows''' if re.match(wildcard, str(win32gui.GetWindowText(hwnd))) != None: self._handle = hwnd def find_window_wildcard(self, wildcard): self._handle = None win32gui.EnumWindows(self._window_enum_callback, wildcard) def set_foreground(self): """put the window in the foreground""" win32gui.SetForegroundWindow(self._handle) class ie_mgr(): """ Classe de gestion de la fen?tre ie. Permet d'obtenir un objet repr?sentant la page ie de suviefluid """ def __init__ (self,titre_fenetre): """Constructor""" # Source : http://win32com.goermezer.de/content/view/168/131/ _clsid='{9BA05972-F6A8-11CF-A442-00A0C90A8F39}' # cl? du registre correspondant au ShellWindows _ShellWindows = win32com.client.Dispatch(_clsid) for i in range(_ShellWindows.Count): # Recherche de la fen?tre IE ? manipuler if re.match(r"suivefluid production*",_ShellWindows(i).LocationName): print("valeur ok : ", i) _index_shell = i break try: self.ie = _ShellWindows(_index_shell) self.doc = self.ie.Document self.bdy = self.doc.body self.Frame_haut = self.bdy.children(0) self.Frame_bas = self.doc.body.children(1) # On focus sur la frame contenant les valeurs ? ins?rer (la frame "bas") except NameError as e: print(e) SystemExit if __name__ == "__main__": fenetre_a_traiter = r".*windows_name.*" sf = ie_mgr(fenetre_a_traiter) #Instanciation du webbrowser w = WindowMgr() #Instanciation de la fen?tre ? traiter w.find_window_wildcard(fenetre_a_traiter) => After this, i can manipulate my browser like this : dURL = "my_URL" # URL sf.ie.Navigate(dURL,0,"frame_name") #Go ?cran missions (...) w.set_foreground() #Affichage de sf en premier plan => After this, i can seend keys to manipulate my browser _shell = win32com.client.Dispatch("WScript.Shell") # On instancie un objet permettant de simuler les touches clavier _shell.SendKeys("{TAB 34}") #Tab jusqu'? l'onglet mission _shell.SendKeys("{ENTER}") _shell.SendKeys("612") #Imput num?ro de mission ? rechercher _shell.SendKeys("{ENTER}") #Clic bouton rechercher and so on. I need to replace the sendkeys part by some good code like #Supposing "sf" is a splinter or selenium representation of my already running browser : sf.find_by_xpath(('//table[@id='tablename']/tbody/tr[1]/td[2]').click() (or something similar) nota : you hava my code Tim ;-). Laurent 2016-03-08 1:19 GMT+01:00 Christopher Nilsson : > Not really via the win32 api, but if you're looking for the python > equivalent of this selenium use-case, you should check out Splinter ( > http://splinter.readthedocs.org/en/latest/). > > You'll need phantomjs, or any other compatible web "driver" installed as > well though for this to work. > > I imagine achieving similar functionality with just win32 api will be a > pretty massive effort... > > On Mon, 7 Mar 2016 at 22:15 laurent solano > wrote: > >> Hi, >> >> For now, i make automation by simulating the keyboard. It's working, but not satisfying. >> >> What I want to do is the equivalent in Python win32 of this line of code (from java selenium) : >> >> - webDriver.findElement(By.name("valider")).click(); >> >> - confirmation = webDriver.findElement(By.xpath("//table[@id='tablename']/tbody/tr[1]/td[2]")).getText(); >> >> >> Using doc.valider.click() and doc.TheForm.valider.click() is not working. >> >> Using "createtree" method, i can find the first level (frameset), but nothing under this level. idem with "children" property. >> >> >> Any idea ? >> >> >> Laurent >> >> ---- >> >> Tim Roberts, timr at probo.com : >> >> Why don't you show us the code you have? The Internet Explorer COM >> >> object surface is very large, so we don't want to waste time explaining >> what you already know. >> >> >> 2016-02-22 9:46 GMT+01:00 laurent solano : >> >>> Hi, >>> >>> I'm automating ie webbrowser with win32com module. >>> >>> I need to locate some xpath elements to manipulate them. Is there a way >>> to do it ? >>> More or less, i need the same feature than findElement(By.xpath ...) >>> from selenium. >>> >>> Can anyone help ? >>> thanks in advance, >>> >>> Laurent, >>> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32 >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From malte.forkel at berlin.de Wed Mar 9 12:31:28 2016 From: malte.forkel at berlin.de (Malte Forkel) Date: Wed, 9 Mar 2016 18:31:28 +0100 Subject: [python-win32] Problem registering COM server at installation time In-Reply-To: References: <569A9F56.3000002@berlin.de> <3fd7e460-7f6d-4373-368b-117569b6decf@gmail.com> <56AFD995.4000209@berlin.de> Message-ID: <56E05DF0.3000605@berlin.de> According to eryk, it might help to "create a context at runtime from the manifest that's embedded in python27.dll". How would I do that? It sounds to me like it requires Windows programming skills (which unfortunately I don't have). Does "later MSVC versions no longer have this stupid requirement" mean that I shouldn't have a problem creating the COM server at installation time if a moved to Python 3.x? Malte Am 01.02.2016 um 23:24 schrieb Mark Hammond: > Eryk's reply is right on the money - I'd forgotten about that. IIRC, > having that manifest directly in pythoncomxx.dll or pywintypesxx.dll > ended up using a different activation context, which had its own > problems; that loader module exists purely to work around these problems. > > I'm still a bit confused as to why bdist_wininst isn't working for you > when that's the exact same stub used by the pywin32 installer, which > obviously does manage to load Python ok. > > (The good-ish news is that later MSVC versions no longer have this > stupid requirement, but that doesn't help the 2.x series) > > Mark > > On 2/02/2016 9:17 AM, Malte Forkel wrote: >> Am 01.02.2016 um 05:42 schrieb Mark Hammond: >>> On 17/01/2016 6:51 AM, Malte Forkel wrote: >>>> Hi, >>>> >>>> I'm trying the register a COM server using the install script of a >>>> built >>>> distribution, created with the bdist_wininst format of distutils. But >>>> the script fails with a message that MSVCR90.dll can't be found. >>>> Registering the server after the installer is done works fine. I'm >>>> using >>>> Python 2.7.11 and pywin32-220 on Windows 7.1 64 bit. >>> >>> That sounds a little strange - the script should only be executed >>> after python27.dll is loaded, which itself relies on msvcr90.dll. >>> >>> Does it happen to work if you put the installer executable in the same >>> directory as python27.dll? >>> >>> Mark >> >> Yes, same problem if the installer is run from C:\Windows\System32. >> >> Malte >> > > From timr at probo.com Wed Mar 9 13:12:18 2016 From: timr at probo.com (Tim Roberts) Date: Wed, 9 Mar 2016 10:12:18 -0800 Subject: [python-win32] equivalent selenium findElement(By.xpath...) with win32com In-Reply-To: References: Message-ID: <56E06782.3010508@probo.com> laurent solano wrote: > > I had already identified and look at the documentation about splinter. > Sound great, but there is one missing feature : i need to automate an > already open browser, where i'm already log in. > > With win32com, i can do it. below my code: You're doing this is in a somewhat unusual way. The COM server you're accessing here is the Windows shell, when then indirectly finds a web browser and opens it. Have you looked at the IEC module? At the lowest level, you can do ie = win32com.client.Dispatch("InternetExplorer.Application") You can then use ie.Document to get the IHTMLDocument2 interface for the visible tab. It's then possible to query through the DOM, although not with the usual DOM methods. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From laurent.solano at gmail.com Fri Mar 11 09:37:07 2016 From: laurent.solano at gmail.com (laurent solano) Date: Fri, 11 Mar 2016 15:37:07 +0100 Subject: [python-win32] equivalent selenium findElement(By.xpath...) with win32com Message-ID: Tim, I fear your proposal does not solve my problem. With ie = win32com.client.Dispatch("InternetExplorer.Application") : - how can I assign this "ie" object with my already running browser ? - how can I use function like ".find_by_xpath" with thie ie.object. I think splinter is a good way, just need to know how to connect it to my browser (i don't want to log in automaticaly, so i need to log in manually and after take control of my browser.) any ideas ? Laurent. ------------------------------ > > Message: 3 > Date: Wed, 9 Mar 2016 10:12:18 -0800 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] equivalent selenium > findElement(By.xpath...) with win32com > Message-ID: <56E06782.3010508 at probo.com> > Content-Type: text/plain; charset="utf-8" > > laurent solano wrote: > > > > I had already identified and look at the documentation about splinter. > > Sound great, but there is one missing feature : i need to automate an > > already open browser, where i'm already log in. > > > > With win32com, i can do it. below my code: > > You're doing this is in a somewhat unusual way. The COM server you're > accessing here is the Windows shell, when then indirectly finds a web > browser and opens it. Have you looked at the IEC module? > > At the lowest level, you can do > ie = win32com.client.Dispatch("InternetExplorer.Application") > > You can then use ie.Document to get the IHTMLDocument2 interface for the > visible tab. It's then possible to query through the DOM, although not > with the usual DOM methods. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > > ------------------------------ > > End of python-win32 Digest, Vol 156, Issue 5 > ******************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anwohot at hotmail.com Fri Mar 18 11:48:28 2016 From: anwohot at hotmail.com (Andreas) Date: Fri, 18 Mar 2016 15:48:28 +0000 Subject: [python-win32] Python 2.7.11 on Windows Server 2012 R2 standard - Error message "DLL load failed: %1 is not a valid Win32 application" after IMPORT WIN32SERVICE Message-ID: Hello, I have installed Python 2.7.11 - 64bit version on a Windows Server 2012 R2 Standard (64-bit version) from www.python.org/downloads/windows/ [cid:image001.png at 01D1812B.49530750] where I used the x86-64 MSI Installer No problems so far. When I run the following commands I get error messages: PS D:\> python27\python Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> import sys >>> import glob >>> import datetime >>> import time >>> import platform >>> import win32service Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: %1 is not a valid Win32 application. >>> import pywintypes Traceback (most recent call last): File "", line 1, in File "D:\python27\lib\site-packages\win32\lib\pywintypes.py", line 124, in __import_pywin32_system_module__("pywintypes", globals()) File "D:\python27\lib\site-packages\win32\lib\pywintypes.py", line 64, in __import_pywin32_system_module__ import _win32sysloader ImportError: DLL load failed: %1 is not a valid Win32 application. What is the reason? How can I solve this problem? Best regards Andreas -------------- next part -------------- An HTML attachment was scrubbed... URL: From tooke412 at yahoo.com Sat Mar 19 11:09:34 2016 From: tooke412 at yahoo.com (Joe) Date: Sat, 19 Mar 2016 15:09:34 +0000 (UTC) Subject: [python-win32] pywintypes.com_error- no data source was provided when sending outlook attachment References: <1496702959.1230862.1458400174947.JavaMail.yahoo.ref@mail.yahoo.com> Message-ID: <1496702959.1230862.1458400174947.JavaMail.yahoo@mail.yahoo.com> Hello,Iam trying to send an email through outlook 2010 on a win 7 64 bit oswith python 2.7 32 bit and win32com 32 bit. I am using the same codeexample found in many Google search results. This chunk of code willrun fine if I rem out the attachment, but once I try adding theattachment, I get an error about 'no data source provided'. Thissame sample of code appears to work fine in many instances, but I'vealso seen this error appear on the net since 2002. I've also changedthe attachment line use this format, and have tried it myself, butno luck#newMail.Attachments.Add('Location', olByValue, 1, 'Description') I've named changed the name of the attachment every way possible (r'c:\test.txt c:\test.txt c:\\test.txt) and I've placed it in other directories, but still the same error. Any suggestions importwin32com.clientolMailItem = 0x0 obj = win32com.client.Dispatch("Outlook.Application") newMail = obj.CreateItem(olMailItem) newMail.Subject = "I AM SUBJECT!!" newMail.Body = "I AM IN THE BODY\nSO AM I!!!" newMail.To = "themail at mail.org" #newMail.CC = "moreaddresses here" #newMail.BCC = "aaa" attachment1 = r'c:\test.txt' newMail.Attachments.Add(attachment1) newMail.Send() pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'Cannot add the attachment; no data source was provided.', None, 0, -2147352567), None) -------------- next part -------------- An HTML attachment was scrubbed... URL: From jacob at blindza.co.za Sun Mar 20 17:40:09 2016 From: jacob at blindza.co.za (jacob Kruger) Date: Sun, 20 Mar 2016 23:40:09 +0200 Subject: [python-win32] Something similar to py2exe for bundling python code into single file executables, using python 3.5.1? Message-ID: <56EF18B9.9020904@blindza.co.za> Like subject lines says, just wondering what's the simplest, easiest module/add-on, etc. to use for generating something close to a single file executable file when working with python 3.5.1? cx_freeze? AFAIK, py2exe isn't really usable with 3.5.1, as of yet? TIA Jacob Kruger Blind Biker Skype: BlindZA "Roger Wilco wants to welcome you...to the space janitor's closet..." From Paul_Koning at Dell.com Sun Mar 20 20:34:41 2016 From: Paul_Koning at Dell.com (Paul_Koning at Dell.com) Date: Mon, 21 Mar 2016 00:34:41 +0000 Subject: [python-win32] Something similar to py2exe for bundling python code into single file executables, using python 3.5.1? In-Reply-To: <56EF18B9.9020904@blindza.co.za> References: <56EF18B9.9020904@blindza.co.za> Message-ID: I haven't tried py2exe with Python 3.5.1 specifically, but it works just fine with Python 3.4. Give it a try. paul ________________________________________ ... AFAIK, py2exe isn't really usable with 3.5.1, as of yet? From timr at probo.com Sun Mar 20 23:53:58 2016 From: timr at probo.com (Tim Roberts) Date: Sun, 20 Mar 2016 20:53:58 -0700 Subject: [python-win32] Python 2.7.11 on Windows Server 2012 R2 standard - Error message "DLL load failed: %1 is not a valid Win32 application" after IMPORT WIN32SERVICE In-Reply-To: References: Message-ID: <722352A0-D768-4B6D-B931-4E2A0931AF19@probo.com> On Mar 18, 2016, at 8:48 AM, Andreas > wrote: I have installed Python 2.7.11 - 64bit version on a Windows Server 2012 R2 Standard (64-bit version) ... >>> import pywintypes Traceback (most recent call last): File "", line 1, in File "D:\python27\lib\site-packages\win32\lib\pywintypes.py", line 124, in __import_pywin32_system_module__("pywintypes", globals()) File "D:\python27\lib\site-packages\win32\lib\pywintypes.py", line 64, in __import_pywin32_system_module__ import _win32sysloader ImportError: DLL load failed: %1 is not a valid Win32 application. What is the reason? How can I solve this problem? It looks to me like you installed the 32-bit version of PyWin32. When you have a 64-bit Python, every extension you install has to be a 64-bit extension. Unlike the 16/32 transition, 64-bit Windows simply does not have the ability to mix 32-bit and 64-bit libraries in a single process. It is for this reason that I still tend to choose 32-bit Python. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Gindi.Khangura at Cerner.com Mon Mar 21 18:03:38 2016 From: Gindi.Khangura at Cerner.com (Khangura,Gindi) Date: Mon, 21 Mar 2016 22:03:38 +0000 Subject: [python-win32] C/C++ COM client calling Python COM server Message-ID: <200794D02F76F2439441AE2D0424DCDCCF019861@CERNMSGKC2MB3C.cerner.net> I have a COM server implemented in Python 2.7 (using pythoncom) that I am able to call using a Python or VBScript client. I would like to call the COM server from C/C++ code as well, but cannot find any information regarding this. My intention is to have a Python-only COM server that can be accessed by a Java application, VBScript script, and C/C++ DLL; this question is just focusing on the C/C++ part of it. The same question has been posted on SO with a bit more information: http://stackoverflow.com/questions/36142243/c-c-com-client-calling-python-com-server Any help would be appreciated. Thanks! - Gindi CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Mar 21 19:18:37 2016 From: timr at probo.com (Tim Roberts) Date: Mon, 21 Mar 2016 16:18:37 -0700 Subject: [python-win32] C/C++ COM client calling Python COM server In-Reply-To: <200794D02F76F2439441AE2D0424DCDCCF019861@CERNMSGKC2MB3C.cerner.net> References: <200794D02F76F2439441AE2D0424DCDCCF019861@CERNMSGKC2MB3C.cerner.net> Message-ID: <56F0814D.20308@probo.com> Khangura,Gindi wrote: > I have a COM server implemented in Python 2.7 (using pythoncom) that I > am able to call using a Python or VBScript client. I would like to > call the COM server from C/C++ code as well, but cannot find any > information regarding this. > My intention is to have a Python-only COM server that can be accessed > by a Java application, VBScript script, and C/C++ DLL; this question > is just focusing on the C/C++ part of it. Because C++ is a lower-level language, accessing an object is much wordier. In this particular instance, what you have is a late-binding "dispatch" interface, meaning that you can't just define a C++ class and fetch a pointer. You have to access everything indirectly. It's a pain in the ass. Here's a web page to get you started. https://msdn.microsoft.com/en-us/library/windows/desktop/ms221694.aspx The first sample shows how to start from a ProgID or CLSID (which you have) and get an IDispatch interface pointer. The second example shows a general-purpose "Invoke" function that can call a method on an IDispatch interface, given the method name and a list of parameters. You have to fetch the ID number for the method you want to call, then you have to create an argument array, then you call IDispatch::Invoke for that ID number. To call your one example function, this is approximately it: CComPtr pDispatch; pDispatch.CoCreateInstance( your_clsid ); DISPID id; pDispatch->GetIDsOfNames( IID_NULL, L"getNextNum", 1, LOCALE_USER_DEFAULT, &id ); DISPPARAMS dparams; ZeroMemory( &dparams, sizeof(DISPPARAMS) ); VARIANT vRet; VariantInit( &vRet ); Invoke( pDispatch, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dparams, &vRet, NULL, NULL ); The result comes back in vRet. The type will probably have vRet.vt == VT_I4, and the value is in V_I4(&vRet). This is why most people don't use late-binding IDispatch objects from C++. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jacob at blindza.co.za Tue Mar 22 09:37:44 2016 From: jacob at blindza.co.za (jacob Kruger) Date: Tue, 22 Mar 2016 15:37:44 +0200 Subject: [python-win32] Something similar to py2exe for bundling python code into single file executables, using python 3.5.1? In-Reply-To: References: <56EF18B9.9020904@blindza.co.za> Message-ID: <56F14AA8.8030500@blindza.co.za> Ok, turns out py2exe is definitely not compatible with 3.5.x - all online forum postings came across mention that, for example, under ./Lib/site-packages/py2exe there are no files relating to py35, so, will have to look into an alternative. Stay well Jacob Kruger Blind Biker Skype: BlindZA "Roger Wilco wants to welcome you...to the space janitor's closet..." On 2016-03-21 2:34 AM, Paul_Koning at Dell.com wrote: > I haven't tried py2exe with Python 3.5.1 specifically, but it works just fine with Python 3.4. Give it a try. > > paul > ________________________________________ > ... > AFAIK, py2exe isn't really usable with 3.5.1, as of yet? > > > From sanaaabdullah21 at gmail.com Sun Mar 27 05:33:58 2016 From: sanaaabdullah21 at gmail.com (Sanaa Abdullah) Date: Sun, 27 Mar 2016 11:33:58 +0200 Subject: [python-win32] Python Urrgent question Message-ID: Hi , I hope you're doing well. My name is Sanaa , and I wanted to ask you about a difficulty that I faced recently. I am trying to automate a couple of steps using pywinauto in python. I am trying to click the Button called "Test Instance" in the attached figure. The thing is that the name of the window is "Site Controller GUI Command Center - Version: 2.5.2.0 OfflineLSM ". Here is my tries : from pywinauto import application from pywinauto import findwindows from pywinauto import timings from pywinauto import application #initialize an instance of the Application class app = application.Application() app=app.Start("C:\\hdmt\\tos_2.5.2.0_release\\tosrelease\\bin\\release\\HdstSiteGuiWPF.exe") dlg='Site Controller GUI Command Center - Version: 2.5.2.0 OfflineLSM' app.dlg.TestInstance.Click() #print app._findwindows.find_windows() #app.top_window_().print_control_identifiers() please help me. I look forward to hearing from you. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Mar 28 14:03:55 2016 From: timr at probo.com (Tim Roberts) Date: Mon, 28 Mar 2016 11:03:55 -0700 Subject: [python-win32] Python Urrgent question In-Reply-To: References: Message-ID: <56F9720B.7040703@probo.com> Sanaa Abdullah wrote: > > I hope you're doing well. My name is Sanaa , and I wanted to ask you > about a difficulty that I faced recently. I am trying to automate a > couple of steps using pywinauto in python. I am trying to click the > Button called "Test Instance" in the attached figure. The thing is > that the name of the window is "Site Controller GUI Command Center - > Version: 2.5.2.0 OfflineLSM". pywinauto is not part of PyWin32. You should ask this question on the pywinauto mailing list. When you do, you need to tell them what you expected to happen, and what actually did happen. You did not say that here. Because we do not have your app, we can't run your sample. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.