Re: [python-win32] Object type puzzle

2023-01-07 Thread Tim Roberts

On 1/7/23 7:11 AM, Bob Kline wrote:


As a very minor side note, just so you know, it looks like there's a
bug in the mailing list software. I went back to the original of my
previous post, and the ">" character which appears at the beginning of
the paragraph beginning "From what I can tell ..." was not in the
message that I sent, but was added by the mailing list, making it look
as if that paragraph might have been part of the quoted message to
which I was replying, instead of what it actually was (part of my own
reply).


Ah, you youngsters who don't remember the glory days.  That's not a bug, 
it's a feature.


In the early days, mail messages were stored in a standard format called 
"mbox".  This was a simple, plain text format that just had the text of 
every message.  The separator between messages was a line that read 
"From  Sat Jan 07 11:14:59 2023".  So, any line in a 
message that started with the word "From" needed to be escaped to 
prevent it from being read as a separator. The traditional escapement 
was to change it to "> From".


--
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] List all fonts filename

2023-01-05 Thread Tim Roberts

Moi15 Moi wrote:
My goal is to list all the filename of the font installed without 
listing the file in those 2 folders:

- C:\Windows\Fonts
- %userprofile%\AppData\Local\Microsoft\Windows\Fonts

I found a way to do it directwrite: 
https://gist.github.com/JeremieBergeron/dc04bcb747c94a82a10020a990ba884a

But, from what I can see, pywin32 doesn't support directwrite api.


It's just COM, which pywin32 does perfectly well.  The advantage of COM 
is that you don't need a custom interface.  Did you look at the pyglet 
code that does this?



But, I don't know how I get the font path 
(ex: C:\Users\Admin\AppData\Local\Microsoft\Windows\Fonts\Jester.ttf) 
with GDI


The easier way would be to read the registry. 
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" 
is where Windows stores the registered fonts.  The key is the font name, 
the value is the file name.  If there is a file name without a path, it 
defaults to C:\Windows\Fonts.


--
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] List all fonts filename

2023-01-03 Thread Tim Roberts

On 1/3/23 6:13 PM, moi15moismokerlolilol wrote:


I don't wanna list the family name.


Then what do you want?  Do you understand how Windows arranges fonts?  
"Arial" is a font family.  "Tahoma" is a font family.  You can enumerate 
all of the fonts using the WIn32 API, and everything in the Win32 API 
can be accessed through pywin32.


--
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] List all fonts filename

2022-12-30 Thread Tim Roberts

On 12/23/22 6:29 AM, Moi15 Moi wrote:



Is it possible to list all the fonts filename with pywin32?

From what I can see, it is possible with the GetFontData 
<https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getfontdata> from 
GDI.


GetFontData is certainly available in pywin32, as are most Win32 APIs.  
However, it only returns information about one font at a time -- the 
font that is currently selected into that DC.


You can use EnumFontFamilies or EnumFontFamiliesEx, available in win32gui.

http://timgolden.me.uk/pywin32-docs/win32gui__EnumFontFamilies_meth.html

https://stackoverflow.com/questions/5760594/pywin32-enumfontfamilies-breaks-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] Trouble finding MSOLAP provider with adodbapi

2022-12-06 Thread Tim Roberts

savoy wrote:


I've downloaded the most up-to-date MSOLAP library from Microsoft's site
(16.0.56.19) and installed it. The location of the library is then saved
as C:\\Program Files (x86)\Microsoft Analysis Services\AS
OLEDB\140\msolap.dll.


That's a 32-bit DLL.  Your ODBC driver needs to match your Python 
bittedness, and most of us run 64-bit Python.  Is there a 64-bit version 
of the connector?


--
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] Pywin32 without the interface

2022-12-02 Thread Tim Roberts

On 12/2/22 12:10 PM, Tim Roberts wrote:


On 12/2/22 4:25 AM, QMUL_EECS DVS wrote:

Is it related to the fact that I can’t open Visio/ Word windows? If 
so, is there a way for me to avoid this error?


The first and most obvious question is, do you actually have Office 
and Visio installed on your AWS instance?  How did you do that without 
a UI?  Launching Word like this usually does not bring up a UI window 
unless you specifically set "xxx.Visible = True", so I'm guessing 
there's something else going on.


My apologies for the multiple replies.  Either my connection or my mail 
server had a "burp", and it told me it had not sent anything when it 
clearly had.


--
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 without the interface

2022-12-02 Thread Tim Roberts

On 12/2/22 4:25 AM, QMUL_EECS DVS wrote:



Thanks for replying. Apologies for my vague question, let me see if I 
can rephrase: I want to run pywin inside an aws instance, which only 
allows for command line interface.


Currently I can use pywin in my local machine, but it needs to open 
Visio and Word windows. However, in the aws instance it throws an error:

‘ Traceback (most recent call last):

File "C:\Program 
Files\Python37\lib\site-packages\win32com\client\dynamic.py", line 86, 
in _GetGoodDispatch


IDispatch = pythoncom.connect(IDispatch)

pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)

...

File "C:\Program 
Files\Python37\lib\site-packages\win32com\client\dynamic.py", line 89, 
in _GetGoodDispatch


IDispatch, None, clsctx, pythoncom.IID_IDispatch

pywintypes.com_error: (-2147024891, 'Access is denied.', None, None)’

Is it related to the fact that I can’t open Visio/ Word windows? If 
so, is there a way for me to avoid this error?


The first and most obvious question is, do you actually have Office and 
Visio installed on your AWS instance?  How did you do that without a 
UI?  Launching Word like this usually does not bring up a UI window 
unless you specifically set "xxx.Visible = True", so I'm guessing 
there's something else going 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] Pywin32 without the interface

2022-12-02 Thread Tim Roberts

On 12/2/22 4:25 AM, QMUL_EECS DVS wrote:



Thanks for replying. Apologies for my vague question, let me see if I 
can rephrase: I want to run pywin inside an aws instance, which only 
allows for command line interface.


Currently I can use pywin in my local machine, but it needs to open 
Visio and Word windows. However, in the aws instance it throws an error:

‘ Traceback (most recent call last):

File "C:\Program 
Files\Python37\lib\site-packages\win32com\client\dynamic.py", line 86, 
in _GetGoodDispatch


IDispatch = pythoncom.connect(IDispatch)

pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)

...

File "C:\Program 
Files\Python37\lib\site-packages\win32com\client\dynamic.py", line 89, 
in _GetGoodDispatch


IDispatch, None, clsctx, pythoncom.IID_IDispatch

pywintypes.com_error: (-2147024891, 'Access is denied.', None, None)’

Is it related to the fact that I can’t open Visio/ Word windows? If 
so, is there a way for me to avoid this error?


The first and most obvious question is, do you actually have Office and 
Visio installed on your AWS instance?  How did you do that without a 
UI?  Launching Word like this usually does not bring up a UI window 
unless you specifically set "xxx.Visible = True", so I'm guessing 
there's something else going 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] Pywin32 without the interface

2022-12-02 Thread Tim Roberts

On 12/2/22 4:25 AM, QMUL_EECS DVS wrote:



Thanks for replying. Apologies for my vague question, let me see if I 
can rephrase: I want to run pywin inside an aws instance, which only 
allows for command line interface.


Currently I can use pywin in my local machine, but it needs to open 
Visio and Word windows. However, in the aws instance it throws an error:

‘ Traceback (most recent call last):

File "C:\Program 
Files\Python37\lib\site-packages\win32com\client\dynamic.py", line 86, 
in _GetGoodDispatch


IDispatch = pythoncom.connect(IDispatch)

pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)

...

File "C:\Program 
Files\Python37\lib\site-packages\win32com\client\dynamic.py", line 89, 
in _GetGoodDispatch


IDispatch, None, clsctx, pythoncom.IID_IDispatch

pywintypes.com_error: (-2147024891, 'Access is denied.', None, None)’

Is it related to the fact that I can’t open Visio/ Word windows? If 
so, is there a way for me to avoid this error?


The first and most obvious question is, do you actually have Office and 
Visio installed on your AWS instance?  How did you do that without a 
UI?  Launching Word like this usually does not bring up a UI window 
unless you specifically set "xxx.Visible = True", so I'm guessing 
there's something else going 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] Pywin32 without the interface

2022-11-30 Thread Tim Roberts

On 11/30/22 8:16 AM, QMUL_EECS DVS wrote:

I hope you are well. I’m trying to use pywin32 on my local server, is 
it possible to run it without the Visio/ Word interface open? Since I 
can only see the command line


The question doesn't make much sense.  Are you saying that you want to 
automate Visio and Word through pythoncom, but you don't want the 
application window to be visible?  That can be done. Please clarify.


--
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] Looking for PyWin32 for Python 2.3.1

2022-11-15 Thread Tim Roberts

Paul Newton wrote:


Thanks for your reply Tim and my apologies - I did not mean to be rude 
and I take your point.  I made an earlier mistake, my Python version 
is 2.1.3 not 2.3.1 but I am looking at doing an install using 
pywin32-200.zip.


You don't really want to build these from source.  It does look like 
that file is missing, but even if it weren't, that is a project file for 
Visual Studio 2003.  You almost certainly do not have a copy of Visual 
Studio 2003 hanging around, and they typically don't build with newer 
compilers.  Just use the executable installer.


The DSP is present in the 201.1 zip.  I don't know whether that builds 
for Python 2.1 or not.


--
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] Looking for PyWin32 for Python 2.3.1

2022-11-15 Thread Tim Roberts

Paul Newton wrote:


Please don't ask why I would want to install such an old version of 
Python, but I have Python 2.3.1 installed anyway.  Now I am looking 
for the corresponding PyWin32 install files.  I believe they are 
available here https://sourceforge.net/projects/pywin32/files/pywin32/ 
or here https://www.lfd.uci.edu/~gohlke/pythonlibs/ but I cannot 
fathom exactly what I need to download or what to do with the download.


If you click on version 200, for example, you'll see there is a file 
"pywin32-200.win32-py2.3.exe".  Download it and execute it. It will 
install itself in the proper location, which is stored in the registry.


And, as a rule, it's considered rude in a list like this to say "please 
don't ask why".  It may not be the case for you, but very often we get 
very specific off-the-wall questions that arose only because the asker 
took a wrong turn several steps ago.  By learning more about the "why", 
we can offer a much better overall experience.


--
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] Windows printing with the use of Device Context

2022-11-07 Thread Tim Roberts

On 11/7/22 5:25 PM, Neil Kenig wrote:


You may want to try https://pypi.org/project/PyMuPDF/.   It's relatively easy 
to create a blank PDF and then insert text of a given font and size at precise 
locations on the page.  PDF files use points (1/72nd of an inch) for both font 
sizes and location on a page and will print properly regardless of the 
printer's resolution (assuming the stock size is the same, e.g. US Letter or 
A4).  You can then print the PDF and if the preprinted stock is loaded into the 
printer, you should get the desired result.


This is excellent advice, and it has the huge advantage of being 
cross-platform.  The Windows printing API is, in my expert opinion, 
peculiar and finicky.


--
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] Windows printing with the use of Device Context

2022-11-07 Thread Tim Roberts

Antoine FINET wrote:


I would like to print information at the correct coordinates on a pre 
printed form.


If I understood correctly my readings, the coordinates given to a 
"TextOut" Printer Device Context depend on the resolution of the 
printer. Am I right?


Yes, but the exact same thing is true of on-screen windows.  You can use 
GetDeviceCaps(hdc, LOGPIXELSX) to get the pixels per inch resolution.  
There's also a LOGPIXELSY, but unless you have a 40-year-old graphics 
adapter, they are the same.  The DeviceCapabilities API returns a 
DEVMODE structure that has detailed information about the printer.



I don't have another printer to test but my underlying question is : 
does the coordinates depend on the printer?


Absolutely, yes.  Modern printers can be 300, 600, or 1200 dots per 
inch.  Label printers can use even wilder values.


--
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] Unpredictable behavior of pywin32 on new computer

2022-10-11 Thread Tim Roberts

On 10/11/22 12:23, Zach York wrote:

Interesting, thanks for the quick response. So would a quick way to 
test this out be to change the scaling to 100% from whatever it's set at?


That would be an interesting step.  Another thing to try is to call the 
APIs to make your app "high-DPI aware".  You can do that for one process 
using this code:


```

from ctypes import windll
user32 = windll.user32
user32.SetProcessDPIAware()

```

Or you can use a registry hack:

https://stackoverflow.com/questions/43401709/marking-your-python-program-as-high-dpi-aware-seamlessly-windows

--
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] Unpredictable behavior of pywin32 on new computer

2022-10-10 Thread Tim Roberts

Zach York wrote:


I have recently upgraded my computer and after upgrading and 
installing pywin32, I have found the behavior to be extremely 
unpredictable and in a lot of cases, just wrong.

...
My scripts are mostly trying to do some background clicking using 
PostMessage/SendMessage  and window resizing/positioning using 
MoveWindow. I used to be able to use SendMessage reliably before this 
computer upgrade, but now it seems like I need a combination of 
PostMessage + SendMessage to see a click at all). For MoveWindow, the 
results are entirely unpredictable (window isn't moved at all, window 
resized and moved to the wrong location, etc).


I assume this has to somehow be with my setup and not pywin32, but I 
am lost on what might be causing this weird behavior. Any insight 
would be greatly appreciated!


If you upgraded your display as well, the problem is probably the 
display scaling.  Unless you mark your application has being "high DPI 
aware", Windows will lie to you about pixel locations.  If your display 
is 3840x2160, but you have scaling set to 200%, your "non-aware" 
application will be told that the display is 1920x1080, and the pixel 
coordinates you are sending to other applications will be wrong.  Go 
read about "high DPI aware" applications.  It's a mess.


--
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] Hi

2022-07-06 Thread Tim Roberts

On 7/6/22 10:40, osama saadi via python-win32 wrote:


I am using colab and try to install pywin32.
I used the following code (!pip install pywin32) but I got error.

Please can you help me how to install it?


Colab runs on Linux machines.  PyWin32 does not run on Linux.

What APIs were you hoping to use?

--

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] Need a value from pywin32

2022-06-21 Thread Tim Roberts

On 6/21/22 13:39, Steven Manross wrote:


I was intrigued by this and I would like to get it to work, but I cannot...  I 
know I'm doing something wrong, but don't know what.  I will leave this for the 
archives, and maybe it will help someone else some day.
...
def get_wts_info(session_id):
 '''
 Get WTS Info
 '''
 # This only tries to work on the local server currently but I get an 
access violation running the WinStationQueryInformationW line

 Buf = ctypes.POINTER(WinStationInformation)()
 BufLen = 260

 hWinSta = ctypes.windll.LoadLibrary("WINSTA.DLL")
 if hWinSta:
 winsta_handle = hWinSta._handle
 print(f'winsta_handle = {winsta_handle}')
 QueryInfoHandle = 
ctypes.windll.kernel32.GetProcAddress(ctypes.c_ulonglong(winsta_handle), 
b"WinStationQueryInformationW")

 # This handle is 0...  possibly because of the numeric conversion from 
the winsta_handle to a ctypes.c_ulonglong  ???  unsure


No, 0 is the error return that means the name was not found.

You shouldn't need to use LoadLibrary and GetProcAddress.  ctypes does 
that for you automatically.


    winsta = ctypes.WinDLL('winsta.dll')

    winsta.WinStationQueryInformationW( 0, session_id, 8, 
ctypes.byref(Buf), BufLen, ctypes.byref(RtnLen))


If you have Visual Studio, you can try doing "link /dump /exports 
\windows\system32\winsta.dll" to make sure it has that entry point.


--
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] Need a value from pywin32

2022-06-20 Thread Tim Roberts

Craig R. Matthews wrote:


I have a need to determine the "IDLE TIME" as provided by the Windows 
Query program.


Sample output:
C:\>query user /server:CTX202201
 USERNAME  SESSIONNAME    ID  STATE   IDLE TIME LOGON TIME
 administrator rdp-tcp#67  2  Active   1:38 
6/15/2022 10:48 AM


I can't find the above "IDLE TIME" anywhere in pywin32 "Python for 
Win32 Extensions".


I need this time value, and would rather keep all the code in python 
without having to resort to something like subprocess to encapsulate 
the Windows Query program.


This is part of Windows Terminal Services.  The API to fetch the idle 
time is undocumented and unsupported, but you can find the information here:


https://groups.google.com/g/microsoft.public.win32.programmer.kernel/c/xt2G599tJuQ?hl=en#91fc4e79a5d6c495

Because it is undocumented, it might be better to parse the output of 
"query user".


--
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] Package giving Error while deploying to windows container

2022-05-19 Thread Tim Roberts

On 5/19/22 05:40, Vernon D. Cole wrote:

Django also runs on Windows, and I have operated it there for testing 
purposes, but it is most at home in a Linux environment.
I have never (personally) run it in a container. I prefer the better 
performance and ease of use when installed directly on the server. 
Containers may deploy more quickly, but you pay a penalty for the rest 
of the life of the system.
I cannot imagine why one would want to run * anything * in a Windows 
container. That is adding complexity on top of difficulty.
My suggestion is to eliminate Windows from your thinking and run 
django directly on Linux.


However, this is not very good advice for an application that is 
invoking Microsoft Excel to do its 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] Package giving Error while deploying to windows container

2022-05-18 Thread Tim Roberts

Ankit Sharma wrote:
The issue with Pywin32 library is , it is getting deployed 
successfully to window container, However, once we try to use Export 
file function from the library , we get following error:

...
  File "C:\app\backend\manage_products\products.py", line 17751, in 
run_excel

    excel = win32.gencache.EnsureDispatch('Excel.Application')
...
Exception Value: (-2147221005, 'Invalid class string', None, None)


This is the log that we can not rectify even after updating our python 
version and changing container from Linux based environment to Windows 
Based environment.


Can you please help us out in figuring this issue out! or can help us 
in suggesting if we can deploy this package in a Linux container. 
Anything works.


You are trying to run the Excel application.  To do that, you have to 
have Excel installed on the machine where you're running. And, of 
course, nothing that uses Win32Com can ever work on Linux.


If you're trying to manipulate Excel files, there are many 
cross-platform libraries to do that.  If you really need to RUN Excel, 
then it has to be on Windows, and you have to have Excel installed.


--
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 win32com.shell to browse iphone photos | problem with pywebview

2022-05-11 Thread Tim Roberts

Bastian Schnitzler wrote:

I want to use win32com to transfer photos from my iphone to my
computer (I found a code snippet here, that worked for me:
https://gitlab.com/lassi.niemisto/iphone-photo-dump/).
In addition I would like to use pywebview to build a GUI.
...
It is the same, except that the folder for Apple iPhone is missing on
the second go.

Why is the shell behaving differently here? Is this a bug in win32com
or is pywebview influencing it somehow? What can I do to make it work?


Have you tried configuring your app to use a local web server? If you 
don't run your own server, then your pywebview app runs inside the 
browser's process, and that is a highly protected sandbox.  That's 
probably why you don't see external devices.


--
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] zmq under win32service

2022-03-08 Thread Tim Roberts

momc...@bojinov.info wrote:


server:

import zmq, json

context = zmq.Context()

socket = context.socket(zmq.REP)

socket.bind('ipc://cache/mm')

while True:

   message = socket.recv_json()

   print(message)

socket.send_json(json.dumps({"data" : "BLA BLA"}))

Once I start the service though I can’t send/receive content

Both service and cmd/client run under the same account (not SYSTEM)


Where is the service code?


I was wondering if I can even use while True without the spawning a 
separate thread for it ?


No.  Just like a Windows GUI app, a Windows service has a main message 
loop that has to remain in control, so it can receive and dispatch 
messages from the service manager.  The system sends "are you awake?" 
messages periodically to make sure you're still alive.  If you aren't 
getting back to the main loop, then you will be terminated.


So, if you're using the sample you mentioned, the service "def 
main(self):" will need to launch a thread to do your listening. You will 
also need to have your thread check the "stop_request" flag, so you can 
cleanly exit when the service is terminated.


--
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] WM_MOUSEWHEEL It only works in one window.

2022-02-16 Thread Tim Roberts

nakarin samon wrote:
>
> Is there any python that works like pywin32 SendMessage PostMessage. 
doesn't move the mouse?


There are a couple of problems here. SendMessage and PostMessage are not 
Python things.  Those are fundamental Win32 APIs.  pywin32 just gives 
you access to them. Second, those routines do not, of course, move the 
mouse.



> I want to move the mouse scroll or click the mouse without moving the 
mouse, I have used WM_MOUSEWHEEL. but not successful. It only works in 
one window. Will there
> be another one or it only works on the left side of the screen I 
tried moving the window to another section but it didn't work when I 
moved it back to the same place

> in the top left it works.

I can't tell what you're asking or what you're expecting, and your video 
no longer works.  Mouse messages are delivered to the window with 
focus.  Background windows do not get them unless they have captured the 
mouse.


So, please tells us what you are trying to achieve (not how you are 
trying to do it), and perhaps someone can advise 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] Run solidworks macro from python.

2022-02-15 Thread Tim Roberts

Sanaa Mouzahir wrote:


Apologies for the late reply, I had to go through a lot of 
documentation regarding SolidWorks itself. Unfortunately, the 
available documentation that I find is regarding creating a SW COM 
object, however, nothing about running a macro already written in 
SolidWorks VB. More specifically, when I look up 'swbindings.py' I do 
not get any output, and if I try to import it, I get the error message 
'no module named swbindings'.


Anything you can do from VBA can be done from Python, and it's usually a 
one-for-one translation.  Somewhere in the SolidWorks object model 
documentation, there has to be a command to run a named VBA script.  
That's what you need to find.  The key is that this is not Python 
related.  You're just controlling their COM server, so you need to find 
the right method in the right interface in their object model.


--
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] Run solidworks macro from python.

2022-02-10 Thread Tim Roberts
On Feb 10, 2022, at 9:39 AM, Sanaa Mouzahir  wrote:
> 
> Or maybe After importing the packages I can just use the same command as the 
> VBA? I know that for excel the function Application.run(macroname) works, but 
> not for solidworks..


Right, because every application defines their own object model.  There’s no 
“general rule” that applies to all COM servers.  You HAVE to go through the 
documentation for THAT product, or at least look at some examples.
— 
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] Run solidworks macro from python.

2022-02-10 Thread Tim Roberts

Sanaa Mouzahir wrote:
Hello. I have started a project in which I have to link both 
solidworks and python. I want to use Pywin32 to run a macro from 
python. here is my code:


app=win32com.client.Dispatch("SldWorks.Application")
app.OpenDoc("C:/Users/sm5126/Downloads/Python/Python/Part1.SLDPRT", 1)
app.Run("C:/Users/sm5126/Downloads/Python/Python/Part1.SLDPRT!ForceRebuild.swp")

I basically want to use the same run function as for excel. But it 
does not work. Is there a way to run a macro from python using Pywin32?


What do you mean by "it does not work"?  Do you get an error? Does it crash?

Have you read the documentation for the SolidWorks API?  As I read the 
documentation, the API for running a script is called RunScript, not Run.


--
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 with adodbapi

2022-01-23 Thread Tim Roberts
On 1/14/22 02:25, KANAGARAJAH, Sanch (UNIVERSITY COLLEGE LONDON 
HOSPITALS NHS FOUNDATION TRUST) via python-win32 wrote:




I am wondering if anyone is able to help me with the attached error? 
when I tried to connect to a SQL server with adodbapi using a Python 
script.



What kind of database were you connecting to?  The error is saying there 
was no driver for that database.  Note that if you are running a 64-bit 
Python, you must have a 64-bit ODBC driver for your database.



--
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] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-09 Thread Tim Roberts

Steven Manross wrote:

Correct me if I am wrong...  but Office 2010+ comes in 64-bit and 32-bit 
versions.  I know that 2019 definitely does.


Both are available, but until Office 2019 the 32-bit version was the 
default, so that's what virtually everyone has.




Providing he matches his Python architecture (32 or 64) to his Office 
application architecture (32 or 64), it should work unless that code has issues 
working in 64-bit mode?  I haven’t tried this myself in this particular case, 
as I've always installed 32-bit Office apps.


Right.



Its possible that my Office 2019 install doesn’t have the correct components or 
APPIDs or CLSIDs installed (even if I matched the python and office 
architectures) as I searched for them and couldn’t find them in the native x64 
and x86 registry subkeys:

* HKEY_CLASSES_ROOT
* HKLM\Software\Classes
* OR HKLM\Software\Wow6432Node\Classes


Is this the desktop versions or the Office 365 versions?  There are 
differences.


--
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] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-08 Thread Tim Roberts

Vernon D. Cole wrote:

Most likely, you are running a 64  bit version of Python.
Due to Windows restrictions, only 32 bit programs can talk to each other.


That comment demands clarification, because as stated it is quite 
misleading.


The issue here is that a 32-bit application can only load 32-bit DLLs.  
Outlook 2016 is a 32-bit application, so when it as a COM client tries 
to load an in-process COM server (that is, his add-in), the COM server 
DLL must also be 32-bit.


There are many, many ways that 32-bit and 64-bit programs can talk to 
each other.  This is a very specific instance.


--
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] Clipboard Documentation

2021-12-01 Thread Tim Roberts

On 11/30/21 7:04 AM, gw1500 via python-win32 wrote:



Thanks for the reply. I read about that but was hoping to use pywin32. 
I can see now the folly of that decision.


I have a working minimal test but am looking for something a bit more 
automated. I bring my app window to the top using pywin32 and a line I 
need is already highlighted. I can ctrl-c from the keyboard and 
pyperclip works just fine. However, since the line is already 
highlighted is there a way to get it without user interaction (ctrl-c)?


 I don't know how much trouble you want to go to.  If you can get the 
window handle of the text box that has your text, you can send a WM_COPY 
message to it.  With the standard controls, that tells it to do a "copy" 
operation with the currently selected text.


--
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] Clipboard Documentation

2021-11-29 Thread Tim Roberts

Dennis Putnam wrote:


I'm using pywin32 and it is my understanding it can also be used for 
copying text from an app to the clipboard. I have been able to find 
scant documentation for that. Can someone send me a link to some 
definitive documentation? TIA.


The easy way is to use the well-respected `pyperclip` module. You can 
install it with pip.  The Win32 clipboard APIs are a pain to work with, 
and of course don't work at all on other systems.


--
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] mail Sensitivity doesn't work as expected(can not set the sensitivity label)

2021-11-17 Thread Tim Roberts

Victor Liu wrote:



Gratitude to all the work of the library. I am trying to use it to 
send out some emails, but I have encountered this issue which might be 
a bug. It can be represented by this minimum working example.


It might perhaps be a bug, but it is not a bug in Python.  All you're 
doing is controlling the Outlook object model.




... mail.Sensitivity  =  1
mail.Send()

This works well expect the |mail.sensitivity =1| part, so it pops up a 
window to set the sensitivity label(Bear in mind, not all outlook has 
set up this restriction).
... 
<https://user-images.githubusercontent.com/7195126/141965903-30c23072-d41d-403a-a11c-69e6e98e9c60.png>

This makes the process is impossible to automate.

My understanding is |mail.sensitivity = 1| is for that Azure label. 
Please let me know if I missed something.


That is certainly not how it is defined.  MailItem.Sensitivity is an 
enumeration of type OISensitivity, where 0=normal, 1=personal, 
2=private, and 3=confidential.  Here's the doc page:


https://docs.microsoft.com/en-us/office/vba/api/outlook.olsensitivity

There is no additional meaning assigned to it.  It's possible your copy 
of Outlook might have additional add-ons that change this behavior, but 
there is nothing you can do about that with COM.


--
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 PythonCOM - Application.Run does not work for Access.Application

2021-09-17 Thread Tim Roberts

Christoph J. Dorner wrote:


I need to call Office / VBA applications form a running Python script.
While calling VBA from Python using Application.Run works with EXCEL, it
does not work with ACCESS. What I do:
I link to the Office application via the win32com.client dispatch
mechanism as usual and I can see the application object in the Python
debugger.
If I do an excelapp.Run('xxx") everything is fine.
If I do an accessapp.Run('xxx") it throws an error -2147352562 which
win32api.FormatMessage states is an issue with the number of parameters.
But that cannot be the case as the UDF has no parameter and I do not
pass any (additional) parameter.


Curious.  Both the Excel "Application.Run" and Access "Application.Run" 
methods are defined the same way, with 30 "optional" parameters.  Have 
you experimented with specifying a dummy parameter to see if that makes 
a difference?


Have you tried using "win32com.client.gencache.EnsureDispatch" instead 
of simple "Dispatch"?  That way, it generates and caches a wrapper 
file.  It might be possible to peek in the generated file to see if the 
wrappers look any different.


--
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, 'OpenEventLogW', 'Access is denied.')

2021-09-15 Thread Tim Roberts

Ruggero Paolo Basile wrote:



Good morning i'am try to connect to remote host and get the eventlog 
from windows , but in the


module i can't find a value for authentication.
Have you some news?

this is my error "pywintypes.error: (5, 'OpenEventLogW', 'Access is 
denied.')"



To do that operation, your username has to have permission on that 
remote machine.  Are you using a domain?  Are you logged in as a domain 
administrator?



This article talks about it, but since Windows security is a vast, dark, 
confusing, twisted mess, I'm not sure you'll be able to make it work.



https://docs.microsoft.com/en-us/archive/blogs/janelewis/giving-non-administrators-permission-to-read-event-logs-windows-2003-and-windows-2008


If you bring up the Event Viewer application ("eventvwr"), under Action, 
there's a "Connect to Another Computer" option.  Does that work 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] windows images on clipboard

2021-08-12 Thread Tim Roberts

Mriswithe wrote:


I was looking at making a little helper app for Windows that will take 
an image on your clipboard and ensure it is under 8MB for posting to 
discord, and if it isn't, use Pillow to resize it until it is the 
right size.


I can use Pillow's ImageGrab.grabclipboard() to get the image off the 
clipboard, but I am a little confused about writing it back. I have 
been back and forth between the pywin32 source and the windows docs 
for the windows C API, but I don't have any previous experience or 
context to know what some pieces are intended to do.


I found an example to write to it from StackOverflow 
(https://stackoverflow.com/questions/34322132/copy-image-to-clipboard 
<https://stackoverflow.com/questions/34322132/copy-image-to-clipboard>), 
but I was wanting to dig a little deeper to see what formats other 
than BMP I could use to put on the clipboard. My ignorance of C++ and 
the Windows APIs and hell the Python C API is really biting me here.


You can't.  You have to write it as a DIB (Device Independent Bitmap), 
which is the format in a .BMP file.


The Windows clipboard was designed in roughly 1986, before GIF, before 
JPEG and way, way before PNG.  The clipboard is designed for universal 
interchange, so it really does need to spec the lowest common 
denominator.  If they allowed PNGs, then all of the graphics application 
in the world would have to be modified to decode PNG data.


So, to make your app work, save the result as a BMP.


Is there a bit of an idiots example guide for how to say, put a PNG on 
the clipboard or a JPG? Some example code? There is a ton of useful 
info in the pywin32 repo, but I haven't found anything that has made 
this click for me.


There is no idiots guide, because it cannot be done.  Well, technically 
speaking you can put arbitrary binary data into the clipboard, but other 
graphics applications will not be able to read it.  When they look for 
image data, they look for format CF_DIB, and that means a .BMP.


--
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


Re: [python-win32] Using win32gui.FindWindow() results in black or white screen

2021-06-03 Thread Tim Roberts

CodingMan125 wrote:



Dear, List Members using the FindWindow function from win32gui to find 
the window handle of a certain window through window name to enable 
video capture of certain window results in a black screen. Although 
trying the same code without a window handle to default it to 
capturing the whole screen results in a successful video capture, the 
same code however results in a black or white screen when trying to 
capture a specific window with window handle. How can I solve this?


In general, you can't.  From your description and from the comments in 
the code, I'm assuming you're trying to capture some kind of multimedia 
stream -- a movie playback or a camera live view.  In that case, the 
video stream is not actually contained in the application window.  
Instead, the video is rendered in its native format (usually a YUV 
format) into an offscreen region. That offscreen region is then used as 
a texture surface which the GPU's 3D engine renders onto the visible 
screen.  The application window remains a solid color, which is used as 
a chromakey (like a "green screen") to allow menus to be easily drawn on 
top.


--
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] Does it support the 64-bit Excel

2021-04-23 Thread Tim Roberts

On 4/23/21 12:42 PM, Ben Hui wrote:



I am interested to know if python -win32, specifically, the version:

pywin32-300.win-amd64-py3.9.exe, at 
https://github.com/mhammond/pywin32/releases 
<https://github.com/mhammond/pywin32/releases>


1. Will it support Excel 64 bit.  The users have Windows 10 and Excel 
2016 both 64 bit?


The "amd64" in the name says "yes".  Excel is controlled through COM, 
and with a COM server, your Python bittedness must match the server 
bittedness.



2. Is there any documentation on the pywin32 library.  I cannot seem 
to locate it on Github repository.


Quite a lot.  Did you Google for it?  It's on the first page of 
results.  http://timgolden.me.uk/pywin32-docs/contents.html


--

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 1: incorrect function when starting service python

2021-03-30 Thread Tim Roberts

Shaik Saleem Basha wrote:

Issue:

1.I have created a python script for windows service, service is 
creating I can't able to run I'm getting the following error ( The 
pythonftp service terminated with the following service-specific 
error: Incorrect function.) in windows logs.


2.I'm able to run the service from windows services, only if I'm 
creating service from the environment this is also working only on my 
laptop the same I have tried on another laptop I'm getting the same error.


Are you sure the other laptop has the same version of Python, and the 
same version of all of the Python modules you require?  Are you sure 

that both systems have access to the D: drive?  If that's a file share, 
are you sure both laptops have permission to access it?  Remember that 
services, by default, run as the "local system" user, which does not 
have any of your network permissions.


When you run on the other laptop, do you get a traceback that tells you 
which line failed?  You should share that.




4.code link: https://cutt.ly/ux7XdnB <https://cutt.ly/ux7XdnB>

It is incredibly foolish of you to publish your actual FTP username and 
password in a public github repository.  You need to find another way to 
handle 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] win32com.client.WithEvents fails when running as a Windows service

2021-03-06 Thread Tim Roberts
On Mar 6, 2021, at 6:43 AM, Marius Cirsta  wrote:
> 
>  I'm trying to automate CANoe using win32com. I've written a script that 
> works perfectly when I log in and run it as a normal user.
> ...
> When being run as a service though I get this error:
> 
> Traceback (most recent call last):
>   File "D:\Jenkins\Scripts\dispatch.py", line 203, in 
> exec_test(PDConfigPath, "CommonTests", "PD_CSB")
>   File "D:\Jenkins\Scripts\dispatch.py", line 146, in exec_test
> win32com.client.WithEvents(csbTstMod, TestModuleEvents)
>   File "C:\Program 
> Files\Python39\lib\site-packages\win32com\client\__init__.py", line 336, in 
> WithEvents
> instance = result_class(disp) # This only calls the first base class 
> __init__.
>   File 
> "C:\WINDOWS\TEMP\gen_py\3.9\7F31DEB0-5BCC-11D3-8562-00105A3E017Bx0x1x58.py", 
> line 19507, in __init__
> cookie=cp.Advise(win32com.server.util.wrap(self, 
> usePolicy=EventHandlerPolicy))
> pywintypes.com_error: (-2147024891, 'Access is denied.', None, None)

Do you have your service configured to run as your user?  The normal service 
user has different access permissions, so it can’t access your file shares.
— 
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 When Reading In PSTs

2021-02-18 Thread Tim Roberts

Nick Orr wrote:


This seems to be the consensus from two others that I've heard back 
from. Unfortunately this is an issue for me (it's always that one same 
meta tag:  ) as it's being requested by the project to have the 
contents be identical to the email in Outlook. I just don't see any 
possible way to achieve this given that it's stripped and inferring it 
risks inaccuracy.


Do you know whether the message actually contained that line to begin 
with?  If this happens with messages you send, try sending one to a 
Linux mailbox somewhere, and take a look at the raw text.  It's also not 
impossible that Outlook adds line for export, but that it's not actually 
present in the message text.


Outlook takes liberties with message content that it probably shouldn't.

--
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] Bug When Reading In PSTs

2021-02-17 Thread Tim Roberts
On Feb 17, 2021, at 6:07 AM, Nick Orr  wrote:
> 
> I've been developing a Python tool to ingest and write all emails from a PST 
> exported from Outlook to individual .html files. The issue is that when 
> opening the PST in outlook and checking the source information for emails 
> individually, it includes this specific line:
> 
> 
> 
> which IS NOT being included when importing the PST with Pywin32 and reading 
> all the emails in the PST. To see what it looks like in a chunk - 

What you HAVEN’T said here is how you are talking to Outlook — how you 
generated your “outlook” object.  PyWin32 doesn’t have any code that is 
Outlook-specific.  I assume you’re using win32com.client.Dispatch.  If so, 
remember that Python isn’t doing any processing here.  It’s just passing 
requests through COM to Outlook.  If your text is coming back oddly, then 
Outlook is returning it oddly.

  tags are intended for web servers; it’s possible that Outlook is 
absorbing the  tag because it isn’t useful.  Maybe it has copied the 
charset to a property of the message object to reflect the character set.  That 
is, perhaps there’s something in the “item” object that gets tweaked.


> Because the emails otherwise are identical, I can only assume this is being 
> done by the library. I'm wondering if there's a reason that meta tag is 
> excluded, or if it's a bug in PyWin32?

No, it’s not being done by PyWin32.  It’s being done by Outlook.  You’d get the 
same result if you called this method from C#.
— 
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] Opening existing memory mapped files with pywin32

2021-02-16 Thread Tim Roberts
On Feb 16, 2021, at 5:49 PM, rhyslloyd1  wrote:
> 
> Thanks for the quick response! I've made some progress since reading. My goal 
> is to be able to talk to the NVIDIA Share API using Python. I found this 
> <https://github.com/cm-pony/Experienceless/issues/1#issuecomment-763496808> 
> post on GitHub the other day and I wanted to implement it myself. I've 
> obviously bitten off more than I could chew.

I was wrong.  What you have there is the name of a mapping object, not the name 
of a file.


> Also the "read_line" method doesn't exist apparently. This 
> <https://pastebin.com/JjrA4jEJ> is the output now.

Your snippet is private; we can’t read it.  No, “read_line” isn’t going to 
work.  This is not a file, it’s just a chunk of memory — a string of bytes.  
The implication from your link is that this is a JSON string.  If so, you 
should be able to read() the whole thing, do .decode(‘utf-8’) and pass the 
result to a JSON decoder.
— 
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] Opening existing memory mapped files with pywin32

2021-02-16 Thread Tim Roberts

Eryk Sun wrote:


I'm sorry to say that the only reliable solution is to directly call
WinAPI OpenFileMappingW() and MapViewOfFile() using a foreign-function
interface (FFI) package such as ctypes or CFFI. I can write up an
example if you need help.


Respectfully, I think you have misread the original message.  He is a 
relative beginner, just trying to do a simple file mapping. Based on his 
description, mmap should be able to do what he needs.


I'm willing to be proven wrong, but I'm afraid you may be sending him on 
an unnecessary wild goose chase.


--
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] Opening existing memory mapped files with pywin32

2021-02-16 Thread Tim Roberts

rhyslloyd1 via python-win32 wrote:


I am trying to open a memory mapped file using Python. I originally 
used the "mmap" module from Python however I had issues with it 
because I had to use a fixed size for the file even though my goal was 
to open an existing file of which the size would be unknown.


The file size isn't really "unknown".  It's just not known in advance.  
There are many ways to find the size of a file.  Plus, the "mmap" module 
accepts 0 as a size parameter, meaning "map the whole file".



I am now using the "mmapfile.mmapfile" function. My code looks like 
this <https://pastebin.com/QygT2wp6>. In the docs 
<http://timgolden.me.uk/pywin32-docs/mmapfile__mmapfile_meth.html> it 
says I can use a file name of "None" if I'm planning on opening an 
existing file. This <https://pastebin.com/2FVhpDiB> is the error I get 
when running my code.


There are a couple of misunderstanding here.  It is important to realize 
that the name of the mapping object is quite different from the name of 
the file being mapped.  The Windows memory-mapping concept is quite 
general, and is often used as a way to share memory between multiple 
processes.  In that case, you just want a chunk of memory without 
bothering with a file on disk.  In that case, you'd create a mapping 
object with a name, but no file name.


If you're just mapping an existing file, you need to supply the file 
name, but you don't need to supply a name for the mapping object.  The 
code you showed creates a shared memory object that does not map a file 
on disk.  The shared memory object has a name (the GUID), and another 
application could open that named object, but it doesn't map to a file.


If you want to open a mapping to an existing file, specify the name of 
the file as File= and specify Name=None.


However, you can do all of this with the mmap module as well.  If you 
have a file called "data.bin", you can do


    import mmap
    fn = open('data.bin','rb')
    data = mmap.mmap( fn.fileno(), 0, access=mmap.ACCESS_READ )

That maps the whole file, and len(data) will tell you how large it is.

--
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] DeviceIOControl calls respond with parameter incorrect

2021-02-08 Thread Tim Roberts
On Feb 8, 2021, at 8:23 PM, Doug Campbell  wrote:
> 
> In my python 2 script, I am trying to connect to the VeraCrypt device driver 
> to get some information on my mounted volumes.

There are a lot of things to go wrong here.  You may be in for a long slog.  
Your ctypes definition does look fundamentally correct.


> This is what I have so far.  I tried a bunch of different ideas on how to 
> construct the input buffer for the DeviceIoControl function call but I keep 
> getting the following response.
> 
> Traceback (most recent call last):
>   File "test.py", line 188, in 
> 
> info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,b'x05x00x00x00'
>  + (b'x00' * 702),65536)
> pywintypes.error: (87, 'DeviceIoControl', 'The parameter is incorrect.')

The last parameter is the size of the output buffer, and that does get passed 
to the driver.  It should be sizeof(VOLUME_PROPERTIES_STRUCT) which is, I 
believe, 1280.


> #info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,struct.pack('ii520sQLQQiii66sL64sL',prop),17424)

Last should be 1280, I think.

> info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,b'0x00' + 
> b'x05x00x00x00' + b'x00' * 702),65536)

The first b’0x00’ is wrong; the first byte of the struct needs to be 5.
— 
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] 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] 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] 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] 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] 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] 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] 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-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] 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] 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] 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] 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-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] [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 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] 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

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


> 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] 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] 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-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] 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-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] 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] 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] 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] 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] 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] 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:

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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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


  1   2   3   4   5   6   7   8   9   10   >