如何注册一个64位的python COM服务器 [英] how to register a 64bit python COM server
问题描述
ahk 代码:ComObjCreate("{C2474B5A-5E9D-484D-BDFD-20A100183426}")
这适用于 AutoHotkeyU32.exe,但不适用于 AutoHotkeyU64.exe
错误信息是:找不到指定的模块.
this works in AutoHotkeyU32.exe, but not in AutoHotkeyU64.exe
error message is: the specified module could not be found.
完整代码在这里:如何在 python 中编程热字符串,就像在 autohotkey 中一样
推荐答案
你需要 pywin32,但不要使用 pip install pywin32
从 https://github.com/mhammond/pywin32/releases
下载否则它不适用于 AutoHotkeyU64.exe,它仅适用于 AutoHotkeyU32.exe.
一定要下载amd64,(我下载的是pywin32-300.win-amd64-py3.8.exe)
you'll need pywin32, but don't download using pip install pywin32
download from https://github.com/mhammond/pywin32/releases
OR ELSE IT WON'T WORK for AutoHotkeyU64.exe, it will only work for AutoHotkeyU32.exe.
make sure to download amd64, (I downloaded pywin32-300.win-amd64-py3.8.exe)
现在我明白为什么它不起作用
如果您正确注册,我认为它可以在使用 pip install pywin32
时工作.
你有两个选择:
now I understand why it didn't work
I think it CAN work when using pip install pywin32
if you register it correctly.
you have 2 choices:
- 按此处所示正确注册如何像在自动热键中一样在 python 中编程热字符串 :
不要使用UseCommandLine()
,使用RegisterServer(clsctx=pythoncom.CLSCTX_LOCAL_SERVER, ...)
- 使用
UseCommandLine()
注册服务器后,删除注册表项HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{C70F3BF7-2947-4F87-B31E-9F5B8B13D24F}\PythonCOMPath\Inproc
将{C70F3BF7-2947-4F87-B31E-9F5B8B13D24F}
替换为您自己的CLSID
- register it correctly as shown here How to program hotstrings in python like in autohotkey :
do NOT useUseCommandLine()
, useRegisterServer(clsctx=pythoncom.CLSCTX_LOCAL_SERVER, ...)
- after server has been registed using
UseCommandLine()
, delete the registry keyHKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{C70F3BF7-2947-4F87-B31E-9F5B8B13D24F}\PythonCOMPath\InprocServer32
replace{C70F3BF7-2947-4F87-B31E-9F5B8B13D24F}
with your ownCLSID
(我认为)没有必要
键:InprocServer32
:名称
: (默认)
类型
:REG_EXPAND_SZ
数据
: pythoncom39.dll
,
另外,要求它会失败
(I think) there is no need for
key: InprocServer32
:
Name
: (Default)
Type
: REG_EXPAND_SZ
Data
: pythoncom39.dll
,
also, requiring it makes it fail
(我认为)没有必要,因为它实际上使用了 LocalServer32(这也是一个键)
我的是:名称
: (默认)
类型
: REG_SZ
Data
: C:\PROGRA~3\Miniconda3\pythonw.exe "C:\ProgramData\Miniconda3\lib\site-packages\win32com\server\localserver.py";{C70F3BF7-2947-4F87-B31E-9F5B8B13D24F}
(I think) There's no need because it actually uses LocalServer32 (which is also a key)
mine is:
Name
: (Default)
Type
: REG_SZ
Data
: C:\PROGRA~3\Miniconda3\pythonw.exe "C:\ProgramData\Miniconda3\lib\site-packages\win32com\server\localserver.py" {C70F3BF7-2947-4F87-B31E-9F5B8B13D24F}
localserver.py
是一个做 COM 的东西,为了证明这一点,用 python
替换 pythonw
.运行时,您将看到窗口.
localserver.py
is the one doing the COM stuff, to prove it, replace pythonw
with python
. you will the window when it's ran.
这篇关于如何注册一个64位的python COM服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!