pywin32

Passing utf-16 string to a Windows function

我怕爱的太早我们不能终老 提交于 2020-01-15 09:20:38
问题 I have a Windows dll called some.dll with the following function: void some_func(TCHAR* input_string) { ... } some_func expects a pointer to utf-16 encoded string. Running this python code: from ctypes import * some_string = "disco duck" param_to_some_func = c_wchar_p(some_string.encode('utf-16')) # here exception! some_dll = ctypes.WinDLL(some.dll) some_dll.some_func(param_to_some_func) fails with exception "unicode string or integer address expected instead of bytes instance " The

Passing utf-16 string to a Windows function

久未见 提交于 2020-01-15 09:20:28
问题 I have a Windows dll called some.dll with the following function: void some_func(TCHAR* input_string) { ... } some_func expects a pointer to utf-16 encoded string. Running this python code: from ctypes import * some_string = "disco duck" param_to_some_func = c_wchar_p(some_string.encode('utf-16')) # here exception! some_dll = ctypes.WinDLL(some.dll) some_dll.some_func(param_to_some_func) fails with exception "unicode string or integer address expected instead of bytes instance " The

Windows XP - mute/unmute audio in programmatically in Python

不打扰是莪最后的温柔 提交于 2020-01-14 03:37:05
问题 My machine has two audio inputs: a mic in that I use for gaming, and a line in that I use for guitar. When using one it's important that the other be muted to remove hiss/static, so I was hoping to write a small script that would toggle which one was muted (it's fairly inconvenient to click through the tray icon, switch to my input device, mute and unmute). I thought perhaps I could do this with pywin32, but everything I could find seemed specific to setting the output volume rather than

Define mailbox to which to save an email - win32client python

自作多情 提交于 2020-01-14 01:35:28
问题 I would like to save an email to the drafts folder of a shared mailbox using the win32 API for Outlook. I can save an email to my (default?) mailbox drafts folder using the below: def TestEmailer(text, subject, recipient): outlook = win32.Dispatch('outlook.application') mail = outlook.CreateItem(0) mail.To = recipient mail.Subject = subject mail.HtmlBody = text mail.Save() TestEmailer('hello world', 'test', 'recipient@gmail.com') Thanks to this previous question I can see that the

Is there a way to automate BLF to CSV conversion in Vector CANoe?

眉间皱痕 提交于 2020-01-13 16:56:52
问题 My first approach was using python-can (as it added support for parsing BLF files with 2.0.0 release) like this: import can filename = "logfile.blf" logging = can.BLFReader(filename) for msg in logging: print(msg) but that resulted in an error that I reported to the developer. BLF format is proprietary and somewhat secret so I understand supporting it in an open-source library can be problematic. So then I looked into doing it using a solution provided by Vector : COM , but so far haven't

Read PST files from win32 or pypff

落花浮王杯 提交于 2020-01-13 06:15:10
问题 I want to read PST files using Python. I've found 2 libraries win32 and pypff Using win32 we can initiate a outlook object using: import win32com.client outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox = outlook.GetDefaultFolder(6) The GetDefaultFolder(6) gets the inbox folder. And then I can use this folders functions and attribute to work with. But what I want is to give my own pst files which pywin32(or any other library) can read. Here it only connects

python win32service - Getting triggered startup information for service

拜拜、爱过 提交于 2020-01-05 04:35:10
问题 win32 API QueryServiceConfig2 function supports the SERVICE_CONFIG_TRIGGER_INFO structure to get event(s) that trigger the service startup. However, python's win32service.QueryServiceConfig2() does not list such value as a parameter option. Is it possible to get that information with the win32service module? 回答1: Unfortunately, no. Here's a simple code snippet ran under Python 3.5 and PyWin32 v221 : #!/usr/bin/env python3 import win32service if __name__ == "__main__": for name in dir

How to get desktop item count in python?

匆匆过客 提交于 2020-01-03 13:55:11
问题 I'm trying to get the number of items on the desktop using win32gui in python 2.7. The following code: win32gui.SendMessage(win32gui.GetDesktopWindow(), LVM_GETITEMCOUNT) returns zero and I have no idea why. I wrote win32api.GetLastError() afterwards and it returned zero either. Thanks in advance. EDIT: I need to use this method because the final goal is to get the positions of the icons, and it's done by a similar method. So I just wanted to make sure that I know how to use this method. Also

What's the correct way to use win32file.ReadFile to get the output from a pipe?

亡梦爱人 提交于 2020-01-01 19:22:09
问题 I'm using the pywin32 extensions to access the win32 API under Python. I'm new at doing Windows programming in Python -- I'm a POSIX guy -- so I may be doing things in a bone-headed manner. I'm trying to use the win32file.ReadFile function properly, and I'm having some trouble interpreting the possible result codes. I'm calling the function like this: result, data = win32file.ReadFile(child_stdout_r, 4096, None) I'm reading the output from a child process that I launch. I get good data, but I