Zu Python unter Windows
- Zum Zugriff via com siehe auch:
- >724241 Installation von Bibliotheken und Bibliotheken für Python
- UTF-8-Ausgabe auf die Konsole
__import__( "sys" ).stdout.buffer.write( chr( 0x231E ).encode( 'utf-8' ))
- main.py
import os
with open( 'tmp.cmd', 'w' ) as file:
print \
( \
# program
r'ECHO '
# example
r'EXAMPLE '
, file=file, flush=True )
print( 'PAUSE', file=file, flush=True )
os.system("C:\Windows\System32\cmd.exe /k tmp.cmd")
input()
- Ausführbare Datei
C:\Users\Hans\AppData\Local\Programs\Python\Python37\python.exe
- Arbeitsordner
C:\Users\Hans\AppData\Local\Programs\Python\Python37\example.py
- lokaler Ordner
C:\Users\Hans\AppData\Roaming\Python\Python37\site-packages\usercustomize.py
- Registrierungsauszug
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.py]
@="Python.File"
"Content Type"="text/plain"
- Registrierungsauszug
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Python.File]
@="Python File"
[HKEY_CLASSES_ROOT\Python.File\DefaultIcon]
@="\"C:\\Windows\\py.exe\",1"
[HKEY_CLASSES_ROOT\Python.File\Shell]
[HKEY_CLASSES_ROOT\Python.File\Shell\open]
[HKEY_CLASSES_ROOT\Python.File\Shell\open\command]
@="\"C:\\Windows\\py.exe\" \"%L\" %*"
[HKEY_CLASSES_ROOT\Python.File\Shell\Edit with IDLE]
[HKEY_CLASSES_ROOT\Python.File\Shell\Edit with IDLE\command]
@="\"C:\\Users\\s\\AppData\\Local\\Programs\\Python\\Python37\\pythonw.exe\" -m idlelib \"%L\" %*"
- Appdata
import pythoncom
from win32com.shell import shell
kfmgr = pythoncom.CoCreateInstance(
shell.CLSID_KnownFolderManager, None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IKnownFolderManager)
appdata = kfmgr.GetFolder(shell.FOLDERID_RoamingAppData)
appdata_path = appdata.GetPath()
IKnownFolderManager interface:
https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iknownfoldermanager
IKnownFolder interface:
https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iknownfolder
main.py
import win32com.client
from time import sleep
xl = win32com.client.Dispatch("Excel.Application")
xl.Visible = True
sleep( 1 )
- Unterprozesse
subprocess.Popen(['start', 'hello.txt'], shell=True)
subprocess.check_call( [ sys.executable, 'hello.py'])
- Exe (geht nicht mit 3.8?)
pip install pyinstaller
Scripts/pyinstaller -–onefile -–windowed --icon="images\myicon.ico" myApp.py
.exe now is in dist
https://nsis.sourceforge.io/Download
create zip w/ exe and use NSIS
Problemratgeber
- Mehrfache Excel-Prozesse
- Falls mehrere voneinander unabhängige Excel-Prozesse parallel laufen (und nicht nur mehrere Hauptfenster), sind Zugriffe auf »Excel.Cells« eventuell nicht möglich (Fehler-Code -2146827284)