pythoncom

How to pass arguments to win32com event handler

自闭症网瘾萝莉.ら 提交于 2019-12-24 03:41:34
问题 The code below works fine. I can't find a way to pass some arguments to EventHandler or to call methods of MainClass from EventHandler . For example instead of using constant param , I'd like to pass it through constructor or setter method. I've tried recommendations from here. But in this case EventHandler instance does not catch any events (or at least nothing appears in stdout). class EventHandler: param = "value" def OnConnected(self): print 'connected' return True class MainClass: def

Script in Python crashed when alt+tab is pressed repeatedly (pyhook and pythoncom)

喜欢而已 提交于 2019-12-22 12:29:29
问题 I'm making a script in Python 3.5.2 on windows 10 that capture the keys that user press.The code works perfectly except when I press alt+tab to switch the windows, sometimes crashes immediately and sometimes crashes when I press it repeatedly. The most basic code is next: import pythoncom, pyHook def OnKeyboardEvent(event): print ('Ascii:', event.Ascii, chr(event.Ascii)) return True # create a hook manager hm = pyHook.HookManager() # watch for all keyboard events hm.KeyDown = OnKeyboardEvent

How to continuously monitor a new mail in outlook and unread mails of a specific folder in python

本秂侑毒 提交于 2019-12-18 07:13:07
问题 I want to check for a particular sender email and process it automatically wherever it arrives However, there may be some situation where my outlook was restarted, mean while i received mail from sender and marked as unread For continuous monitor for a new mail for a specific subject i have found the following code import win32com.client import pythoncom import re class Handler_Class(object): def OnNewMailEx(self, receivedItemsIDs): # RecrivedItemIDs is a collection of mail IDs separated by a

pythoncom crashes on KeyDown when used hooked to certain applications

天大地大妈咪最大 提交于 2019-12-17 10:56:10
问题 I wrote this code on to observe the event of a keydown motion. The problem appears to be that when this script is run, certain programs will crash this program, spitting out this error message: TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk_ code', 'scan_code', 'ascii', 'flags', 'time', 'hwnd', and 'win_name' Some programs observed to crash are: Skype, Sublime Text 2 After a few trials at debugging it, the problem appears to be occurring on the final line but

Tkinter text entry with pyHook hangs GUI window

心已入冬 提交于 2019-12-13 07:04:52
问题 I have a Tkinter GUI application that I need to enter text in. I cannot assume that the application will have focus, so I implemented pyHook, keylogger-style. When the GUI window does not have focus, text entry works just fine and the StringVar updates correctly. When the GUI window does have focus and I try to enter text, the whole thing crashes. i.e., if I click on the console window or anything else after launching the program, text entry works. If I try entering text immediately (the GUI

When getting Document object from Word.Application object, its members are not filled from gencache cache while VBSEdit is able to get them

余生长醉 提交于 2019-12-12 19:17:58
问题 https://mail.python.org/pipermail/python-win32/2004-October/002582.html summarizes my problem perfectly (with slight edits to update it for my case): I would like to have a Word Document instance with all methods and properties visible during interactive session. This is my currnet apporach: >>> from win32com.client import gencache, Dispatch >>> gencache.EnsureModule('{00020905-0000-0000-C000-000000000046}', 0, 8, 1, bForDemand=True) <module 'win32com.gen_py.00020905-0000-0000-C000

pythoncom.CoCreateInstance can't create IZoneIdentifier; the interface is missing from registry too despite being documented in MSDN

时光怂恿深爱的人放手 提交于 2019-12-12 04:14:34
问题 I'm trying to implement Manipulating the zone identifier to specify where a file was download from – The Old New Thing - MSDN blogs in Python. At CoCreateInstance : pythoncom.CoCreateInstance( pywintypes.IID('{0968e258-16c7-4dba-aa86-462dd61e31a3}'), #CLSID_PersistentZoneIdentifier None,pythoncom.CLSCTX_ALL, pywintypes.IID('{cd45f185-1b21-48e2-967b-ead743a8914e}')) #IID_IZoneIdentifier I get an error: TypeError: There is no interface object registered that supports this IID (No stacktrace as