pywin32

Write image to Windows clipboard in python with PIL and win32clipboard?

廉价感情. 提交于 2019-11-26 17:17:31
问题 I'm trying to open an image file and copy the image to the Windows clipboard. Is there a way to fix this: import win32clipboard from PIL import Image def send_to_clipboard(clip_type, data): win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardData(clip_type, data) win32clipboard.CloseClipboard() clip_type = win32clipboard.CF_BITMAP filepath = 'c:\\temp\\image.jpg' im = Image.open(filepath) data = im.tobitmap() # fails with valueerror: not a bitmap # data =

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

徘徊边缘 提交于 2019-11-26 14:39:52
问题 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? 回答1: You are

Get other running processes window sizes in Python

风流意气都作罢 提交于 2019-11-26 13:21:30
问题 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

Creating a python win32 service

风流意气都作罢 提交于 2019-11-26 12:57:35
问题 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

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

我的未来我决定 提交于 2019-11-26 12:17:17
问题 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. 回答1: 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

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

一笑奈何 提交于 2019-11-26 12:02:51
问题 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? 回答1: 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:\...

Python 3.4 :ImportError: no module named win32api

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 11:12:09
问题 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

Scrapy

拥有回忆 提交于 2019-11-26 09:30:41
找到问题的那一刻,骂了自己N次的猪脑子!!! 问题:爬虫脚本本来一切正常的,临时有其他事情耽搁了,然后回头正式运行的时候发现一只报错 [twisted] CRITICAL: Unhandled error in Deferred,错误就是下面这样的(因为都一样的错误,所以直接从网上贴过来的): 2016-03-13 08:50:50 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsole, LogStats, CoreStats, SpiderState Unhandled error in Deferred: 2016-03-13 08:50:50 [twisted] CRITICAL: Unhandled error in Deferred: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 150, in _run_command cmd.run(args, opts) File "/usr/local/lib/python2.7/dist-packages/scrapy/commands/crawl.py", line 57, in run self

Symlinks on windows?

你。 提交于 2019-11-26 09:23:25
问题 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. 回答1: 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

import win32api error in Python 2.6

若如初见. 提交于 2019-11-26 07:26:05
问题 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 回答1: After I copy pywintypes26.dll and pythoncom26.dll from C:\Python26\Lib\site-packages\pywin32_system32 to C:\Python26\Lib\site-packages