简体   繁体   中英

how to register a 64bit python COM server

ahk code: ComObjCreate("{C2474B5A-5E9D-484D-BDFD-20A100183426}")

this works in AutoHotkeyU32.exe, but not in AutoHotkeyU64.exe
error message is: the specified module could not be found.

full code is here: How to program hotstrings in python like in autohotkey


I call my SymPy functions using ahk hotkeys. I register the python script as a COM server using pywin32 and load it using ahk.

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)

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

  1. register it correctly as shown here How to program hotstrings in python like in autohotkey :
    do NOT use UseCommandLine() , use RegisterServer(clsctx=pythoncom.CLSCTX_LOCAL_SERVER, ...)
  2. after server has been registed using UseCommandLine() , delete the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{C70F3BF7-2947-4F87-B31E-9F5B8B13D24F}\PythonCOMPath\InprocServer32

    replace {C70F3BF7-2947-4F87-B31E-9F5B8B13D24F} with your own CLSID

(I think) there is no need for
key: InprocServer32 :
Name : (Default)
Type : REG_EXPAND_SZ
Data : pythoncom39.dll ,
also, requiring it makes it fail

(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 is the one doing the COM stuff, to prove it, replace pythonw with python . you will the window when it's ran.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM