[python-win32] pywintypes.com_error: (-2147467259, 'Unspecified error', None, None)

2016-03-09 Thread Blair, Colin S
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.
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] equivalent selenium findElement(By.xpath...) with win32com

2016-03-09 Thread laurent solano
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

Re: [python-win32] Problem registering COM server at installation time

2016-03-09 Thread Malte Forkel
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
>>
>
>


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] equivalent selenium findElement(By.xpath...) with win32com

2016-03-09 Thread Tim Roberts
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, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32