Re: [python-win32] PyWin32 API

2017-10-19 Thread Tim Roberts
Josh Clayton wrote:
>
> I've been reading the documentation and had a question. 
>
> How would I create a custom tag in the details tab of a file then set
> it, and read it?
>
> If creating it is not possible, would it then be possible just set an
> already existing tag and then read it? My end goal is to try and
> metatag a large group of files to avoid having to open them to read
> them.  I'd rather just use a script to blast through 10,000 files and
> understand what files are in my folder structure.

The answer is quite complicated.

The Details tab in Explorer is exposing whatever metadata the underlying
file format supports.  If you look at a JPG, for example, the JPG format
has the ability to add "tags".  If you change the tag list while you're
looking at that tab, Windows modifies the file to add that to the tag
list in the JPG file.  Similar, a Word document supports metadata like
"DocTitle" and "Author", and Explorer understand the Word file format
and how to modify it.  There is no generic "hidden store" for these
properties.

You can get access to these properties using the Shell object model. 
Theoretically, this should do it, but this returned "None" for all of
the properties I tried.  I wish you luck.  If Tim Golden is listening,
he may have a better idea.

Note that the Shell.NameSpace API is one of the very few places in
Windows where the path MUST be specified with backslashes.  It will not
accept forward slashes.

from win32com.client import Dispatch
shell = Dispatch("Shell.Application")
y = shell.NameSpace(r"c:\tmp\pvt")
print( y.Title )
for z in y.Items():
    print( z.Path )
    print( z.ExtendedProperty("Author"),
    z.ExtendedProperty("Date"),
    z.ExtendedProperty("Tags"))

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] PyWin32 API

2017-10-20 Thread Tim Roberts
Michael C wrote:
>
> I am wrestling with my life right now, but I'll post more hopefully by
> tomorrow.
>
> Also, I am trying to write my own 'Cheat Engine' or just a memory
> scanner in general, 
> I am just looking for simple values such as a int or a double.

Wrong thread.

Here is C++ code that does what you asked, based on a StackExchange
article that was trying to cheat on games by increasing the money
level.  This one scans my gvim editor process looking for the "cpp"
extension.  It finds several hundred occurrences:
    https://pastebin.com/BbyrXxsf

It's possible to convert that to Python, but you're using ctypes so much
that you're basically writing C code in Python.  Further, Python doesn't
worry about representations in memory.  If you're searching for a
specific floating point value, then you need to know exactly how it was
stored, bit for bit.  Is it single precision?  Double precision?  Scaled
integer?  Are you sure?

And if you do find the value, you can't change it unless you're sure
it's not a false positive.  You're likely to find any 4-byte random
value somewhere in a process, perhaps even as bytes of machine code. 
You don't want to change it unless you're sure it's a numeric constant
and not, say, a pointer.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Python - connexion to serial port

2018-01-15 Thread Tim Roberts
Schoeni, Yann wrote:
>   
>
> I thought it would be a great idea to keep it open during the
> application life time for one reason.
>
>  
>
> My webserver (running on windows) got a Velleman VM8090 module plugged
> in with a usb cable, my serial port is virtual.
>
>  
>
> 7)  Sometimes, the script return « The Serial port is already
> open », and a *delay is identified*. Below the function that open the
> port : 
>
> 8)  Because of this delay I was just thinking about keeping the
> serial port open while the application is running.
>
>  
>
> What do you guys think ? $
>

There are two possible solutions.

The only time the port should be open is if you are already processing
another request.  No matter what you do, there's always going to be a
delay in that case.  Your problem, then, is to serialize access to the
serial port, to ensure there's only one request at a time.

Your proposed solution is certainly workable.  You could create a
long-running "serial server" that keeps the serial port open and accepts
requests from your web server.  The other solution is to change your
script so that IT keeps retrying until it's able to open the port, with
a short delay between each attempt.  That way, the web server would
always see success.

The delay with the two solutions should be about the same; you're always
going to have to wait for request A to finish before request B starts,
but the second solution would be easier, from where you are now.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Python - connexion to serial port

2018-01-12 Thread Tim Roberts
Schoeni, Yann wrote:
>  
>
> « is the Python script persistent (is it running continuously in the
> background) or launched for each transaction? »
>
>  
>
> -   Currently, the script is launched for each transaction. As I
> understand your proposition, when the web page is open,
>
>    an ajax request should call a python script which open a thread
> between the machine and the serial peripheral, right ?
>

I'm still not clear what problems you are seeing with the
open/send/close paradigm.  What leads you to make a change?  The
open/send/close model is usually easier to handle, because the process
starts with a clean slate every time.  Once you go to a long-running
process, you have more things to keep track of.

Dennis is not necessarily proposing a new thread.  Consider, for
example, a server application using one of the frameworks, like Flask or
CherryPy or Django.  Such an application gets launched once, and sits
idle waiting for to send it things to do.  When it gets a request
(either from a socket or routed from Apache), it reads input, takes
action, sends output, then waits for more things to do.

Dennis' proposal is the same.  Have a Python script running
continuously.  When an Ajax request comes in (either from a socket or
from Apache), you communicate with the serial port and send your
response.  The serial port can remain open, because the application does
not close.

But I'm not convinced that complexity is needed.  The open/send/close
model should work just fine.


> -   Even if I find a way to open a thread with the serial port or
> to keep it open with a loop, is it possible to send it orders ?

Why wouldn't it?

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Recycle bin deletion date - mixing shell and winshell?

2018-01-11 Thread Tim Roberts
Durumdara wrote:
>
> The winshell module
> (https://winshell.readthedocs.io/en/latest/recycle-bin.html) retreives
> recycle bin files for me, I can see the deletion date, but not the
> real filename in filesystem (to I can delete the older ones).

The documentation does not describe it, but if you look in the source
code (which should always be your fallback for True Answers), you'll see
that the ShellRecycledItem object has a real_filename() method that
returns the information you want.

The documentation is on github, if you want to submit a fix.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Pywin32 outlook email organizer

2018-01-31 Thread Tim Roberts
Samantha Mait wrote:
>
>  
>
> I am reaching out as I am trying to use the pywin32 package for python
> 2.7 to automate sending an outlook calendar invite. The package is
> awesome and is able to do everything I would like except for one
> piece. I am trying to send the email from a separate email address. Is
> there any way that I can do this?
>
>  
>
> Ideally, I would like the email to be able to generate the script on
> my computer, but have the sender be someone else like you can do in
> python’s email package via sendmail(from_addresss, [to_address],
> msg.as_string()).
>

Remember that Python is just a gateway into Outlook.  You can't do
anything that Outlook wouldn't ordinarily do, and Outlook doesn't allow
you to override the sender address.  You can set up multiple identities
in Outlook, and then use Python to choose which identity to use when
sending.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Using DirectShow API to access webcam

2018-08-16 Thread Tim Roberts

Joe wrote:


I have a question an hope you can help me. I am trying to control a 
UVC webcam

using the DirectShow API, but could not get anything to work.

The question is already posted on StackOverflow:

https://stackoverflow.com/questions/51843523/accessing-webcam-via-directshow-using-com-with-python 



I am not familiar with using CLSID, IID so playing with the few 
examples I found

got my nowhere:

# IID_IAMVideoProcAmp is C6E13360-30AC-11d0-A18C-00A0C9118956
from win32com.client import Dispatch
from win32com.client.gencache import EnsureDispatch,GetClassForProgID, 
GetClassForCLSID, GetModuleForProgID, GetModuleForCLSID


iid = '{c6e13360-30ac-11d0-a18c-00a0c9118956}'

print(GetClassForCLSID(iid))
print(GetModuleForProgID(iid))
print(GetModuleForCLSID(iid))

CLSID = IID('{c6e13360-30ac-11d0-a18c-00a0c9118956}')
print(CLSID)

print(Dispatch(CLSID))

pywintypes.com_error: (-2147220990, 'CONNECT_E_CANNOTCONNECT', 
None, None)


Could someone of you point me in the right direction and maybe put
together a few lines to get me started?


I am not entirely convinced it is possible to control DirectShow from 
Python, but I'll give you some general information.


An "interface" in COM terms, described by an IID, is just a set of 
functions declarations.  It defines the things you can do with an 
object, but it is not actually an object.  A "CLSID", on the other hand, 
defines a COM object.  The CLSID doesn't tell you what the object can 
do, it's just a way of creating an object.  Once you have used a CLSID 
to create an object, you can ask it for an interface.


So, you can't just create IID_IAMVideoProcAmp.  You have to ask an 
existing object for its IAMVideoProcAmp interface.  You would create 
your camera object, and then query the camera object for IAMVideoProcAmp.


Creating a DirectShow graph is a multi-step process.  You create a 
filter graph, you add your camera to the graph, you tell the graph to 
render the stream (which means it automatically fills in the other 
filters), and you control it.  Here is some sample code that does this:


    https://gist.github.com/dust8/3890196

This is actually more complicated than it needs to be, because it's 
trying to handle TV devices with tuner and audio filters as well. You 
don't need that.  Once you have a device from VideoInputDeviceCategory, 
you don't need the video decoder or the audio.  You can just render the 
graph at that point.


Alternatively, it looks like this package might be more applicable:

    http://videocapture.sourceforge.net/

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] LNK4197 error building c++ extension

2018-08-17 Thread Tim Roberts

Robin Becker wrote:
I am not a great C++ person so as I am building my first C++ extension 
I am seeing this error which I don't understand


> _aggstate.obj : warning LNK4197: export 'init_aggstate' specified 
multiple times; using first specification
>    Creating library build\temp.win-amd64-2.7\Release\_aggstate.lib 
and object build\temp.win-amd64-2.7\Release\_aggstate

> .exp


It's not an error, it's a warning.  And this has nothing to do with 
C++.  Is this your own private project, or is it one I can go look up?



I looked in the preprecessor output(_aggstate.i) and see this single 
occurrence of aggstate_init



#line 1191 "_aggstate.cxx"
extern "C" __declspec(dllexport) void init_aggstate(void)
{
 aggstate_init();
}


is this some feature of C++ or is there a real issue here?


My guess is that you have listed "init_aggstate" in the ".def" file that 
lists the exported functions.  That's the first export specification.  
You are also using __declspec(dllexport) in the function definition, and 
that's the second export specification. When you use 
__declspec(dllexport), you don't need the ".def" file.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] LNK4197 error building c++ extension

2018-08-21 Thread Tim Roberts
On Aug 21, 2018, at 5:59 AM, Robin Becker  wrote:
> 
> C:\code\hg-repos\taggstate\REPOS\aggstate>ls build\temp.win-amd64-2.7\Release
> _aggstate.exp   _aggstate.obj   agg25
> _aggstate.lib   _aggstate.pyd.manifest
> 
> digging a bit deeper I find taht the problem comes from the exp file and the 
> linker /EXPORT. It seems that the /EXPORT:init_aggstate can be suppressed for 
> this build and the warning disappears, but something (I assume the exp) 
> supplies the export. Certainly the pyd appears to work.

Yes, the /EXPORT linker command is just an alias for the .def file.  You need 
to mention the entry point EITHER (1) in a .def file, (2) in a /EXPORT, or (3) 
with a __declspec(dll export).  One and one only.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Using DirectShow API to access webcam

2018-08-17 Thread Tim Roberts

Joe wrote:


thanks for your helpful answer and the explanations.
Following up on your comment on http://videocapture.sourceforge.net/
I found that there is jaraco.video, which seems to be
"a port of the VideoCapture module in pure Python using ctypes and 
comtypes."

(https://github.com/jaraco/jaraco.video)

It is using a 'DirectShow.tlb' file, whatever that is, to get the
definitions into comtypes.


A TLB file is a "type library".  It is a compiled version of the IDL for 
a set of COM interfaces.  IDL is modified subset of C++ that is used to 
declare the functions within a COM interface, their parameters, and 
their types.  It is intended to be  a language-independent way to define 
the functions within an interface.


Looks like you're on your way.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Reg. taking folder ownership

2018-08-27 Thread Tim Roberts

Goku Balu wrote:


My use case is this. Folder1 is created by Admin1 and ACL is set by 
Admin1. Now Admin2 wants to change the ACL. I think we have two 
options here

1) Take folder ownership and the do the changes
2) Take elevated privileges for Admin2 account and add/remove ACL 
entries (Similar to "Run as Administrator" and using icalcs in cmd)


I'm trying to solve this with the first approach. After Googling 
around, here is the code I'm trying to run for taking ownership from 
Admin1 and assign it to Admin2.


The Windows file permission ecosystem makes my head hurt, so I'm going 
to avoid answering your exact question, but I would point out that 
Admin1 can change the ACL to give Admin2 the right to change the ACL.  
In the file permission dialog, that's the "Change permissions" right.  
In code, it's the "WRITE_DAC" file permission.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Using WMI to listen to window creation and destruction

2018-07-18 Thread Tim Roberts
Ram Rachum wrote:
> "Are you really looking to monitor the creation of new top-level
> windows, which means the creation of new processes?"
>
> Does that apply to explorer windows? (i.e. when you open a new
> folder.) Because that's what I'd like to listen to.

No.  Those are just subwindows opened within the Explorer process.

What are you REALLY trying to do?  What's the overall goal?  Explorer
has an extensive shell extension interface that let you participate in
many actions, but opening new folders is not one of them.

    https://msdn.microsoft.com/en-us/library/windows/desktop/cc144067

Remember, you can open a new folder without opening a new window

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Dispatch multi instance of the some com server

2018-07-17 Thread Tim Roberts
Matteo Boscolo wrote:
> we have an issues with our com server (exe) .
>
> we dispatch it with dispatchEx to be sure that every time we dispatch
> it a new instance of the com server will be created.
>
> but it dose not work.
>
> when we dispatchex it the program get the live instance instead of
> creating a new one.
>

Why?  I know you weren't asking for a design review, but it seems like a
serious design flaw if you cannot handle multiple requests with a single
instance.  That's a big part of COM -- an easy way to have a server that
handles multiple clients.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Using WMI to listen to window creation and destruction

2018-07-18 Thread Tim Roberts
Ram Rachum wrote:
>
> I'd like to use the `wmi` module to be notified on the events of a
> window being created or destroyed. Is this possible? I looked at the
> tutorial and cookbook and could find many interesting things, but not
> that.

I don't think WMI provide information about windows, although admittedly
I've underestimated WMI in the past.  If you have evidence to the
contrary, please correct me.

However, I'm pretty sure what you said is not really what you meant. 
Remember that every control, every button, every textbox, every icon --
really, every visible thing is a separate window.  You'd get thousands
of hits.  Are you really looking to monitor the creation of new
top-level windows, which means the creation of new processes?  Because
WMI DOES provide information about processes.

If you do want to find out about windows, you'd need to use a Windows hook.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Issue on getting activesheet on win 8 and Win 8+ OS systems

2018-07-24 Thread Tim Roberts
Aravind wrote:
> Issue on getting activesheet on win 8 and Win 8+ OS systems
>
>    We are facing issues on getting active sheet values while running
> python3 code using win32.
>
>  
>
> Problem occurs only running on windows 8 and Windows 8+ OS PC's.
>
>  
>
> Here I attached the screenshot of my error and piece of code which i
> execute.
>

Are you actually opening a file?  Does the file open correctly?  Is it
possible the workbook isn't open yet by the time you query it?  Are you
running as the logged in user, or is this a service?

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Writing event handlers

2018-08-30 Thread Tim Roberts

Kairen Tan wrote:


I’m trying to write some python to consume events from an Event 
Handler….without much success.


I’m using a class created using makepy, and on inspecting the file, 
there is a block of commented code like:


# Event Handlers
# If you create handlers, they should have the following prototypes:
#def OnBeforeOpen(self, oRecord=defaultNamedNotOptArg):
#def OnBeforeSave(self, oRecord=defaultNamedNotOptArg, 
bCancel=defaultNamedNotOptArg):

#def OnAfterSave(self, oRecord=defaultNamedNotOptArg):
#def OnBeforeDelete(self, oRecord=defaultNamedNotOptArg, 
bCancel=defaultNamedNotOptArg):

#def OnCloseRecord(self):
#def OnAfterDelete(self, lDatabaseID=defaultNamedNotOptArg, 
sImportID=defaultNamedNotOptArg):


*My question is simply, how do I implement this? *
*
*
I’ve tried using win32com.server.register.RegisterServer, but I’m 
stumped as to what comes after that.


It would have been helpful if you had told us what server you were 
trying to work with here.


You don't need to register yourself as a server.  Registration is only 
needed if someone else is going to look for your object by its CLSID, 
but that's not the case here.  There's really no such thing as an "event 
handler" in COM.  I'm guessing that the server you're working with wants 
you to hand it a COM interface, and it will call methods of that COM 
interface when certain events occur.


So, you need to use the magic _reg_ names so that win32com recognizes 
you as a COM object, but after that, all you should need to do is create 
an instance of your object, and pass it to whatever method your server 
uses to register the callback object.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywintypes.error: (5, 'RegSetValueEx', 'Access denied')

2018-03-15 Thread Tim Roberts
Robin Kluth wrote:
>
> I use Python 2.7 on win10 and pywin32 223. I want to log messqages to
> the EventLog:
>
> dllname = os.path.dirname(__file__)
> ntl = NTEventLogHandler("Python Logging Test", dllname=dllname)
> logger = logging.getLogger("")
> logger.setLevel(logging.DEBUG)
> logger.addHandler(ntl)
>
> logger.error("This is a '%s' message", "Error")
>
> But I get:
> ...
> pywintypes.error: (5, 'RegSetValueEx', 'Zugriff verweigert')
>
> If I run the script with Admin privs, it is working.
>
> How to log as "normal" user? Am I missing something?

You can't.  If you want to log to the event log, you'll need
privileges.  Each app must register as an "event source".  Doing so
requires writing to the HKEY_LOCAL_MACHINE part of the registry, and
write requires admin privileges.

Technically speaking, it would be possible to register that source once
in an elevated process and then use it without re-registering, but the
current code does not support that.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Service stucks in Starting state

2018-04-10 Thread Tim Roberts
k3...@free.fr wrote:
> Unfortunatelly when I install and then start my service, it gets stucked in 
> Starting state and then I have no chance to stop or remove it except by 
> restarting the computer.

How do you know this?  How did you start the service?  How are you
monitoring the state?

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Future of PyWin32

2018-03-28 Thread Tim Roberts
Thomas Pietrowski wrote:
>
>
> (2) Syntax fixes and code-style.
>
> If I'm not wrong I saw mixed usage of tabs, 2-whitespace and
> 4-whitespace indents. Of course, I can be wrong and we are using
> 4-whitespaces everywhere, but I remember that I saw files using tabs
> and 2-whitespaces.
> It is boring work, but I can imagine, that people, who see this mixed
> usage, might get frightened.
> Also when it comes to code-style I would like to make everything well
> ordered. Eg. splitting long lines and splitting multiple options, so
> you can read the code without scrolling vertically too much.

Remember that much of PyWin32 is automatically generated.  Automatically
generated code is almost never pleasant to read.


> (3) Self-explaining variable names
>
> Some variables are using abbreviations. Instead, I would like to use
> full words, so the code is readable like a written book. Personally, I
> like this a lot because the source actually tells you what it is doing
> without any guesses.

Again, much of PyWin32 is automatically generated from the Win32 C API. 
The names need to match the API, as terse as they may be.

I am sympathetic to your plea, but renaming efforts like this are
fraught with dangers.  It's awfully easy to cause duplicates or screw up
the comments through an overactive search-and-replace.


> (6) Focusing more on Python3 compatibility
>
> The end of life of Python2 is at 2020 and therefore I would suggest
> investing time into making the code compatible to Python3 asap.

PyWin32 has been Python 3 compatible for many years.  To what are you
referring?

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] More info about Microsoft Foundation Classes (MFC)

2018-03-29 Thread Tim Roberts
Thomas Pietrowski wrote:
>
> I have general questions about MFC and hope you can answer them.
> When compiling PyWin32 for Py2.7 and Py3.x I get successful builds,
> but setup.py can't find the MFC libraries,
> which are specified here:
> https://github.com/thopiekar/pywin32/blob/master/setup.py#L1059
> for Python 2.7, Python 3.3 and Python3.4. This happens while using
> Appveyor and I contacted them about these "missing" files.
> One of the developers contacted me back and asked, whether mfc90*.dll
> is really needed for Python2.7.
> I think the question is quite eligible: Why are exactly these versions
> of MFC libraries strictly specified here?
> Isn't it possible to take the latest version, which is available?
> (Which is there for Python3.5 and 3.6.)

No.  It may not be obvious, but Python itself it entirely implemented in
a DLL.  (Note that the "python.exe" command is only a couple dozen
kilobytes.)  That DLL links to the dynamic version of the C run-time
library.  To avoid conflicts in shared state and such, all of the DLLs
it calls must either use a static C run-time library, or the same
dynamic version that Python itself uses.  The same applies to MFC.  When
an application or DLL links with MFC, it links to a specific version
(e.g., mfc90.dll).  You can't substitute another.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] More info about Microsoft Foundation Classes (MFC)

2018-03-29 Thread Tim Roberts
Thomas Pietrowski wrote:
> Ok, so basically the same I know from Linux.
> But how likely is it that Python 2.7.14 (which is currently the latest
> version) is linked against old libraries?
> Isn't the Python Foundation updating their build system regularly, too?

No.  In the past, the policy has been whatever build system is used for
2.7.0 will be used for all 2.7.x releases.  If they upgrade their Visual
Studio, then all users have to upgrade, too, and in the Windows world
that costs money.


> At the moment I'm quite convinced that the choice of an MFC version
> does not depend on Python, but on which version you built PyWin32.
> However, this is only my current feeling.

Right.  The core interpreter has no UI, and does not link to MFC.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] com_error creating VSS shadow copy (running as windows service)

2018-03-26 Thread Tim Roberts
Gerardo García Urtiaga wrote:
>
>
> We have an application that launch a VSS (volume shadow copy), when
> the application is running as administrator user, the shadow copy is
> made correctly, but when the application is running as windows service
> the application has a crash:

Under what user are you running the service?  If you are using
LOCAL_SYSTEM, then you should have administrator privilege, but if you
are using a regular user, then you do not.


> com_error: (-2147221020, 'Sintaxis no v\xe1lida', None, None)
>

That's MK_E_SYNTAX, meaning the string could not be parsed in the
current context.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Get errors 7000 and 7009

2018-03-26 Thread Tim Roberts
Chang Dacool wrote:
>
> The service will fail to start when we reboot the OS in some
> computers, when this happens we will get error code 7000 and 7009 in
> the event viewer.
> 7000: The ServiceName service failed to start due to the following error:
> The service did not respond to the start or control request in a
> timely fashion.
> 7009: A timeout was reached (3 milliseconds) while waiting for The
> ServiceName service to connect.
>
> We checked our program, the Service timeout was before launching our
> program.
>

I can't tell what you mean.  Are you saying your service sometimes takes
more than 30 seconds to launch?  If so, then you need to figure out why
it takes so long.  If you are waiting for some event during your
startup, perhaps you can reorganize your code so that you defer some of
your initialization until after you enter the main service loop.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32com + Brother Printer + Django

2018-03-25 Thread Tim Roberts
On Mar 23, 2018, at 9:44 AM, Scott Vitale <sc...@spigotlabs.com> wrote:
> 
> I'm looking for some win32com help... I have a simple Python script that 
> creates a `Dispatch` object for a `bpac.Document` type (it's a Brother 
> printer SDK class).  It works perfectly fine in a standalong script, but as 
> soon as I attempt to call this code from Django, it hangs on creating the 
> `Dispatch` objectso bizarre.
> 
> I've tried calling `CoInitialize` in a variety of ways, no difference in 
> behavior.
> 
> The other oddity is that I can create `bpac.Printer` objects with no issue.  
> It's only the `bpac.Document` type that hangs.  Unfortunately I don't have 
> access to the library source and I'm not sure how to debug why it's hanging.

How are you running your Django app?  Is it running as a service?  Is it 
networked, or directly connected?  Microsoft does not recommend printing from 
Windows services, in parts because of security considerations.  Your service is 
running as a special Windows user (unless you've configured it), and that 
special user needs permissions to use the printer.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Excel / Word: setting properties

2018-02-28 Thread Tim Roberts
Niemann, Hartmut wrote:
>
>  
>
> I create an excel document using the COM interface.
>
>  
>
> Now I need to set two properties to be compatible with a new company rule:
>
>  
>
> “[the tool] uses MS Office standard (‘Keyword’) and custom (‘Document
> Confidentiality’) properties. so if your code is able
>
> to preset values to these properties [everything should work]”
>
>  
>
> How do I set the [Excel workbook] standard property “Keywords” to
> “C_Restricted” and the user property “Document Confidentiality” to
> “Restricted”?
>

The Document object should have a BuiltinDocumentProperties collection
and a CustomDocumentProperties collection that you can query and
manipulate.  You'll have to discover whether the properties you need to
tweak are builtin or not.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Excel / Word: setting properties

2018-03-02 Thread Tim Roberts
On Mar 2, 2018, at 12:07 AM, Niemann, Hartmut <hartmut.niem...@siemens.com> 
wrote:
> 
> print ('%r' % workbook.BuiltinDocumentProperties)
> 
> gives me 
> 
> >
> 
> What can I do with such an object?

Are you checking the Word object model?  The BuiltinDocumetProperties method 
returns a DocumentProperties object.  I believe that is a collection of 
DocumentProperty objects.  So you should be able to say something like

for prop in workbook.BuiltinDocumentProperties:

— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Wait for process to be started

2018-04-25 Thread Tim Roberts
Ram Rachum wrote:
>
> I'm writing a Python program on Windows 7. I want the program to
> patiently wait for a process to be started that has a certain name,
> and then do an action after it was started.
>
> I can easily write the program using polling, i.e. checking every
> second whether the process is active, but I want to be more efficient
> and wait on the system event that is generated when a process is
> started. Is that possible?

Is this a process you are starting?  If YOU start the process, you get a
handle that you can wait on

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to get actual FILETIME from PyTime

2018-06-28 Thread Tim Roberts
Rob Marshall wrote:
> Thank-you. I also figured out that if I want the "actual" FILETIME I can do:
>
>>>> get_filetime = lambda i: ((i & 0x),(i - (i & 0x))>>32)
>>>> get_filetime(13174227726000)
> (905689856L, 30673639L)
>>>> low,high = get_filetime(13174227726000)
>>>> (high<<32)+low
> 13174227726000L

A FILETIME is just a 64-bit integer, and you can always pass it to APIs
that way.  The only reason the structure has it in two parts is because
the Microsoft C compilers of the early 1990s did not have a 64-bit type.

Another way to do the unpacking is
    struct.unpack('II',struct.pack('Q',i))
and the reverse:
    struct.unpack('Q','strict.pack('II',low,high)[0]

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Exception '-2147221164' while using win32com.client.Dispatch("SAPI.SpVoice")

2018-10-10 Thread Tim Roberts
On Oct 9, 2018, at 8:03 AM, Sai Ram  wrote:
> 
>We are using "win32com.client.Dispatch("SAPI.SpVoice")" for TTS to our 
> target device from a Windows 7 desktop. We are seeing many of these 
> exceptions: "Exception '-2147221164'". 
> Is there a fix for this? Basically, wanted to know the reason for this 
> exception and the fix for this.

COM exceptions are listed in hex.  -2147221164 is 0x80040154, which is 
E_CLASSNOTREG.  Have you installed SAPI 5.1?  It's not built-in.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM: control menu bar

2018-09-30 Thread Tim Roberts
On Sep 30, 2018, at 6:25 AM, Emre CETIN via python-win32 
 wrote:
> 
> Hello James. Thank you for your advice. I ran Spy++. At the logging options I 
> selected the menu bar portion of the other program. I selected WM_COMMAND 
> only and then chose  all "Additional Windows" (except for the All Windows in 
> System). Then I clicked one of the menu items I wanted: Edit | Select All. It 
> provided me with the following line: WM_COMMAND wNotifyCode:0 (sent from a 
> menu) wID:57642.
> 
> How can I use this class ID (57642) in Python to act as if it was 
> clicked/pressed?

That's not a class ID, it's a window ID.  You can trigger that by sending the 
exact same message you saw here.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Exception '-2147221164' while using win32com.client.Dispatch("SAPI.SpVoice")

2018-10-10 Thread Tim Roberts

Sai Ram wrote:


   I really did not know that this value would make difference. 
Apologies for the vague question. The actual exception is "-2147352567".


That's 0x80020009, or DISP_E_EXCEPTION.  That's really telling you to 
refer to the other code for the details.



Also, we have around 5000 test scripts. Out of these, around 300 test 
scripts fails with this exception. So, I do not doubt any system 
issues here.


Did you actually install the SAPI SDK?  Do all 5,000 of the scripts use 
SpVoice?  Do the 300 that fail use some particular subset?  Are they all 
either 32-bit or 64-bit apps?


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Exception '-2147221164' while using win32com.client.Dispatch("SAPI.SpVoice")

2018-10-10 Thread Tim Roberts
On Oct 10, 2018, at 1:25 PM, Sai Ram  wrote:
> 
> We use Nuance's Vocalizer Expressive for voice and sapi5.dll. Also, we modify 
> the "Windows registry" to refer to this dll.

What does that mean?  Ordinarily, you would just register the DLL with regsvr32 
once and for all.  Are you making registry changes on the fly?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] why do I get error 1804 from win32print.SetJob?

2018-11-16 Thread Tim Roberts

Glenn Linderman wrote:


Here is the code I'm using. Note that the variables js and rename are 
the control variables if you need to tweak this to run in your 
environment. js contains a substring of an existing document name, and 
the idea is that the document name of the first matching spool job 
having a document name containing that fragment will be changed to the 
content of the rename variable by the code.

...
Here is the error I'm getting:

{'JobId': 27, 'pPrinterName': 'HL6180dw', 'pMachineName': 
'STEPHEN', 'pUserName': 'Glenn', 'pDocument': 'duh', 'pDatatype': 
'NT EMF 1.008', 'pStatus': None, 'Status': 8210, 'Priority': 1, 
'Position': 0, 'TotalPages': 22, 'PagesPrinted': 0, 'Submitted': 
pywintypes.datetime(2018, 11, 14, 21, 1, 27, 882000, 
tzinfo=TimeZoneInfo('GMT Standard Time', True))}

Traceback (most recent call last):
  File "D:\my\py\spool.py", line 109, in 
    win32print.SetJob( phandle, res[ 1 ], 1, jobinfo, 0 )
pywintypes.error: (1804, 'SetJob', 'The specified datatype is invalid.')


That's very odd.  This is not from the Pywin32 code --  it has correctly 
parsed your structure.  That error is coming from the SetJob API itself 
(ERROR_INVALID_DATATYPE).  As an experiment, have you tried coding up 
the exact same sequence as a C program to see if you get the same error?


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Bug - Passing byref an array to a com method interpreted as a single element

2019-01-21 Thread Tim Roberts

rv...@free.fr wrote:


I'm trying to translate a VBA application to Python. I cannot change 
the COM Server as its works also with others programs.
It seems I have a problem with win32com.client by passing an array of 
double to a COM method.


VBA allows to pass arrays to COM server byref on the first element of 
the array

...||

From typelib COM interface

|[id(0x0007), helpstring("Méthode GetValues")] HRESULT 
GetValues([in, out] double* pValues); # pointer on array of double 
[id(0x0008), helpstring("Méthode SetValues")] HRESULT 
SetValues([in] double* pValues);|


...

It seems win32client do not interpret correctly the type expected by 
the COM server, here float() instead of pointer on an array of float.




That statement is not accurate.  The fault is not in win32client.  The 
root of the problem is that the function definition in your type library 
is not COM-compliant.  There are rules that need to be followed in order 
for a COM interface to work seamlessly across languages, and you have 
violated those rules.  The proper way to pass an array is to use a 
SAFEARRAY. Your definition, for example, cannot possibly work in an 
out-of-process server, because there is no way for the marashaling code 
to know how much data to send across.  The GetValues case is doubly 
hopeless.  How can the server know how large the buffer is?  How can the 
client know how much data will be returned?  You are simply not allowed 
in COM to have that be assumed.



Win32client is quite correct in interpreting your definition as it 
does.  The fact that it works in VBA is an lucky accident.  If you want 
this to work reliably, you need to change the interface.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Bug - Passing byref an array to a com method interpreted as a single element

2019-01-21 Thread Tim Roberts

Tim Roberts wrote:

rv...@free.fr wrote:


It seems win32client do not interpret correctly the type expected by 
the COM server, here float() instead of pointer on an array of float.




That statement is not accurate.  The fault is not in win32client. The 
root of the problem is that the function definition in your type 
library is not COM-compliant.  There are rules that need to be 
followed in order for a COM interface to work seamlessly across 
languages, and you have violated those rules.  The proper way to pass 
an array is to use a SAFEARRAY. Your definition, for example, cannot 
possibly work in an out-of-process server, because there is no way for 
the marashaling code to know how much data to send across.  The 
GetValues case is doubly hopeless.  How can the server know how large 
the buffer is?  How can the client know how much data will be 
returned?  You are simply not allowed in COM to have that be assumed.


Win32client is quite correct in interpreting your definition as it 
does.  The fact that it works in VBA is an lucky accident.  If you 
want this to work reliably, you need to change the interface.


Having said all that, you may be able to do what you need with the 
"comtypes" module, which allows lower-level access to COM interfaces.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] python win32com.client; reverse engineer sql server timestamp

2018-12-17 Thread Tim Roberts
On Dec 17, 2018, at 5:20 PM, Anrik Drenth  wrote:
> 
> I'm looking for the mapping table / logic that will render sql server 
> timestamp values as win32com.client does.

OK, then why did you not tell us what the win32com.client does?


> I'm currently  importing a text file into Access. The text file contains a 
> column with a timestamp value which has been extracted from sql server.  The 
> values for the (Access String 50) column look something like 
> "0x0189CF01".

That's a 32-bit integer.  You need to be storing this as a 32-bit integer, not 
as a string.  Or, best of all, as an Access date/time datatype.  Exactly which 
data type in the SQL Server column?  How was the text file generated?  In 
virtually every case, SQL Server will export date and time columns as date time 
strings (that is, "2018-12-17".  How did you get a hex representation?
 

> Using VBA I want to convert these to the exact same value that win32com 
> creates.
> 
> In python (sample code below) the timestamp value is stored as an 8 byte, 
> bytearray.  Which then gets interpreted by Access.  

Which version of Python are you using?  You are taking binary data and shoving 
it through a Unicode-to-ASCII conversion.  That produces garbage.  That's not a 
string.  It's an integer.


> Below is a sample of how the sql server timestamp value is stored in Access:
> 
> SQL Server (Timestamp) | Access (Text 50) 0x0189CF01  |  003F49  
> 0x0189D001  |  003F69  0x01B54DFF  |  003F6D  
> 0x01F74701   | 003F4E  0x0189C003   | 003F70  
> So it tries to do a mapping, sometimes 1 to 1, sometimes not as page 5 of the 
> below link demonstrates 

Right.  You're producing garbage.  The "3F" in there is the "?" character, 
which means "this character does not exist in the current 8-bit code page".  
It's not a Unicode string, don't try to treat it like one.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to obtain printer HANDLE as int in Python

2018-12-10 Thread Tim Roberts

paolo bonatti via python-win32 wrote:
I'm trying to print PDF documents with pdfix sdk utilizing win32print. 
This PDF library requires printer HANDLE value as int directly not as 
a PyObject.


Is there any way to obtain printer HANDLE value in Python code?
(attached is a sample)



   hDC.CreatePrinterDC (win32print.GetDefaultPrinter ())


If that is getting you what you need, then

    win32print.OpenPrinter( win32print.GetDefaultPrinter() )

will get you the handle to that printer.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32api.FindFiles hangs (was COM registration hangs up: 32 bit Python 3.7 on 64 bit Win 7)

2018-12-05 Thread Tim Roberts

Boylan, Ross wrote:


Is this some kind of string conversion issue?  My installation is borked?
Manual debugging statements show sys.argv[0] is 'BSTImport.py'.

win32api.FindFiles('BSTImport.py')
in a python 3.7 shell (32 bit) hangs.


That's quite bizarre.  The code for win32api.FindFiles is 
straightforward.  Is this a special directory, like a net share or 
something?  If you ask for *.py, is BSTImport.py in the list you get back?


Do you code in C?  You might code up a trivial C app to run a 
FindFirstFile/FindNextFile loop with the same parameters to see if the 
same thing happens.  Of course, I'm not sure what the next step would 
be, whether that worked or failed.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32api.FindFiles hangs

2018-12-06 Thread Tim Roberts

Jim Bell wrote:
Maybe it's not your installation of Windows that's messed up, but just 
a third party driver. Or someone has mis-configured something on the 
server.


This net share Z: drive: what's the technology / software that's 
behind it? Is it a standard Windows share, or a third-party driver? 
(If it's a standard Windows share, is it a Microsoft server doing the 
sharing?)


Yes, this is the right direction to go.  Some NFS implementations, for 
example, are far less robust than one would really like for the 
corporate environment.  You might also try temporarily disabling your 
virus scanner and see if that alters things.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] why do I get error 1804 from win32print.SetJob?

2018-11-20 Thread Tim Roberts

Glenn Linderman wrote:
Of course, the GetJob is decoding the structure properly... but its 
PyBuildValue parameter strings are much more complex than the 
PyArg_ParseTupleAndKewyords parameter strings, and there is mention of 
TCHAR in the JobToPy, but not in the PyToJob, so that makes it further 
seem like my speculations above might have some chance of being the 
problem.


I should not have scoffed at your speculation, because your analysis was 
correct.  The win32print code is calling SetJobW, which expects Unicode, 
but the JOB_INFO_1 structure is filled with ANSI strings.  That's a very 
nasty bug.  I'll file a bug report.


In the meantime, I'll fix up my little C++ example to do the job for you.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] why do I get error 1804 from win32print.SetJob?

2018-11-20 Thread Tim Roberts

Glenn Linderman wrote:


I looked at the win32print.cpp file. There were lots of 
Python-internals stuff there that I don't really follow well. I didn't 
see anything obviously wrong, but I got to wondering about the code 
that builds the structure... it puts in UTF-8 text strings (which 
would be same as ASCII in the cases I'm considering, but what if 
someone has a non-ASCII printer name, or document file name, or ???). 
And I'm sure the A version of the Windows API probably is happy with 
ASCII, but does the 64-bit compilation call the A version of the 
Windows API or the W version?


32 vs 64 makes no difference here.   SetJobA always expects 8-bit 
strings, SetJobW always expects 16-bit strings.  SetJob maps to one or 
the other based on the absence or presence of #define UNICODE.  The 
routines that convert Python strings to zero-terminated strings will do 
the right thing.



And would the W version be happy with ASCII? Or would that produce an 
1804 error?


If you pass ASCII strings to the W API, it just means the strings are 
interpreted as garbage.  The name will not be found.  It shouldn't cause 
1804.


I went to ReactOS and looked at the source code for SetJob. 
ERROR_INVALID_DATATYPE is returned for exactly one reason: the pDatatype 
value is not in the valid list of datatypes for the print processor for 
this job.  There's no reason for that; your structure says "NT EMF 
1.008", which is almost always valid.


This had to work at some point.  All of these things get tested. I just 
don't know what would have changed.  If I get motivated (I've already 
spent too much time on this ;), I'll see if I can get your script to 
fail here.



And then of course, I've no idea what compilation parameters were 
used, either for your program (which works), or for win32print.cpp 
(which maybe doesn't).


I built mine for non-Unicode.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] why do I get error 1804 from win32print.SetJob?

2018-11-19 Thread Tim Roberts

Glenn Linderman wrote:


I've not coded up the equivalent C program, as I don't have a C 
compiler installed here, and haven't done any C coding for 8 or 10 years.


Were you able to reproduce the problem, or is your error analysis 
based on code reading?


I looked at the code.  Plus, I recognized that 1804 is a Windows errors 
code, not a Python error.  Let me see if I can write up a C++ test that 
would be useful for you.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Making a COM server that accepts COM objects

2019-01-09 Thread Tim Roberts

Boylan, Ross wrote:

I have a Python 3.7, 32 bit, COM server and am calling it from 32 bit Office 
2010 in VBA.  I am attempting to pass some COM objects from VBA to Python.  The 
trace collector full output appears below, but I think the key clues are 
several messages like

in ._QueryInterface_ with unsupported 
IID {0003---C000-0046} ({0003---C000-0046})


Those are not important.  The COM framework is just probing to find out 
what extras you support.  0003-etc is IMarshal and 001B-etc is 
IStandardMarshal; both can be used to help in the RPC process.




and, later,
 rst = fedb.OpenRecordset("foo")
AttributeError: 'PyIDispatch' object has no attribute 'OpenRecordset'


You can't just pass an Access database object to another process and 
expect it to work.  The support pieces aren't there.  Thus, the crux of 
your problem is this:



 _reg_progid_ = "Fahy.BST"
 # for unknown reasons the inprocess server isn't working
 _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER


That's the problem you need to chase.  You need to be an in-process 
server if you want to share state with the original code.  What happens 
when you register yourself as in-process? Note that the registry has to 
look different for this.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] python win32com.client; reverse engineer sql server timestamp

2018-12-18 Thread Tim Roberts
On Dec 18, 2018, at 1:05 PM, Anrik Drenth  wrote:
> 
> Couple of good insights there. Would you have example python code that shows 
> the Unicode-to-ASCII conversion in action?
> 
> So 0x0189CF01  to 003F49 
> 
> The current code is written in Python 2.7, its selecting the data from SQL 
> Server and writing it into Access 97.
> As Access 97 is somewhat dated we want to get rid of this code and hand 
> responsibility back to the client.
> 
> The sql server timestamp field is a rowid.  It was used back in the day under 
> the mistaken assumption it was a datetime field.  It is not, subsequently the 
> field exists but has never been used.

Aha.  Here's my alternate theory, then.  I'll bet that field in the Access 
table is declared as "AutoNumber".  In that case, Access would be assigning its 
own unique row number to the field, totally ignoring the incoming field from 
SQLServer.  That would make a certain amount of sense, but you'd have to look 
at the other values in that field to be sure.

> We still have to re-produce the same exact same value in the field on the off 
> chance it is used by the clients system.

Don't you have the code that originally created those fields?  It is absolutely 
pointless for us to guess how this was done.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] ExportAsFixedFormat's ValueError

2019-03-27 Thread Tim Roberts

Kaweit wrote:


i make a question:
doc.ExportAsFixedFormat(output, 
constants.wdExportFormatPDF,|Item||=||constants.wdExportDocumentWithMarkup, 
CreateBookmarks ||=||constants.wdExportCreateHeadingBookmarks)|
     but "ValueError",the argument was wrong.  Cloud you help me? I 
think I need a Win32com Docutment.


This is not a win32com issue, it is a Word issue.  And it would have 
been easier if you had told us that you were using Word instead of 
making us guess.  We don't know were "ExportAsFixedFormat" comes from.


Why didn't you cut-and-paste us the exact error message?  Did it tell 
you which argument was wrong?  What, exactly, is "output"? It would be 
helpful to see the code leading up to this as well.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] hook the left mouse button down event on any window

2019-03-29 Thread Tim Roberts

Zhao Lee wrote:
I originally posted the question here 
<https://stackoverflow.com/questions/55399565/hook-the-left-mouse-button-down-event-on-any-window>, 
please help ,thank you !



I want to hook the left mouse button down event on any window, my code 
as following :
|importwin32guiimportwin32uiimportwin32condefonMousePressed(self):print('onMousePressed',win32gui.GetCursorPos())deflistener():  
 windowHandle =win32gui.WindowFromPoint(win32gui.GetCursorPos())  
 clickedWindow =win32ui.CreateWindowFromHandle(windowHandle)  
 clickedWindow.HookMessage(onMousePressed,win32con.WM_LBUTTONDOWN)# 
print('-registerMouseEvent', clickedWindow)whileTrue:  
 listener()|


However , the |onMousePressed| function was never called when clicked, 
what is wrong ?


P.S. I know some similar projects such as PyUserInput 
<https://github.com/PyUserInput/PyUserInput>, mouse 
<https://github.com/boppreh/mouse>, pynput 
<https://pythonhosted.org/pynput/keyboard.html#monitoring-the-keyboard>, 
just want to know why my code didn't work.


Your code came across badly formatted, so I can't tell exactly what you 
wrote.  You aren't actually calling listener() from within a continuous, 
tight CPU loop, are you?  This function is going to get called thousands 
and thousands of times a second. This is very poor practice, and it's 
part of the reason these other modules exist.


You attach to an external window, install your mouse message hook, then 
your function exits, the window object is deleted, and the hook is released.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] hook the left mouse button down event on any window

2019-03-30 Thread Tim Roberts
On Mar 29, 2019, at 8:39 PM, Zhao Lee  wrote:
> 
> import win32gui
> import win32ui
> import win32con
> 
> def onMousePressed(self):
> print('onMousePressed', win32gui.GetCursorPos())
> 
> def listener():
> windowHandle = win32gui.WindowFromPoint(win32gui.GetCursorPos())
> clickedWindow = win32ui.CreateWindowFromHandle(windowHandle)
> clickedWindow.HookMessage(onMousePressed, win32con.WM_LBUTTONDOWN)
> # print('-registerMouseEvent', clickedWindow)
> 
> while True:
> listener()
> time.sleep(8)
> 
> what is wrong and what's the good practice ?

I TOLD you what is wrong.  Let’s follow the flow.  Every 8 seconds you call 
listener.  It does the following, very quickly:

* Fetch the window under the cursor, assuming the cursor is over a window.
* Create a Python window object around that window handle
* Install a hook to catch button down messages for that specific window
* Function exits, the window object is destroyed, and the hook is uninstalled

Then you go back to sleep.  While you are alseep, there is no hook.  The only 
time you have a hook is the few milliseconds between your HookMessage call and 
when the function returns.

The right answer is to use a package like pyHook to install a global hook.  
This is exactly what it is for.

https://stackoverflow.com/questions/165495/detecting-mouse-clicks-in-windows-using-python
 
<https://stackoverflow.com/questions/165495/detecting-mouse-clicks-in-windows-using-python>
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



smime.p7s
Description: S/MIME cryptographic signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] chapter 5 : implementing com objects with python

2019-03-26 Thread Tim Roberts

Benjamin McNeill wrote:


Hello,  I am trying to get this com server to work in VBA.  I can 
register and deregister the server but I can not call it from vba.  
Any suggestions?  I am using windows 10 and office 365 with python3.7.


Remember that the bit-size must match.  I don't actually know whether 
Office 365 is a 32-bit app or a 64-bit app, but your version of Python 
must match.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] adodbapi: paramstyle 'named' doesn't work as expected

2019-02-20 Thread Tim Roberts

Dennis Lee Bieber wrote:


The loop is looking for the end of the parameter name by looking for a
non-alphanumeric character. But your update command just... ends -- there
is no non-alphanumeric character after the name to terminate the loop.
INSERT syntax has a closing ) to terminate.

I WOULD consider this a subtle bug in the ADODBAPI code.


You are being too kind.  This bug is not subtle in any way. Python is so 
good at string parsing -- there must be a better way to write that.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to get target of folder shortcuts

2019-03-18 Thread Tim Roberts

kurt wrote:

Hello, I'm trying to get the target filename of windows shortcuts.  The
code below works great for regular shortcuts, but errors out on "folder
shortcuts".
...
The code below works great for regular .lnk shortcuts, but folder
shortcuts give me:
[...]
 persistFile.Load(fname,STGM_READ)
pywintypes.com_error: (-2147024891, 'Access is denied.', None, None)

The quirk with folder shortcuts is they have some DOS attributes set,
which I suspect could be causing me trouble.  Is there, perhaps,
something I need to do to get my IPersistFile to ignore file attributes?


Your code works for me, although the SFGAO_FOLDER bit is not set for my 
folder shortcut.  If you do a "dir" of the folder where the link lives, 
what do you see?  Is it actually a .lnk file of about a kilobyte?


There are no DOS attributes on my folder shortcut.  What do you see?

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Performing ReplyAll to outlook email message

2019-03-15 Thread Tim Roberts

Ahmed Matar via python-win32 wrote:


I am trying to perform a reply all to an email message that I have 
passed into my python script.

...

#what I would like to do now is do a “Reply all” with my reponse being 
“ResponseToEmail”



Any ideas if this is possible?


Sure, it's possible, but you have to do it all "the hard way". Create a 
new message, copy the Receipts list into the new message, set your body, 
send it.  Not a lot of code, but it's a little tedious.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM Photoshop - Exception occurred

2019-03-09 Thread Tim Roberts
On Mar 8, 2019, at 9:08 AM, Ioannis Valasakis  wrote:
> 
> ...
> Currently, that this is the error I am getting and I can't seem to understand 
> why, as I've seen online examples using the exact same code and it works.
> 
> >>> desc.putReference(cTID("null"), ref) 
> >>> desc.putBoolean(cTID("MkVs"), False)
> >>> app.executeAction(cTID("slct"), desc, 3)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 516, 
> in __getattr__
> ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Adobe 
> Photoshop', u'Illegal argument - argument 1\n- Required value is missing', 
> None, 0, -2147220262), None)

Different versions of Photoshop?  Could the “slct” action refer to a plugin 
that isn’t present on your Windows 10 system?

The key point is that this is almost certainly going to end up being a 
Photoshop issue, not a Python issue.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



smime.p7s
Description: S/MIME cryptographic signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Facing issue while connecting to alm via python

2019-01-29 Thread Tim Roberts

Neeraj Chhabra wrote:


I have one requirement, in which i need to connect to HP ALM and log a 
defect in jira using python. i tried to connect to alm through 
pywin32. but getting error. please check below code snippet and error -

...
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, 
None) During handling of the above exception, another exception 
occurred: ... pywintypes.com_error: (-2147221164, 'Class not 
registered', None, None)


It's likely that you are using a 64-bit Python but your ALM installation 
is 32-bit.  An in-process COM server has to match the bittedness of the 
caller.  Do you have the option of installing a 32-bit Python to see if 
it works from there?


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] connecting to labview executable

2019-05-12 Thread Tim Roberts
On May 12, 2019, at 12:53 PM, c.kristu...@hoc.net wrote:
> 
> I think what he is saying that he can connect to the LabView IDE but he
> cannot connect to the stand-alone executable once it is built. LabView
> is an interpreter which comes with a compiler to build stand-alone
> binaries.

Yes, you are right.  Do we know whether the standalone executable is SUPPOSED 
to act as a COM server?  Somebody somewhere would have to register it.  I would 
not be surprised at all if that only works with the IDE.  That's probably a 
question for the LabView support forum.


> Anyway, LabView can do socket comunication so I think this is the way do
> go rather than reading LabView controls via pywin32.

Agreed.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



smime.p7s
Description: S/MIME cryptographic signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Retrieve Windows Notifications With pywin32

2019-06-02 Thread Tim Roberts
On Jun 2, 2019, at 6:06 PM, DAI VU via python-win32  
wrote:
> 
> ]I am new to python/pywin32. I have a task to check/retrieve/click on some 
> notifications in the "Action Center" posted by a particular windows app. Can 
> I use python/pywin32 for this? Are there sample codes that I can take a quick 
> look? Also, where can I find the DOC for pywin32?

Well, here is the Microsoft repository of samples related to toast 
notifications and the action center.  The examples are all C# and JavaScript, 
but they can be translated.

https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Notifications
 
<https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Notifications>

There are lots of APIs for creating notifications, but I'm not aware of APIs to 
manipulate and respond to those notifications.  Those notifications are there 
for a reason, and they are expected to be handled by a human user.  What kind 
of notifications are you trying to dismiss?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Retrieve Windows Notifications With pywin32

2019-06-06 Thread Tim Roberts
On Jun 5, 2019, at 2:25 PM, DAI VU  wrote:
> 
> Thank you for the response. I need to deal with toast notifications. I am not 
> sure if that answer your question.

Well, I was really going for a philosophical point.  Most toast notifications 
are things that the user needs to deal with.  There are many things that would 
be inappropriate for you to dismiss.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Problem reading a shortcut (.lnk) with cPython 3.7 (32 bit)

2019-06-18 Thread Tim Roberts

David Hughes wrote:


I'm in the process of upgrading my software from Python 2.7 to 3.7 now 
that wxPython has been migrated to 3. As part of a procedure for 
upgrading an end user's own installation I check for it's location via 
the desktop shortcut that Innosetup created during the original 
installation.


That's not a particularly good method in the general case.  I don't find 
much use for the desktop icon, so I suppress it.  You might be better 
served to use the registry, in 
HKEY_LOCAL_MACHINE\Software\Python\PythonCore.  32-bit installations 
will be in HKEY_LOCAL_MACHINE\Software\WOW6432Node\Python\PythonCore (if 
you're reading from a 64-bit app).



I have a procedure for doing this that worked/works fine with Python 
2.7 that is very similar to the one published in 
/http://timgolden.me.uk/python/win32_how_do_i/read-a-shortcut.html/. 
Neither mine nor Tim's works under Python 3.7 (I haven't checked any 
other version of 3). With Tim's version, when the line


    name, _ = link.GetPath (shell.SLGP_UNCPRIORITY)

is executed, after a delay it responds with /aborted (disconnected)/ 
and the program terminates, as does mine.


Is it possible you have installed a 32-bit Python on a 64-bit system?  
Theoretically, you should be able to use CLSID_ShellLink from either 
one, but I'm trying to narrow things down.  Tim's code works fine for me 
with Python 3.7.2 (64 bit) on Windows 10.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] connecting to labview executable

2019-05-12 Thread Tim Roberts
On May 9, 2019, at 11:50 PM, Kálózi Zsolt  wrote:
> 
> So this continously reads out the value from the frontpanel of the .vi, that 
> is called 'power'.
> Unfortunatelly this only works if the .VI is running in the LabView IDE. 
> That is okay for the test environment but not okay in the real environment.
>  
> I will have an .EXE file that was generated from the .VI, so I need to access 
> that one. How can I do that with this library? Because simply changing the 
> path to the executable path doesn't work.
> Under 'advanced' I also tried to enable and give a name to the ActiveX 
> server, when I generate the executable, and give that name to the Dispatch, 
> but that didn't work either.

I'm trying to interpret what you've said here.  Are you saying that the 
win32com.client.Dispatch statement only connects to LabView if your executable 
is already running?  If so, then all you should have to do is use os.spawn or 
subprocess.Popen to launch the executable.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



smime.p7s
Description: S/MIME cryptographic signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] getvireference issue

2019-05-09 Thread Tim Roberts
On May 9, 2019, at 4:53 AM, Kálózi Zsolt  wrote:
> 
> I'm writing this mail by hoping someone could help. I have pywin32-224 
> installed on my computer. 
> The following code doesn't seem to work:
> import win32com.client
> 
> labview = win32com.client.Dispatch("LabView.Application")
> VI = labview.getvireference(r'Controller.vi')
> I get the following error:
> 
> AttributeError: ' instance at 0x43780248>' object has no attribute 'getvireference'

The actual spelling is GetVIReference.  Does that work?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Dispatch command hangs

2019-08-15 Thread Tim Roberts
On Aug 14, 2019, at 6:12 PM, Joel Gross  wrote:

> I have a multi-threaded application that receives a large number of messages 
> (COM objects) in sudden bursts. During this time, I've noticed that if my 
> other thread attempts to create a new COM object via the Dispatch call, that 
> call seems to hang until the messages have been processed. This can take more 
> than a minute sometimes. 
> I am wondering if this is because the win32 side of things is still trying to 
> churn through all the messages? Is there a way to preempt this behavior to 
> ensure that the object I'm trying to create gets created immediately?
> 
This is a complicated topic.  Are you calling CoInitialize?  By default, that 
will create a “single-threaded apartment”, where actions get handled by a 
single thread.  You can try calling CoInitializeEx with COINIT_MULTITHREADED 
and see if that helps.

But even then, you bang up against the Python interpreter lock, which only 
allows the interpreter to handle one thread at a time.  I wouldn’t think you’d 
have to wait for the whole set of object requests to drain, but threading in 
Python is always tricky.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Dispatch command hangs

2019-08-15 Thread Tim Roberts
On Aug 15, 2019, at 9:28 PM, Joel Gross  wrote:
> 
> Yeah I'm calling CoInitialize. I can give CoInitializeEx a shot, but there's 
> no clear-cut way to set a priority for Dispatch? I'm not sure how these 
> objects are handled internally, is it just a regular queue?

Is this an out-of-process server, so you’re receiving requests from other 
processes?  If so, then I think you’re seeing RPC (Remote Procedure Call), 
which marshals the parameters back and forth, and I believe those are all 
first-come first-served.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] DoAction problem

2019-07-28 Thread Tim Roberts
On Jul 26, 2019, at 8:05 AM, sylvain.fe...@ville-ge.ch wrote:
> 
> My photoshop action is doing : 
> - Open 
> - Smart sharpen 
> - Convert to Profile current document 
> - Save 
> - Close 
> 
> If Pillow is also able of "smart sharpening" and "converting to Profile 
> current document", your suggestion is very promising.

Did you even look?  Pillow includes both a tunable “sharpen” filter and an 
“unsharp mask” filter, as will every competent graphics library.

The color profile conversion isn’t really necessary.  My guess is you’re not 
really sure what it does anyway.


> Is there any place on the Web where I can find reference to psApp tasks like 
> "DoAction", "Export", the parameters they need, etc.? It seems that it is not 
> so easy. Well, this is maybe again a very naive question. 

Those are Photoshop questions.  Adobe has documentation on the Photoshop APIs, 
and they have their own user forums.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] DoAction problem

2019-07-25 Thread Tim Roberts

sylvain.fe...@ville-ge.ch wrote:


New in Python and coding.

My goal :
Apply recorded actions in Photoshop to many folders and subfolders 
containing images.


My inspiration :
Web page explaining a Python code using pywin32 : 
https://vsfxryan.com/portfolio/python-photoshop-action-scripts/, but I 
do not want to define functions, I am too much beginner for this.


Problematic code :
#run action script which opens the file, convert it to jpg, save and 
close it.

psApp.DoAction( actionScript, 'jpg_q8')

Error message :
NameError: name 'actionScript' is not defined

Could you please help me solve this?


Functions are fundamental to programming in general and Python in 
particular.  You need to understand them if you're going to get anything 
done.  Otherwise, you'll end up typing the same code over and over and over.


In this case, it looks like you are trying to run this code outside of 
the function it was defined in.  The error is pretty much 
self-explanatory; you're trying to pass the value of the variable 
"actionScript" to the DoAction function, but there is no variable called 
"actionScript".  Look at the code itself.  You'll see that 
"actionScript" was passed in to the function as a parameter, because he 
wanted to be able to trigger different actions with the same code.


It should be clear that what you need to pass here is the action you 
want to take.


However, if you really need to script common actions to images and 
folders, I strongly suggest you take a look at the ImageMagick package.  
It is an incredible powerful photo manipulation tool that is all driven 
from the command line.  It can be a bit tricky to set up the command 
lines, but once you do, it works the same way, time after time.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] DoAction problem

2019-07-25 Thread Tim Roberts

sylvain.fe...@ville-ge.ch wrote:

Some little progress :
Problematic code modified :
psApp.DoAction('jpg_q8','Default Actions') # where 'jpg_q8' is the 
recorded action and 'Default Actions' the folder where the action is 
saved.


Right -- the "action set" in Photoshop terms.


No more error message, but... no result : my tif files are not 
transformed to jpg files.


The Python part is now working.  WE have no way of knowing what your 
Photoshop action is doing.  Is it actually doing the save, or do you 
need to call psApp.Export?


And, by the way, if ALL you need to do is convert TIF to JPG, you 
certainly do not need to launch the Photoshop behemoth for that. Just 
use pip to install "pillow", the Python Imaging Library, and all you 
need is this:


    from PIL import Image
    Image.open('myfile.tif').save('myfile.jpg')

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Calling Methods of an object returned by an COMObject method

2019-09-20 Thread Tim Roberts
On Sep 19, 2019, at 10:51 AM, Andreas Merl  wrote:
> 
> I am trying to automate CST Studio.
> ...
> As example “Quit()”
> When I try to call this method nothing happens
> mws.Quit()
> It should quit the project.
> What happens:
> Nothing
>  
> For me it looks as the methods of mws are never called.

Have you tried the other methods, or are you basing that conclusion on exactly 
1 sample?

How can you tell it didn’t quite the project?  Does the app open a new instance 
when you call EnsureDispatch?  Excel, for example, is perfectly happy to run in 
the background as a COM server, so there’s no visible change when you quiet.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to set value with PyIPropertyStore

2019-11-10 Thread Tim Roberts
On Nov 10, 2019, at 4:13 PM, Peng Chen  wrote:
> 
> then I tried
> riid = ""
> ctx = None
> properties = propsys.SHGetPropertyStoreFromParsingName(
> file_name, ctx, shellcon.GPS_READWRITE, riid)
> it reported:
> (-2147221005, 'Invalid Class String', None, None)

That’s correct.  “” is not a valid class string.  
SHGetPropertyStoreFromParsingName returns a COM interface, and you have to tell 
it what interface you want.  It is usually IPropertyStore.

What are you trying to do here?  Are you porting some C++ code you found into 
Python?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] NotifyAddrChange

2019-11-05 Thread Tim Roberts
On Nov 5, 2019, at 2:24 AM, Yvan Manon  wrote:
> 
> I'm new with pywin32
> I would be inform about network ip change, is pywin32 can access to 
> NotifyAddrChange
> https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-notifyaddrchange
> or is it a way to handle this or any advise to manage it

Did you do any web searching at all for this?  Google is way faster than this 
mailing list.  The first two hits show you how to do this with ctypes, or try 
cab use this package:

https://sourceforge.net/projects/iphelpers/files/ 
<https://sourceforge.net/projects/iphelpers/files/>
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to set value with PyIPropertyStore

2019-11-07 Thread Tim Roberts
On Nov 7, 2019, at 2:33 PM, Peng Chen  wrote:
> 
> I tried:
> dateShifted = propsys.PyPROPVARIANT(
> mDate + shift_time.timedelta_obj, pythoncom.VT_DATE)
> and it reports:
> module 'win32comext.propsys.propsys' has no attribute ‘PyPROPVARIANT'

It is embarrassing that I had to figure this out twice today.
dateShifted = propsys.PROPVARIANTType(mDate+shift_time.timedelta_obj, 
pythoncom.VT_DATE)

The PROPVARIANTType function returns a PyPROPVARIANT object.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to set value with PyIPropertyStore

2019-11-14 Thread Tim Roberts
On Nov 14, 2019, at 4:15 PM, Peng Chen  wrote:
> 
> Nah, thanks, the stuff I'm trying to do is actually quite simple.
> I try to read the "Encoded date" info from video file, apply a timeshift and 
> write it back.
> I searched a few different libs, they are either works for image files only 
> or it's read only and I can't write.
> So I thought of pywin32 and really didn't expect this coming…

I’m pretty confident that the Windows property system will not be able to 
change the file itself.  These APIs might have filters that let them READ items 
from the media files, but I seriously doubt they will be to MODIFY media files.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to set value with PyIPropertyStore

2019-11-07 Thread Tim Roberts

Peng Chen wrote:

Hi Tim,
 Thanks for the reply. Sorry for the late. I just found your email 
today. Yes I tried with this code:


from win32comext.propsys import propsys, pscon
VIDEO_DATE_ENCODED = pscon.PKEY_Media_DateEncoded
properties = propsys.SHGetPropertyStoreFromParsingName(file_name)
mDate = properties.GetValue(VIDEO_DATE_ENCODED).GetValue() # got the 
datetime object

dateShifted = mDate + shift_time.timedelta_obj # shift date
properties.SetValue(VIDEO_DATE_ENCODED, dateShifted) # set value
properties.Commit()

and I got error message when executing to
properties.SetValue(VIDEO_DATE_ENCODED, dateShifted)


I found it.  Try

  dateShifted = propsys.PyPROPVARIANT(mData + shift_time.timedelta_obj, 
pythoncom.VT_DATE)


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] passing array by reference (3)

2019-10-27 Thread Tim Roberts
On Oct 27, 2019, at 5:06 AM, lcy  wrote:
> 
> Hello:
> Following the tips you mentitoned in the year of 2017
> I tried to test the  Catia.SystemService.Evaluate()  in pytyon, However it 
> cannont work, anything went wrong with my code? Any advice will be 
> appreciated, thank you!

What DID happen?

You don’t have a newline at the very end of the string. CATIA might need that.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to set value with PyIPropertyStore

2019-10-14 Thread Tim Roberts

Peng Chen wrote:


I'm working on a script to shift video media creation time.

I can see there is a function
PyIPropertyStore.SetValue(key, value) and PyIPropertyStore.Commit()
to write the date back, but I'm not sure how to construct the value 
because it requires PyPROPVARIANT type.
I can't figure out any where to import this type and doesn't know how 
to construct it.


PyPROPVARIANT is generally a return type.  In a case like this, I would 
expect that you would simply pass the datetime value, and the interface 
code would convert it into a variant.  Have you tried that?  Did you get 
an error?


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Word Application saving to PDF

2019-10-09 Thread Tim Roberts
On Oct 8, 2019, at 9:58 AM, Holland, James via python-win32 
 wrote:
> 
> I’m trying to open some rtf files to Word and then save as PDFs.
> ...  
> Traceback (most recent call last):
>  
>   File "", line 15, in 
> doc.SaveAs2(output_dir + '/' + 'rtfTest.pdf', FileFormat = wdFormatPDF)
>   File 
> "C:\Users\CMTHOL~1\AppData\Local\Temp\gen_py\3.6\00020905---C000-0046x0x8x7\_Document.py",
>  line 461, in SaveAs2
> , CompatibilityMode)
> com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Word', 
> 'Command failed', 'wdmain11.chm', 36966, -2146824090), None)

Did you do any web searching for this?  -2146824090 is 0x80A1066, which is a 
security issue.  Do you have permission to write into that directory?  Are you 
able to do this same action if you do it by hand?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pure python way to open a file with write deny for others

2020-03-06 Thread Tim Roberts

Robin Becker wrote:

On 05/03/2020 16:04, Eryk Sun wrote:

On 3/5/20, Robin Becker  wrote:
I want to be able to read a windows file which is being periodically 
written

by another process.


I'm having difficulty reconciling this sentence with the subject line.


OK I want to read the (small) file completely. The other process may 
try to re-write the file while I am reading it. I thought that denying 
them write permission for the short time I have the file open for 
reading might make incomplete files less likely. So far the 
applications seem to be able to operate in this fashion and the small 
files seem to be complete.


Remember that the "deny write" permission only applies to opens. And if 
you have "deny write" set, the other open will fail -- it won't just delay.


You can always use win32file.CreateFile directly, and bypass the Python 
filtering.  Alternatively, and perhaps more hacky, you can use 
subprocess to copy the file to a safe temporary name.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] VT_DECIMAL variant

2020-04-15 Thread Tim Roberts

Nikita Lepetukhin wrote:


Tim, thanks for replying!


VT_CY number doesn’t fit the precision I need (16 digits to the right 
of the decimal point). It has only 4 digits according to this description:


https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/5a2b34c4-d109-438e-9ec8-84816d8de40d


The decimal (VT_DECIMAL) has precision up to 28 places 
(https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/b5493025-e447-4109-93a8-ac29c48d018d 
<https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/b5493025-e447-4109-93a8-ac29c48d018d>). 
It is exactly the same as python decimal has. They match to each other 
exactly and much better than VT_CY and python decimal. So maybe it 
wasn’t the best solution to automatically convert python decimal to 
VT_CY variant. Whatever.. what’s done is done.


It's possible this is a misunderstanding in the pythoncom code. CURRENCY 
goes back to the days of Visual Basic 6, whereas DECIMAL is much more 
recent.  It may be appropriate to file a bug report.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] VT_DECIMAL variant

2020-04-15 Thread Tim Roberts

Nikita Lepetukhin wrote:
ok, I will report a bug. But to be honest I'm trying to find the 
solution.
Do I understand right that currently there is no way to pass 
VT_DECIMAL variant from python to com?


Oh, it is possible; the library does many automatic conversions, but 
it's possible to do it by hand.  I just don't know the recipe.  If Tim 
Golden is listening, perhaps he can point us to a reference.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] VT_DECIMAL variant

2020-04-15 Thread Tim Roberts


> On Apr 14, 2020, at 7:09 PM, Nikita Lepetukhin  wrote:
> 
> I use win32com module and everything is ok but I cannot find the way how to 
> pass VT_DECIMAL variant value to COM object's method.
> ...
> This is how the interface is described in gencache:
> class IProperty(DispatchBaseClass):
> CLSID = IID('{0A4C05A0-107B-4A8B-9E34-44ED9B117A25}')
> coclass_clsid = IID('{2171DCF1-B70B-4CAB-9EB7-F7FED71956B4}')
> 
> _prop_map_get_ = {
> "Value": (0, 2, (12, 0), (), "Value", None),
> }

That’s a property that returns a VT_VARIANT.


> In python code I get the object by the following way:
> ...
> I need to pass here VT_DECIMAL variant (due to data precision requirements) 
> but it comes to COM object implementation as VT_R8 variant.
> I tried to use decimal python type but it comes as VT_CY variant.
> 
> Could you help me to find out how to pass VT_DECIMAL variant from python to 
> COM?
> I would appreciate your help very much!

The VT_CY type, the Python decimal type, and the C# decimal type are all the 
same — a 128-point fixed point value with 92 bits of precision.  That’s 
probably what you should use.  In order to use VT_DECIMAL, then you probably 
can’t use automatic translation.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] User login details when running a service

2020-04-11 Thread Tim Roberts
On Apr 11, 2020, at 6:32 AM, Waseem Afser  wrote:
> 
> Is there any possible method to get the logged in user's username from a 
> windows service ? 

Your assumption that there is only one "logged in user” is false, which is why 
the information you seek is not readily available.

There is a WMI query that can return the name of all logged in users:

https://stackoverflow.com/questions/5218778/how-do-i-get-the-currently-logged-username-from-a-windows-service-in-net
 
<https://stackoverflow.com/questions/5218778/how-do-i-get-the-currently-logged-username-from-a-windows-service-in-net>
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



smime.p7s
Description: S/MIME cryptographic signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to change print copies

2020-04-23 Thread Tim Roberts
On Apr 22, 2020, at 10:10 PM, Pavel Olifer  wrote:
> 
> i use your package for changing  printer settings (duplex, copies).
> for duplex it is work, but for copies it doesn’t.

Some Windows printers don’t honor the “Copies” selection directly.  The 
application has to generate multiple copies on its own.  Have you seen a 
multi-copy setting work using the native driver?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"?

2020-04-30 Thread Tim Roberts
On Apr 30, 2020, at 11:47 AM, Terry Davis  wrote:
> 
> Thanks for the pointer! I'll let the maintainers of this software know.
> 
> Do you know if applying this fix is sufficient for win32com to successfully 
> handle returned structs?

I don’t know.  That was the fix suggested by the old mailing list threads I 
found.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"?

2020-04-28 Thread Tim Roberts

On Apr 27, 2020, at 12:58 PM, Terry Davis  wrote:
> 
> I looked in the generated file, and its RecordMap dict was empty, with a 
> comment. There are a dozen or so structs that should be available to the 
> interface. Is there any workaround for this, such as manually defining each 
> com_record?
> 
> RecordMap = {
> ###'LegacyMicroSamplerInfo': '{----}', # 
> Record disabled because it doesn't have a non-null GUID 
> }
> 
> I was also given an idl file, which includes record definitions, like this 
> one:
> 
> typedef struct SoftwareInfo {
>BSTR name;
>BSTR version;
> } SoftwareInfo;
> 
> Is there something missing from the idl file that's causing these to be 
> missed by win32com?

Well, yes.  There are rigid rules for writing IDL to make a valid dispatch 
interface, and generic structs like that are not in those rules.  Some people 
get the idea that anything they can express in C++ can be shoved in a COM 
interface, but it ain’t so.

You should be able to add a GUID attribute to the IDL:

[ uuid(12345678-1234-1234-1234-123456789ABC) ]
typedef struct SoftwareInfo {
…
} SoftwareInfo;

Just generate a new GUID for each one.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to install pywin32 for Text only/TTY, excluding all GUI components

2020-05-24 Thread Tim Roberts
On May 23, 2020, at 4:27 AM, Markus Kramer  wrote:
> 
> Hello,
> I would like to discuss and contribute to an alternative pip package without 
> GUI: 
> - pip install pywin32   continues as is, e.g. includes Pythonwin.
> - pip install pywin32nogui  would contain no GUI components, e.g. MFC.dll.
> What are your thoughts?

What is the point?  Installing a package does not mean you are required to use 
all of it.  If you ship a package that doesn’t need the UI components, then 
your package will not include the components.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to use win32process.CreateRemoteThread

2020-09-11 Thread Tim Roberts
On Sep 10, 2020, at 7:24 AM, june y  wrote:
> 
>  <https://stackoverflow.com/posts/63814377/timeline>i am studying 
> win32process of pywin32.
> 
> but, i encounter a problem.
> 
> problem is I don't know win32process.CreateRemoteThread wants what arguments
> 

CreateRemoteThread does not work with Python functions.  It is a C API, and it 
expects to be handed the address of a C function in the other process.  id(x) 
returns to you an address, but it’s an address that has to be interpreted by 
the Python interpreter run-time, and the Python run-time will not be part of 
the other process.

If you want to do threading in Python, use the ’thread’ or ’threading’ modules. 
 Don’t use win32process for that.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

2020-09-08 Thread Tim Roberts

Shaik Saleem Basha wrote:
When I downloaded  install python  by default  it installed  32bit 
version only so pywin32 also I installed 32bit only

Quicopc library is installed


If QuickOPC is a 64-bit component, then you need to call it from a 
64-bit process.  This is not always an easy thing to determine. If a 
company wants to support both 32-bit and 64-bit processes, then it has 
to install two different COM servers.  I suggest you describe your 
problem to the QuickOPC folks; they would know right away if this were 
the issue.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

2020-09-08 Thread Tim Roberts

Shaik Saleem Basha wrote:


Hi,

I’m using python 3.8.5 32 bit  and also I have installed pywin32 by 
this command pip install pywin32 but when I execute my coed i’m 
getting the following error pywintypes.com_error: (-2147221005, 
'Invalid class string', None, None)


My code :

import win32com.client

client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient')

value = client.ReadItemValue('','OPCLabs.KitServer.2', 'Demo.Single')

print('value:',value)

The most obvious question, of course, is do you actually have the 
QuickOPC .NET library installed?


Why did you choose the 32-bit Python, instead of the 64-bit Python?

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

2020-09-09 Thread Tim Roberts
On Sep 8, 2020, at 9:18 PM, Shaik Saleem Basha  
wrote:
> 
> Thank you for your response I will to that .
>  
> But my issue is not only with Quickopc , I have installed OpenOPC in that 
> also I’m getting same error

OpenOPC is just a wrapper around the other OPC clients.  If you have 64-bit 
clients, OpenOPC will also fail as well.  However, I do not see QuickOPC in the 
list of classes supported by OpenOPC.


> In my Case pywin32 is not matching with the version python I’m using .

Why do you think so?  You have Python 3.8, and the Pywin32 is for Python 3.8.  
If there were a mismatch, you couldn’t call Dispatch at all.


> Can you please suggest me the versions which I can use to solve this errors , 
> because the same version I’m using in another windows laptop there I’m not 
> getting this errors.

Either something has gone wrong with your QuickOPC installation, or you need 
the 64-bit Python.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Strange issues when using pywin32 to develop solidworks

2020-10-07 Thread Tim Roberts
On Oct 5, 2020, at 5:45 PM, nicolas jacky  wrote:
> 
> I test below code snippets in vscode with enviroment of python 3.8, pywin32 
> build 228, solidworks 2017 API sets and created .py files by makepy, I get 
> some strange errors.
> first snippet
> 
> # -*- coding: utf-8 -*-
> from win32com.client import *
> from pythoncom import *
> swx = Dispatch("SldWorks.Application")
> swModel = swx.ActiveDoc
> mathUilty = swx.GetMathUtility
GetMathUtility is a method, not a property.  You need to call it as a function:

mathUtility = swx.GetMathUtility()

ActiveDoc is a property, and so should not need parens.


> Running this code and vscode says:
> 
> line 15, in 
> swModel.AddComponents3(vtName,vtTrans,vtCoordName)
> TypeError: 'NoneType' object is not callable
> If I code it like this 'swModel.AddComponents3' then it's ok.
> 
What is the difference?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] AES based win32crypt lib for python3

2020-10-07 Thread Tim Roberts
On Oct 5, 2020, at 8:24 AM, Raja Sekhar  wrote:
> 
> I have seen win32crypt lib for python, And it is built on DES algorithm.

Sort of.  Triple-DES is used to protect the master key derived from the 
credentials, but I’ve never seen Microsoft say what they actually use to 
encrypt the data blob.


> I am searching for such library in Python using  AES Algorithm. I have gone 
> through pyAesCrypt, Crypto.Cipher  which is taking an explicit key for 
> encryption. 
> I would be grateful if you could help me to find a library in python3,
> which uses AES encryption library similar to win32crypt which encrypts data 
> using a session key derived from current user's logon credentials  as in 
> ‘CryptProtectData’
> function.

Nope.  Remember that win32crypt is nothing but a thin layer that calls the 
Windows CryptProtectData API.  The API does a remote procedure call into the 
Windows LSA (Local Security Authority) to get access to the login credentials 
through an undocumented internal function.

You can certainly find AES encryption for Python, but it’s not going to use the 
login credentials.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Any update on this issue? https://github.com/mhammond/pywin32/issues/1568

2020-09-24 Thread Tim Roberts
On Sep 23, 2020, at 10:46 PM, Patrick Bolliger  wrote:
> 
> I experience the same problem as described in the issue 
> (https://github.com/mhammond/pywin32/issues/1568 
> <https://github.com/mhammond/pywin32/issues/1568>).
> I reached out to Mark Hammond who suggested to ask on this mailing list.
> 
> Also tried to work with makepy.py -d to identify possible libraries but 
> nothing found.
> It is my office computer switched from WIn7 to Win10, Excel is 64-bit version 
> (Not having any admin rights, so not possible to investigate very deep)
> 
> So I am not sure if as the library is called „win32com“ it can not work on 
> 64-bit Excel, so any plans for win64com? :-)

If you have a 64-bit Python, then your win32com is a 64-bit library.  Exactly 
which error do you get?  That large negative number is a COM error code.

Are you sure you still have Excel installed?  Are you quite sure it’s a 64-bit 
Excel?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



smime.p7s
Description: S/MIME cryptographic signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] python-win32 Digest, Vol 205, Issue 5

2020-05-25 Thread Tim Roberts
On May 24, 2020, at 9:21 AM, Markus Kramer  wrote:
> 
> The points are:
> - Reduce vulnerability. The MFC library is large and (earlier? versions) 
> contained CVE's. 

Whatever vulnerabilities there might be aren’t a factor if you aren’t using 
them.


> - Reduce maintenance cost. By shipping less, you need to observe less, and 
> patch less.

You are missing the point.  Pywin32 simply makes all those thing available to 
you.  You don’t have to use them.  And if you aren’t using the graphical 
interfaces, then you aren’t shipping them.  The Python installer apps only 
include the things your script needs.  If you don’t need graphics, then 
graphics DLLs won’t be included in your package.

And your proposal will, of course, INCREASE the maintenance cost for the 
Pywin32 programmers, who now have to deal with multiple packages.


> - Reduce resources. Less size mean less disk space and less network bandwidth.

The MFC DLLs are about 100MB.  At today’s mass storage prices, that’s 3/10 of 
one American penny.  Network bandwidth will not be an issue for your 
applications, because MFC won’t be included in your application.


> Then you wrote
> > If you ship a package that doesn’t need the UI components, then your 
> > package will not include the components.
> 
> This is my goal. 
> I don't get what you refer to with "package". 
> Currently, `pip install pywin32` will include the UI components, even if they 
> are not needed.

When I say “package”, I mean an application package that you want to 
distribute, created by something like pyinstaller.  It will only include the 
components your application needs.

I just don’t see that there is anything to gain in making such a substantial 
change.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to install pywin32 for Text only/TTY, excluding all GUI components

2020-05-26 Thread Tim Roberts
On May 26, 2020, at 6:29 AM, Vernon D. Cole  wrote:
> 
>   I don't understand.  If I include pywin32 as a pip requirement, then I get 
> the whole thing, I think. How can I "ship a package" without carrying the 
> unneeded parts around?

I am under the impression that most people shipping Windows Python applications 
do so using something like Pyinstaller or Py2Exe, which packages up something 
that looks to the end user like a single executable, but which actually 
contains a zip file with the necessary modules and DLLs.  The zip file only 
contains the parts of pywin32 that are actually required by the application.

If you’re shipping your application via pip on WIndows, then virtually everyone 
will already have pywin32.  It is a critical component.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Licensing requirement for usage of win32com APIs through python package (pywin32)

2020-08-02 Thread Tim Roberts
On Aug 2, 2020, at 12:48 PM, Adil Mujeeb  wrote:
> 
> I couldnt see my question in  https://mail.python.org/pipermail/python-win32/ 
> <https://mail.python.org/pipermail/python-win32/> 
> I am not sure if it gets delivered or not.

You waited less than 30 minutes before complaining.  Mailing lists take longer 
than that.


> On Sun, Aug 2, 2020 at 12:19 AM Adil Mujeeb  <mailto:mujeeb.a...@gmail.com>> wrote:
> 
> What is the license clause if this python script will be used to test a 
> commercial Application development?

The license does not change based upon what you’re writing.  If you’re not 
releasing this to the public, then the license is totally irrelevant.  You can 
do whatever you want internally.


> I wanted to be sure that this allows in creating scripts to test commercial 
> product and if internally allows Microsoft license.

How does a Microsoft license get involved?  I think you’re worrying more than 
you need to here.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Pythonwin.exe - trouble on the starting line

2020-07-20 Thread Tim Roberts

ejohn...@earthlink.net wrote:

I wanted to look into using Pythonwin to see how difficult it would be to build 
GUIs using MFC.


This isn't what you asked for, of course, but in my opinion you would be 
better served to start with wxPython.  The basic philosophy is somewhat 
similar to MFC (the two libraries started at pretty much the same time), 
and wxPython has the advantage of being cross-platform.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Server Exectuion Failed

2020-11-12 Thread Tim Roberts
On Nov 12, 2020, at 12:32 PM, Bob Fang  wrote:
> 
> I have an application which utilise win32com to control a software 
> (powerworld if you know what it is). Once I have dispatched a new object I 
> can see in task manager there is a new process created which is running and I 
> can call command through the win32com object -- this is what I want to do and 
> suits me well but I noticed two things:
> 
> 1. The process I created seems to be persistent and will not die even if I 
> explicitly deleted my object using `del` in Python. Is there a way to fully 
> close the process after I am done with my object?

It’s up to the the application.  Out-of-process servers often provide a “close” 
or “exit” method to tell them to clean up.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Use TPM from Crypto API

2020-11-22 Thread Tim Roberts
On Nov 22, 2020, at 4:16 AM, Antoine FERRON via python-win32 
 wrote:
> 
> Can you confirm that TPM "Microsoft Platform Crypto Provider" requires "CNG", 
> and pywin32 is only "CAPI" capable ?

This is not a Python question at all.  Look at the MSDN documentation page for 
the CryptEnumProviders API.  You’ll see that it is deprecated, and only 
accesses the base cryptographic provider and the enhanced cryptographic 
provider.  Remember that pywin32 is, in almost every case, a relatively thin 
wrapper around the Windows APIs.


> Anyway, do you have some ideas in mind to reach my goal ?

The APIs from ncrypt.dll are not, as of yet, exposed in pywin32.  You can 
certainly use ctypes to access them.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Using python to create outlook rules - comtypes (working) vs. pywin32 (not working)

2020-10-30 Thread Tim Roberts

Caio Kauffmann wrote:


I am a hobby programmer and after days trying to figure out what I am 
doing wrong, I still can’t finish a project because of the issue I 
listed in this topic in stack overflow: 
https://stackoverflow.com/questions/64594689/python-comtypes-working-vs-pywin32-not-working-using-python-to-create-o



This is not Visual Basic.  The following statement does nothing in Python:

|oFromCondition.Recipients.ResolveAll|

If you want the method to be called, you have to call it:

|oFromCondition.Recipients.ResolveAll()|

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to code pywin32 run existing window task scheduler?

2021-01-14 Thread Tim Roberts
On Jan 13, 2021, at 8:07 PM, Pongthorn Sangkaphet 
 wrote:
> I am interested in pywin32 . I am going to use it to run window task 
> scheduler through Django web application ?
> 
> Does pywin32 provide some features or method to run window task scheduler?
> 
Obviously, since you’re already using them.  ;)
> I have tried already but error
> 
That’s 0x80070005, which is ERROR_ACCESS_DENIED.  Have you tried running this 
from an elevated process?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Basic question about pywin32, does it work with 64 bit versions of O365?

2021-01-21 Thread Tim Roberts
On Jan 21, 2021, at 8:23 AM, Charlie Lamm  wrote:
> 
> I am contemplating rolling out some pywin32 scripts but my office has a 
> combination of 64 bit and 32 bit local office365 builds.
> Q: Will pywin32 scripts work w/ 64 bit office?
> Because of shelter in place I don’t have a W10 machine running 64 bit office 
> to test this on, but maybe someone knows?

Usually, with a COM server, the bit size of your Python must match the bit size 
of your COM server.  So, you'd need to use 64-bit Python to call a 64-bit COM 
server.  (Note thet pywin32 is available for both 32-bit and 64-bit Pythons.)

However, the Office applications are out-of-process servers, so there’s a proxy 
in the middle, and that should let it work.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Error: VARIANT Type is unknown

2021-01-26 Thread Tim Roberts

Olle Pontén wrote:


Hmm ok, I could find the following information using OLEView (se 
attachment).
It states that the two in parameters are noted as VT_LPWSTR for the 
scriptCmd command.

Would that mean that I have no way of interfacing with them at all?


No, it doesn't mean that!  If it doesn't ask for a variant, then you 
don't deliver a variant.  Did you try just passing a string, as Mark 
suggested?


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Issue with monitor off

2021-06-10 Thread Tim Roberts

anteqqq1 wrote:
Hello there, I have a question concerning Win32 usage. The idea is 
that after operations in python i want to turn my monitor off but when 
i use Win32 command win32gui.SendMessage(win 32con.HWND_BROADCAST, 
win32con.WM_SYSCOMMAND, win32con.SC_MONITORPOWER , 2) the monitor not 
only goin off state but the machine is also going sleep mode . My 
question is : Is there any way to prevent machine going to sleep ? The 
only thing i need is to turn monitor off :)


The operating system can do this for you automatically, in the "Power & 
Sleep" control panel page.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.




smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


<    6   7   8   9   10   11   12   >