pywin32

Win32api is not giving the correct coordinates with GetCursorPos() in python

心不动则不痛 提交于 2019-11-27 09:22:50
When using the win32api from pywin, I am getting incorrect values for the cursor position. My screen's resolution is 1920x1080, but when I use GetCursorPos() I have (0,0) in the top left and (1535,863) in the bottom right. The code I am using is as follows: import win32api def getCursor(): print win32api.GetCursorPos() I am trying this using python 2.7 on windows 10, but I was also getting this error in python 2.6 on windows 8. Is there any solution or workaround to this problem? You are subject to DPI virtualization . Your application has not declared itself aware of high DPI and you have a

win32file.ReadDirectoryChangesW doesn't find all moved files

瘦欲@ 提交于 2019-11-27 08:35:28
问题 Good morning, I've come across a peculiar problem with a program I'm creating in Python. It appears that when I drag and drop files from one location to another, not all of the files are registered as events by the modules. I've been working with win32file and win32con to try an get all events related to moving files from one location to another for processing. Here is a snip bit of my detection code: import win32file import win32con def main(): path_to_watch = 'D:\\' _file_list_dir = 1 #

Python 3.4 :ImportError: no module named win32api

核能气质少年 提交于 2019-11-27 08:05:50
I am using python 3.4 on windows 7.In order to open a doc file i am using this code import sys import win32com.client as win32 word = win32.Dispatch("Word.Application") word.Visible = 0 word.Documents.Open("MyDocument") doc = word.ActiveDocument M not sure why is this error popping up everytime ImportError: no module named win32api Although i have installed pywin32 from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32 and i have also checked the path from where i am importing...i have tried reinstalling pywin32 as well but that doesnt remove the error..... any suggestions....please help

Get other running processes window sizes in Python

独自空忆成欢 提交于 2019-11-27 07:31:07
This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processes are only 800x600 despite there being a huge resolution then that is probably what the user wants. Why make them waste time and energy resizing my window to match all the others they have? I am primarily a Windows devoloper but it wouldn't upset me in the least if there was a cross platform way to do this. Using hints from WindowMover article

How to control the size of the Windows shell window from within a python script?

无人久伴 提交于 2019-11-27 07:15:14
问题 When launching a script-type python file from Windows you get a windows shell type window where the script runs. How can the script determine and also set/control the Window Size, Screen Buffer Size and Window Position of said window?. I suspect this can be done with the pywin32 module but I can't find how. 回答1: You can do this using the SetConsoleWindowInfo function from the win32 API. The following should work: from ctypes import windll, byref from ctypes.wintypes import SMALL_RECT STDOUT =

Creating a python win32 service

ぃ、小莉子 提交于 2019-11-27 06:56:11
I am currently trying to create a win32 service using pywin32. My main point of reference has been this tutorial: http://code.activestate.com/recipes/551780/ What i don't understand is the initialization process, since the Daemon is never initialized directly by Daemon(), instead from my understanding its initialized by the following: mydaemon = Daemon __svc_regClass__(mydaemon, "foo", "foo display", "foo description") __svc_install__(mydaemon) Where svc_install , handles the initalization, by calling Daemon. init () and passing some arguments to it. But how can i initialize the daemon object,

What can you do with COM/ActiveX in Python? [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 06:30:20
I've read that it is possible to automate monthly reports in Crystal Reports with COM/ActiveX. I'm not that advanced to understand what this is or what you can even do with it. I also do a lot of work with Excel and it looks like you also use COM/ActiveX to interface with it. Can someone explain how this works and maybe provide a brief example? luc First you have to install the wonderful pywin32 module. It provides COM support. You need to run the makepy utility. It is located at C:\...\Python26\Lib\site-packages\win32com\client . On Vista, it must be ran with admin rights. This utility will

Windows explorer context menus with sub-menus using pywin32

坚强是说给别人听的谎言 提交于 2019-11-27 05:22:52
问题 I'm trying add some shell extensions using python with icons and a sub menu but I'm struggling to get much further than the demo in pywin32. I can't seem to come up with anything by searching google, either. I believe I need to register a com server to be able to change the options in submenu depending on where the right clicked file/folder is and the type of file etc. # A sample context menu handler. # Adds a 'Hello from Python' menu entry to .py files. When clicked, a # simple message box

Connect to Exchange mailbox with Python [closed]

瘦欲@ 提交于 2019-11-27 05:07:39
问题 I need to connect to an Exchange mailbox in a Python script, without using any profile setup on the local machine (including using Outlook). If I use win32com to create a MAPI.Session I could logon (with the Logon() method) with an existing profile, but I want to just provide a username & password. Is this possible? If so, could someone provide example code? I would prefer if it only used the standard library and the pywin32 package. Unfortunately, enabling IMAP access for the Exchange server

Need skeleton code to call Excel VBA from PythonWin

核能气质少年 提交于 2019-11-27 03:00:25
问题 I need to invoke a VBA macro within an Excel workbook from a python script. Someone else has provided the Excel workbook with the macro. The macro grabs updated values from an external database, and performs some fairly complex massaging of the data. I need the results from this massaging, and I don't really want to duplicate this in my Python script, if I can avoid it. So, it would be great if I could just invoke the macro from my script, and grab the massaged results. Everything I know