From jks55 at hotmail.com Fri Jun 3 18:45:57 2016 From: jks55 at hotmail.com (Jeff Shannon) Date: Fri, 3 Jun 2016 22:45:57 +0000 Subject: [python-win32] How to get access to existing Com Server custom class? Message-ID: Im using python 2.7.9, windows 7... The overall goal: Have another application access our custom com server (already running at this point) and send it a message to be displayed. Obviously, there needs to be a single server, multiple clients. Im trying to use some custom code as a com server. The class was created as: class StatusServerClass: _public_methods_ = ... _reg_progid_ = "CseStatusServerLib.CseStatusServer" _reg_verprogid_ = "CseStatusServerLib.CseStatusServer" _reg_progid_ = "CseStatusServerLib.CseStatusServer" _reg_clsid_ = "{}" _reg_desc_ = 'CSE Status Server' _typelib_guid_ = "{}" _typelib_version_ = 1, 0 # Version 1.0 _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _reg_threading_ = "Apartment" # Not used? def __init__..... and registered using: win32com.server.register.UseCommandLine(StatusServerClass) I can see it in regedit and as far as i know, it looks ok. The GUID is right, name is right. Now when i go to use it, this works just fine: self.StatusClient = Dispatch('CseStatusServerLib.CseStatusServer') but when i want to attach to a running instance from another exe (or even another python window for debug) using: win32com.client.GetActiveObject("CseStatusServerLib.CseStatusServer") it just gives me: dispatch = pythoncom.GetActiveObject(resultCLSID) com_error: (-2147221021, 'Operation unavailable', None, None) Tells me that its not registered? Ive tried using the GUID, Ive tried using pythoncom.GetObject with both the ID and the GUID... no luck. Ive tried comtypes package and get the same thing. Any ideas on what im doing wrong? Why does Dispatch find it by name, but GetActiveObject gets mad? Seems that Dispatch working by name would suggest that the registering worked? What else can i verify in the regedit? thanks!!! More testing... In case you haven't realized yet, I know very little about this. But I have read that for win32com.client.GetActiveObject() to work, the server needs to be in the "running object table"... and its not. So, I found some more example code that i used to register the class this way: import win32com.server.util wrapped = win32com.server.util.wrap(StatusServerClass) flags = pythoncom.REGCLS_MULTIPLEUSE|pythoncom.REGCLS_SUSPENDED handle = pythoncom.RegisterActiveObject(wrapped, StatusServerClass._reg_clsid_,flags) and that does allow the server to show in the running object table, and i can get this: testSW = win32com.client.GetActiveObject("CseStatusServerLib.CseStatusServer") to return without error. But when i try to use it to access a Write method thats part of the class, i get this: testSW.Write(Message = 'test') File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 525, in __getattr__ raise AttributeError("%s.%s" % (self._username_, attr)) AttributeError: CseStatusServerLib.CseStatusServer.Write so its like the original class information is gone. How can i register in the running object table and preserve my class methods? Also, seeing as how i know very little about this, by all means, suggest a better way of doing this: starting a server in python as a singleton and then accessing it from another application. thanks!! -------------- next part -------------- An HTML attachment was scrubbed... URL: From jrodriguezorjuela at luc.edu Wed Jun 8 11:51:12 2016 From: jrodriguezorjuela at luc.edu (Rodriguez Orjuela, Jose Luis) Date: Wed, 8 Jun 2016 15:51:12 +0000 Subject: [python-win32] Track-session-events Message-ID: Hello, I am writing a python script to track laptop usage. So far I am able to do simple stuffs username, machine, logon time, ip address, etc. Now I am trying to capture user logoff and sessions changes (screen lock). Related to user sessions I found a great blog ( http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html#isenslogon ) that explores some of this things but I haven't been able to identify the key parts that I can use in my case. I am looking to capture logoff datetime as well as screen lock and store it in a remote DB. Here is a fragment of the code in the blog that I am trying to use to accomplish this. It would be great if someone can guide me in the right direction. Thank you! def SvcOtherEx(self, control, event_type, data): if control == win32service.SERVICE_CONTROL_SESSIONCHANGE: sess_id = data[0] if event_type == 5: # logon msg = "Logon event: type=%s, sessionid=%s\n" % (event_type, sess_id) user_token = win32ts.WTSQueryUserToken(int(sess_id)) elif event_type == 6: # logoff msg = "Logoff event: type=%s, sessionid=%s\n" % (event_type, sess_id) else: msg = "Other session event: type=%s, sessionid=%s\n" % (event_type, sess_id) try: for key, val in self.GetUserInfo(sess_id).items(): msg += '%s : %s\n'%(key, val) except Exception, e: msg += '%s'%e logevent(msg) -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Jun 9 13:26:19 2016 From: timr at probo.com (Tim Roberts) Date: Thu, 9 Jun 2016 10:26:19 -0700 Subject: [python-win32] Track-session-events In-Reply-To: References: Message-ID: <8355e4a9-364f-547c-1dad-5f359990770b@probo.com> Rodriguez Orjuela, Jose Luis wrote: > > > I am writing a python script to track laptop usage. So far I am able > to do simple stuffs username, machine, logon time, ip address, etc. > Now I am trying to capture user logoff and sessions changes (screen > lock). Related to user sessions I found a great blog ( > http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html#isenslogon > > ) that explores some of this things but I haven?t been able to > identify the key parts that I can use in my case. I am looking to > capture logoff datetime as well as screen lock and store it in a > remote DB. Here is a fragment of the code in the blog that I am trying > to use to accomplish this. It would be great if someone can guide me > in the right direction. > I'm confused. What do you want to know? The code you posted is from a Windows service, which gets launched when the machine boots up and continues to run until the power turns off. That's the only way you can catch logoffs and session changes. Are you writing a service? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jrodriguezorjuela at luc.edu Thu Jun 9 14:44:10 2016 From: jrodriguezorjuela at luc.edu (Rodriguez Orjuela, Jose Luis) Date: Thu, 9 Jun 2016 18:44:10 +0000 Subject: [python-win32] Track-session-events In-Reply-To: <8355e4a9-364f-547c-1dad-5f359990770b@probo.com> References: <8355e4a9-364f-547c-1dad-5f359990770b@probo.com> Message-ID: <0e30f07a00b4492f89d9fbe5c4e8a4c9@mbxls1.adms.luc.edu> Tim thank you for responding. I did some reading and now I am more familiar with windows services. Basically yes I want to create a service to do the following: 1) Track logon time - send info to remote mongoDb 2) Track plugged/unplugged devices, battery level and some apps - send info to remote mongoDb 3) Track logoff time - send info to remote mongoDb So far I can track logon/logoff, plugged devices and battery level at logon/logoff by adding my script to the Users Local Group Policy, scripts (Logon/Logoff) section. I would like to write a service that every 2-5 min checks from devices, battery level and apps and sends the data to remote MongoDb. Then at logoff records the time and send it to the remote MongoDb instance. Thank you again for your help, sorry for the confusion! -----Original Message----- From: python-win32 [mailto:python-win32-bounces+jrodriguezorjuela=luc.edu at python.org] On Behalf Of Tim Roberts Sent: Thursday, June 09, 2016 12:26 PM To: Python-Win32 List Subject: Re: [python-win32] Track-session-events Rodriguez Orjuela, Jose Luis wrote: > > > I am writing a python script to track laptop usage. So far I am able > to do simple stuffs username, machine, logon time, ip address, etc. > Now I am trying to capture user logoff and sessions changes (screen > lock). Related to user sessions I found a great blog ( > http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html > #isenslogon > l%23isenslogon> > ) that explores some of this things but I haven't been able to > identify the key parts that I can use in my case. I am looking to > capture logoff datetime as well as screen lock and store it in a > remote DB. Here is a fragment of the code in the blog that I am trying > to use to accomplish this. It would be great if someone can guide me > in the right direction. > I'm confused. What do you want to know? The code you posted is from a Windows service, which gets launched when the machine boots up and continues to run until the power turns off. That's the only way you can catch logoffs and session changes. Are you writing a service? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 From asimkostas at gmail.com Tue Jun 14 04:57:24 2016 From: asimkostas at gmail.com (asimkon) Date: Tue, 14 Jun 2016 11:57:24 +0300 Subject: [python-win32] mod_python compilation error in VS 2008 for py2.7.1 Message-ID: I would like to ask you a technical question regarding python module compilation for python 2.7.1. I want to compile mod_python library for Apache 2.2 and py2.7 on Win32 in order to use it for psp - py scripts that i have written. I tried to compile it using VS 2008 (VC++) and unfortunately i get an error on pyconfig.h (Py2.7/include) error C2632: int followed by int is illegal. This problem occurs when i try to run the bat file that exists on mod_python/dist folder. Any idea or suggestion what should i do in order to run it on Win 7 Pro (win 32) environment and produce the final apache executable module (.so). For your better assistance, i attach you the necessary files and error_log (ouput that i get during compilation process). I have posted the same question here , but unfortunately i had had no luck! Additionally i give you the compilation instructions that i follow (used also MinGW-w64 and get the same error) in order to produce the final output! Compiling Open a command prompt with VS2008 support. The easiest way to do this is to use "Start | All Programs | Microsoft Visual Studio 2008 | Visual Studio Tools | Visual Studio 2008 Command Prompt". (This puts the VS2008 binaries in the path and sets up the lib/include environmental variables for the Platform SDK.) 1.cd to the mod_python\dist folder. 2.Tell mod_python where Apache is: set APACHESRC=C:\Apache 3. Run build_installer.bat. If it succeeds, an installer.exe will be created in a subfolder. Run that install the module. Kind Regards Kostas Asimakopoulos -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: getopt.h Type: text/x-chdr Size: 18564 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: unistd.h Type: text/x-chdr Size: 1753 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: mod_python_error.docx Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document Size: 17248 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pyconfig.h Type: text/x-chdr Size: 22098 bytes Desc: not available URL: From timr at probo.com Tue Jun 14 13:27:57 2016 From: timr at probo.com (Tim Roberts) Date: Tue, 14 Jun 2016 10:27:57 -0700 Subject: [python-win32] mod_python compilation error in VS 2008 for py2.7.1 In-Reply-To: References: Message-ID: <5a0e6668-1e84-8283-91b5-c9de5ac4bad0@probo.com> asimkon wrote: > I would like to ask you a technical question regarding python module > compilation for python 2.7.1. > > I want to compile mod_python > library for Apache 2.2 > and py2.7 on Win32 in order to use > it for psp - py scripts that i have written. I tried to compile it > using VS 2008 (VC++) and unfortunately i get an error on pyconfig.h > (Py2.7/include) error C2632: int followed by int is illegal. > > This problem occurs when i try to run the bat file that exists on > mod_python/dist folder. Any idea or suggestion what should i do in > order to run it on Win 7 Pro (win 32) environment and produce the > final apache executable module (.so). > > For your better assistance, i attach you the necessary files and > error_log (ouput that i get during compilation process). I have posted > the same question here > , > but unfortunately i had had no luck! Where did you get that copy of unistd.h? That's the problem, as you should have been able to figure out. Your unistd.h has #define ssize_t int which is a terrible practice to begin with. It causes this line in pyconfig.h typedef _W64 int ssize_t; to become this: typedef __w64 int int; just like the error message said. The quickest solution to your problem is to delete that line from unistd.h. Alternatively, you could had YY_NO_UNISTD_H to the compiler symbols, and have that file totally skipped. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Jun 14 13:30:53 2016 From: timr at probo.com (Tim Roberts) Date: Tue, 14 Jun 2016 10:30:53 -0700 Subject: [python-win32] mod_python compilation error in VS 2008 for py2.7.1 In-Reply-To: References: Message-ID: asimkon wrote: > > For your better assistance, i attach you the necessary files and > error_log (ouput that i get during compilation process). I have posted > the same question here > , > but unfortunately i had had no luck! And, by the way, don't ever send plain text files as Word documents, like you did here. Many open source people won't run Word at all because of virus concerns. Plus, as you should have seen, Word tried to just your text and made it virtually unreadable. Just paste it into Notepad and save it as a .txt file. Or, cut-and-paste it into the email. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bhmerchant at gmail.com Thu Jun 16 18:16:56 2016 From: bhmerchant at gmail.com (Brian Merchant) Date: Thu, 16 Jun 2016 15:16:56 -0700 Subject: [python-win32] How to drill down to the Firefox url bar using win32gui? Message-ID: Hi all, Using Inspect.exe, which comes with Windows SDK, I know that Firefox has a toolbar with name "Navigation Toolbar", which in turn has a child with name "Search or enter address". Using win32gui, I am able to get the handle of the Firefox window. However, then doing something like win32gui.EnumChildWindows to search through the windows of the Firefox window tells me that Firefox has no children. So, I am clearly thinking about this wrong -- how should I drill down to get a "handle" on the URL bar UI element? Once I get a "handle" on it, I intend to get its text (i.e. the current URL of the tab). Kind regards, Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From james at jls-radio.com Fri Jun 17 06:40:05 2016 From: james at jls-radio.com (James Scholes) Date: Fri, 17 Jun 2016 11:40:05 +0100 Subject: [python-win32] How to drill down to the Firefox url bar using win32gui? In-Reply-To: References: Message-ID: <2e37bfb0-045a-91b0-cb8f-01187a5d7f0d@jls-radio.com> Brian Merchant wrote: > Using Inspect.exe, which comes with Windows SDK, I know that Firefox has > a toolbar with name "Navigation Toolbar", which in turn has a child with > name "Search or enter address". These are exposed via accessibility APIs - Firefox has very comprihensive support for assistive technology tools. However... > Using win32gui, I am able to get the handle of the Firefox window. > However, then doing something like win32gui.EnumChildWindows to search > through the windows of the Firefox window tells me that Firefox has no > children. That's because the controls inside the Firefox window are not natively drawn. Notice that every control picked up by inspect.exe has the same window handle as the Firefox window itself. > So, I am clearly thinking about this wrong -- how should I drill down to > get a "handle" on the URL bar UI element? Once I get a "handle" on it, I > intend to get its text (i.e. the current URL of the tab). It might just be easier to parse the browser's session storage data which is updated constantly and in JSON, although I'm not entirely sure whether it's possible to gauge the currently displayed tab from that or not. Failing that, you'll need to investigate how to use the accessibility APIs to get what you want, which will probably be more difficult relative to using the window-related APIs you're used to. -- James Scholes http://twitter.com/JamesScholes From dhiraj.subramanian at techalien.in Tue Jun 21 08:44:35 2016 From: dhiraj.subramanian at techalien.in (Dhiraj Subramanian) Date: Tue, 21 Jun 2016 18:14:35 +0530 Subject: [python-win32] Issue with WMI connection timeout In-Reply-To: References: Message-ID: Hi all, I have been using Python WMI module for a while now, I am facing a problem with the remote connection. The script forever tries to acquire a connection with the remote machine without timing out. I did find a solution from preventing the connection to wait forever by introducing a timeout (passing "*security_flags=0x80*" as an argument), but this is not working for me. The link is specified below for the solution that I found. Is there anyway to timeout the connection to the remote machine from freezing the script. Link : http://timgolden.me.uk/python/wmi/wmi.html Regards, Dhiraj -------------- next part -------------- An HTML attachment was scrubbed... URL: From webguy at totalrewind.com Wed Jun 22 20:04:09 2016 From: webguy at totalrewind.com (Kurt Eilander) Date: Wed, 22 Jun 2016 18:04:09 -0600 Subject: [python-win32] shell_view.py folder not browsable Message-ID: <675dbf6d-5128-0698-9dfd-7494993157ae@totalrewind.com> Hey all, I was hoping to create my own IShellFolder in python, but there seems to be something wrong with the example on my system. (Win7 64bit, Python 2.7) The folder shows up on the desktop, but I cannot open it. I saw an earlier thread where the solution was to right-click and select 'explore', but that doesn't even work for me. The context menu only has Cut, Create Shortcut, and Delete. Not seeing any errors in the syslogs. Any fixes or suggestions would be most appreciated! Thanks in advance, -Kurt From asharvce at gmail.com Thu Jun 23 09:56:34 2016 From: asharvce at gmail.com (Asha Eshu) Date: Thu, 23 Jun 2016 15:56:34 +0200 Subject: [python-win32] Win32 com module error Message-ID: Hello, I have python 32 bit version 3.5.1 with win32com module installed . I have also pywin32 32-bit. I am getting the following error File "C:\Program Files (x86)\Python35-32\lib\site-packages\win32com\client\dyn amic.py", line 89, in _GetGoodDispatch IDispatch = pythoncom.connect(IDispatch) pywintypes.com_error: (-2147221021, 'Vorgang nicht verf?gbar.', None, None) Could you please suggest what is the problem and solution for the same Thank you regards, asha -------------- next part -------------- An HTML attachment was scrubbed... URL: From hariharan.rh at hcl.com Thu Jun 23 01:22:08 2016 From: hariharan.rh at hcl.com (R Hariharan) Date: Thu, 23 Jun 2016 05:22:08 +0000 Subject: [python-win32] Unable to extract sender email address across servers Message-ID: Hi , I am unable to Extract the Sender Email Address of Emails from Sent Items folder in MS Outlook 2013 in python. I have used Email Parser and pywin 32. Email Parser is extracting the Sender Email Address from Inbox and pywin32 for Sent items. However I am getting /OU=EXCHANGE ADMINISTRATIVE GROUP (some hex number)/CN=RECIPIENTS.. message in place of valid email address. This is happening for across server extraction. However, Local server extraction of sender email address is successful from sent items using pywin 32. Any help on this would be really helpful. Thanks, Hari ::DISCLAIMER:: ---------------------------------------------------------------------------------------------------------------------------------------------------- The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects. ---------------------------------------------------------------------------------------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Jun 24 03:32:01 2016 From: timr at probo.com (Tim Roberts) Date: Fri, 24 Jun 2016 00:32:01 -0700 Subject: [python-win32] Win32 com module error In-Reply-To: References: Message-ID: <78B9C356-C2F7-4C27-9C3B-683A7951EFE9@probo.com> On Jun 23, 2016, at 6:56 AM, Asha Eshu > wrote: I have python 32 bit version 3.5.1 with win32com module installed . I have also pywin32 32-bit. I am getting the following error File "C:\Program Files (x86)\Python35-32\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch IDispatch = pythoncom.connect(IDispatch) pywintypes.com_error: (-2147221021, 'Vorgang nicht verf?gbar.', None, None) -2147221021 is 0x800401E3, which is ?operation not available.? What COM object were you trying to instantiate? Are you ABSOLUTELY sure that you have a 32-bit version of that object installed? You can?t cross the 32/64 boundary with in-process COM objects. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Jun 24 12:49:14 2016 From: timr at probo.com (Tim Roberts) Date: Fri, 24 Jun 2016 09:49:14 -0700 Subject: [python-win32] Win32 com module error In-Reply-To: References: <78B9C356-C2F7-4C27-9C3B-683A7951EFE9@probo.com> Message-ID: Asha Eshu wrote: > > yes. The COM Object, python and the application which i am invoking > is also 32-bit. > its is just a win32com.client.Dispatc("a.application"); > > I have this error for the Interface. I'm not sure what you mean by the last sentence. You are dribbling out only tiny pieces of partial information, which makes it very difficult for us to do any analysis. Does the error occur when you call win32com.client.Dispatch, or does it happen later? The full traceback would have shown that, but you didn't give us a full traceback. Is this a COM server that you wrote? Is it in-process or out-of-process? Have you verified that you can instantiate this object from other languages? It's pretty easy to test COM interfaces from VBScript or PowerShell. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ford99 at ntlworld.com Fri Jun 24 13:44:58 2016 From: ford99 at ntlworld.com (ford99 at ntlworld.com) Date: Fri, 24 Jun 2016 20:44:58 +0300 Subject: [python-win32] improvement Message-ID: <000049a60f13$24769e52$8de0f9ae$@ntlworld.com> Hi, I've noticed a great improvement in your work, and I need your opinion about an issue, please take a look Kind regards, ford99 at ntlworld.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tabu1989 at gmail.com Thu Jun 30 08:23:21 2016 From: tabu1989 at gmail.com (Nabeela) Date: Thu, 30 Jun 2016 16:23:21 +0400 Subject: [python-win32] win32 error running on python 3 and win 64 machine Message-ID: Hi, i'm trying to run the following code and get this error import win32com.client as win32import os excel = win32.gencache.EnsureDispatch('Excel.Application') Traceback (most recent call last): File "C:\Users\nabeelah.bijapur\Documents\Anaconda3\lib\site-packages\win32com\client\gencache.py", line 532, in EnsureDispatch ti = disp._oleobj_.GetTypeInfo() pywintypes.com_error: (-2147418111, 'Call was rejected by callee.', None, None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "C:\Users\nabeelah.bijapur\Documents\Anaconda3\lib\site-packages\win32com\client\gencache.py", line 543, in EnsureDispatch raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object") TypeError: This COM object can not automate the makepy process - please run makepy manually for this object What is the solution for this. -------------- next part -------------- An HTML attachment was scrubbed... URL: