I know this gets asks occasionally: “How do I import win32api?”. Well you can’t…at least not out of the box. This is where Pywin32 comes in. I recently started throwing together a plugin that needed pywin32 so I could show Windows notification bubbles from sublime:
So I threw this together.
example to show path of all open explorer windows:
[pre=#232628]import sublime_plugin
import Pywin32.setup
from win32com.client.gencache import EnsureDispatch
def run():
for w in EnsureDispatch(“Shell.Application”).Windows():
print(w.LocationName + “=” + w.LocationURL)
run()[/pre]
Output:
User=file:///C:/Users/facelessuser/AppData/Roaming/Sublime%20Text%203/Packages/User
A Test Plugin=file:///C:/Users/facelessuser/AppData/Roaming/Sublime%20Text%203/Packages/A%20Test%20Plugin
Downloads=file:///C:/Users/facelessuser/Downloads
Notice, you just need to call import Pywin32.setup once before your plugin accesses any win32api, win32com, etc. calls. Technically it only needs to be called once when Sublime starts, but there is no guarantee your plugin will start after Pywin32 gets loaded. That is why your plugin just needs to make sure by manually including it.
-
This is only for ST3
-
Not everything may work. I have only tested what I needed to use.
Good luck! And I am not responsible if something breaks .