pywin32

Trouble capturing window with winAPI BitBlt for some applications only

大兔子大兔子 提交于 2019-12-13 00:10:24
问题 I've put together a simple python script that is supposed to take a screenshot of a window whose name contains a specific string. The code I use is the following, import win32gui, win32ui, win32con import PIL.Image def getWindowHandle(name): windowList = [] win32gui.EnumWindows(lambda hwnd, wndList: wndList.append((win32gui.GetWindowText(hwnd), hwnd)), windowList) for pair in windowList: if name in pair[0]: return pair[1] return None class Window(): def __init__(self, hwnd = None): if not

PyWin32 using MakePy utility and win32com to get Network Statistics

穿精又带淫゛_ 提交于 2019-12-12 17:12:02
问题 This question is in continuation to my previous question. I am trying to get Network Statistics for my Windows 7 system using PyWin32 . The steps I followed: 1) Run COM MakePy utility and than select network list manager 1.0 type library under type library. 2) Above process generated this python file. Next I created the object of class NetworkListManager(CoClassBaseClass) using import win32com.client as wc obj = wc.Dispatch("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}") Now I am trying to access

Python ctypes: SetWindowsHookEx callback function never called

旧城冷巷雨未停 提交于 2019-12-12 12:33:58
问题 I'm trying to write a program in Python that is aware of when alert boxes/dialogues are shown. It's dealing with multiple monitors, and I want it to display a visualization on the secondary monitor when a taskbar icon flashes, an error/notification pops up, etc. As far as I can tell, the way to do detect these events is using message hooks, as described here: http://msdn.microsoft.com/en-us/library/ms632589%28v=vs.85%29.aspx I was even lucky enough to find an example that accesses the

exiting a loop by pressing a escape key

微笑、不失礼 提交于 2019-12-12 11:08:36
问题 I am trying to exit a loop by pressing a escape key but my program doesn't work. Is there a way to do that? My code : import win32api import win32con import time from msvcrt import kbhit,getch def clickerleft(x,y): """Clicks on given position x,y Input: x -- Horizontal position in pixels, starts from top-left position y -- Vertical position in pixels, start from top-left position """ win32api.SetCursorPos((x,y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0) win32api.mouse_event

py2exe - No system module 'pywintypes'

梦想的初衷 提交于 2019-12-12 08:23:25
问题 I'm trying to convert a simple Python script into a Windows executable. My setup.py script is: from distutils.core import setup import py2exe setup( name = "Simple Script", options = { "py2exe": { "dll_excludes" : ["libmmd.dll","libifcoremd.dll","libiomp5md.dll","libzmq.dll"] } }, console=['simple_script.py'] ) I have added the dll_excludes as each one of them caused a failure. Now I've hit a failure that I can't simply exlude. This is the error trace: Traceback (most recent call last): File

How to access a subfolder in Outlook inbox in Python

风格不统一 提交于 2019-12-12 04:32:47
问题 I have created a rule in Outlook to move all incoming messages from a particular sender to a subfolder in my Inbox.Like - Inbox - Subfolder I wrote a piece of code import win32com.client outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox = outlook.GetDefaultFolder(6) #6 = Inbox (without mails from the subfolder) messages = inbox.Items message = messages.GetLast() body_content = message.body print body_content #Sometimes has parsing error due to different

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

Word : Deleting Lines in between a Table and a Heading using Python

你。 提交于 2019-12-12 03:56:10
问题 I have a scenario in which there is a Heading/Constant Text like "Call Tree:" present all over the Word document and after that there are some lines, and once the line are over, there is a Table . So I want the lines between the table and the Heading/Constant Text "Call Tree:" to be deleted using python/win32 component. For Example : Input is : ... Call Tree : Line 1 ... Line 2 ... .... .... .... .... Line N .... Table # 1 ..... Output is (i.e. all the lines in between the table and "Call

List of installed programs

人盡茶涼 提交于 2019-12-11 22:25:40
问题 I use the search in the register and the Win32_Product class to get the list of the programs installed on the computer, but it doesn’t give all the programs, I’ve seen programs in C ++ that give the same results as in the programs and components of the control panel. Is there any api for python that can give me the same result. Here is the code for c ++ https://www.codeproject.com/Articles/6791/How-to-get-a-list-of-installed-applications That's what i use: import win32com.client strComputer =

Get DNS search suffix in Python

时间秒杀一切 提交于 2019-12-11 22:04:26
问题 Does anyone know how to get a list of DNS search suffixes on a client - both ones that have been manually added and ones assigned by DHCP. I'd prefer to have a cross-platform solution, but a Windows only solution will work. I couldn't find anything in pywin32 or other modules... 回答1: After a bit of investigation, it doesn't look like there is a cross-platform way since the OS stores this information differently. On Windows, I ended up querying the information via the registry: def