pywin32

How to retrieve the selected text from the active window

浪子不回头ぞ 提交于 2019-11-27 01:23:56
问题 I am trying to create a simple open source utility for windows using Python that can perform user-defined actions on the selected text of the currently active window. The utility should be activated using a pre-defined keyboard shortcut. Usage is partially outlined in the following example: The user selects some text using the mouse or the keyboard (in any application window) The user presses a pre-defined keyboard shortcut The selected text is retrieved by our utility or copied to clipboard

How to check if OS is Vista in Python?

家住魔仙堡 提交于 2019-11-27 01:05:09
问题 How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython? Essentially, I need a function that called will return True iff current OS is Vista: >>> isWindowsVista() True 回答1: Python has the lovely 'platform' module to help you out. >>> import platform >>> platform.win32_ver() ('XP', '5.1.2600', 'SP2', 'Multiprocessor Free') >>> platform.system() 'Windows' >>> platform.version() '5.1.2600' >>> platform.release() 'XP' NOTE: As

Can't start Windows service written in Python (win32serviceutil)

南楼画角 提交于 2019-11-27 00:57:15
问题 I'm trying to start a simple service example: someservice.py: import win32serviceutil import win32service import win32event class SmallestPythonService(win32serviceutil.ServiceFramework): _svc_name_ = "SmallestPythonService" _svc_display_name_ = "display service" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event

Symlinks on windows?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 00:20:24
Does anyone know of a way to make/read symbolic links across versions of win32 from Python? Ideally there should be a minimum amount of platform specific code, as I need my app to be cross platform. Anurag Uniyal NTFS file system has junction points, I think you may use them instead, You can use python win32 API module for that e.g. import win32file win32file.CreateSymbolicLink(fileSrc, fileTarget, 1) If you do not want to rely on win32API module, you can always use ctypes and directly call CreateSymbolicLink win32 API e.g. import ctypes kdll = ctypes.windll.LoadLibrary("kernel32.dll") kdll

import win32api error in Python 2.6

夙愿已清 提交于 2019-11-27 00:08:59
When running python26 under windows OS (64bits)..... I have got errors like: import win32api" error in Python 2.6: pywintypes26.dll or pythoncom26.dll missing ImportError: DLL load failed: The specified module could not be found. I have done the msi installation for python26 all dlls can be found under C:\Python26\Lib\site-packages\pywin32_system32 After I move/copy pywintypes26.dll and pythoncom26.dll to c:\Python26\Lib\site-packages\win32 -> Solve the problem! Dave Bremer I also hit a problem importing win32api. The post-install script for pywin32 failed, which should copy pythoncom26.dll ,

Can't load pywin32 library win32gui

半腔热情 提交于 2019-11-26 23:31:02
问题 I'm trying to use the win32gui module included with pywin32 but I can't get it working. I have downloaded it, built it and everything seem to be located under site-packages, I've found win32gui.pyd at site-packages/win32/win32gui.pyd but when I try to import it I get: import pyHook, win32gui ImportError: DLL load failed: The specified module could not be found. Do I need to move a dll somewhere? and if so, which one? 回答1: My guess is that win32gui depends on some DLL that is not on your

GetWindowRect too small on Windows 7

我的梦境 提交于 2019-11-26 22:45:59
The actual problem I'm trying to solve is, I want to automatically find out the size of the margins around windows. If you can find a better way, please by all means answer that instead of this. To do this I decided to take a screenshot of a test window and measure the margins. This is simple enough, as I expect no margins will ever be bright pink, but I admit it's a hack. I use GetWindowRect ( py ) to get the bounding box, and PIL to grab a screenshot and crop to the bounding box. The problem is that while the crop operates correctly, the bounding box is not accurate . The Windows 7 "Snipping

How to catch printer event in python

荒凉一梦 提交于 2019-11-26 21:24:46
问题 I want to catch the signal when the printer started to print. That would be fine if you tell me how to get the path of document that will print. pywin32print looks like useful but I don't know how to use. 回答1: To be notified of new print jobs, you can use FindFirstPrinterChangeNotification, FindNextPrinterChangeNotification , and a wait function from kernel32 such as WaitForSingleObject. Here's an example to set a filter that waits for a new print job on the local print server. There's much

Python, get windows special folders for currently logged-in user

元气小坏坏 提交于 2019-11-26 20:26:45
How can I get Windows special folders like My Documents, Desktop, etc. from my Python script? Do I need win32 extensions? It must work on Windows 2000 to Windows 7. You can do it with the pywin32 extensions: from win32com.shell import shell, shellcon print shell.SHGetFolderPath(0, shellcon.CSIDL_MYPICTURES, None, 0) # prints something like C:\Documents and Settings\Username\My Documents\My Pictures # (Unicode object) Check shellcon.CSIDL_xxx for other possible folders. I think using pywin32 is the best way. Else you'd have to use ctypes to access the SHGetFolderPath function somehow (other

How to install pywin32 module in windows 7 [duplicate]

ⅰ亾dé卋堺 提交于 2019-11-26 19:14:42
问题 This question already has answers here : ImportError: no module named win32api (5 answers) Closed 4 months ago . I am trying to install pywin32. I downloaded it from sourceforge.net. When I run setup.py install it shows "Unable to find vcvarsall.bat". I Googled about it and found that I have to install MinGW and set path then run python setup.py build --compiler=mingw32 but it's showing Can't find a version in Windows.h Can anybody help? (I have a trial version of Visual Studio 2010 Ultimate