Ich hab nach den Hinweisen/Diskussion folgende Lösung gefunden.
Dazu hab ich den Code von "PureLust" benutzt um nur eine Programminstanz zu erlauben, egal wie viele PB IDE's geöffnet sind.
Und in der WinAPI Library habe ich den Code unter "Prozesse/Alle offene Anwendungen anzeigen" gefunden und angepasst.
Somit wird das Programm beendet wenn alle IDE's geschlossen sind.
Somit benötige ich nur ein Werkzeugeintrag beim IDE-Start.
Bei mir hat das Programm in Ruhe 0,07% CPU-Zeit und in Aktion, je nach Mausaktivitäten, kurzzeitig bis zu 2,9% (1,3% im Durchschnitt). Und das ist für mich akzeptabel.
Code: Alles auswählen
Global g_hMutexAppRunning
Global xx.b = 0
;<comment>
; <summary> AppInstanceExists() : Ermittelt ob ein Programm schon gestartet ist<br>; Autor: PureLust </summary>
; http://www.purebasic.fr/german/viewtopic.php?p=260173#p260173
; <param> AppInstanceExists() </param>
; <return> () </return>
; < example> AppInstanceExist() </example>
;</comment>
Procedure AppInstanceExists()
Protected bAppRunning = #False
g_hMutexAppRunning = CreateMutex_( #Null, #Null, "Global\MyApplication1")
If (g_hMutexAppRunning <> #Null) And (GetLastError_() = #ERROR_ALREADY_EXISTS)
CloseHandle_( g_hMutexAppRunning )
g_hMutexAppRunning = #Null
EndIf
If g_hMutexAppRunning
ProcedureReturn #False
Else
ProcedureReturn #True
EndIf
EndProcedure
;********************************************************************
; der erste Aufruf vor alle anderen Programmschritte
;
If AppInstanceExists()
MessageRequester("", "Die Anwendung läuft bereits."+Chr(13)+"Die zweite Instanz wird beendet.",#MB_ICONERROR)
CloseHandle_(g_hMutexAppRunning)
End
EndIf
;********************************************************************
;<comment>
; <summary> ListWindows(hwnd,Param) : Alle offene Anwendungen anzeigen (WinAPI Library) </summary>
; <return> #True/#False </return>
; < example> EnumChildWindows_(FindWindow_("ToolbarWindow32",#Null),@ListWindows(),0) </example>
;</comment>
; And GetWindowLongPtr_(hwnd,#GWL_STYLE) & #WS_VISIBLE kann weggelassen werden; erfasst dann alle
Procedure ListWindows(hwnd,Param)
If GetWindowLongPtr_(hwnd,#GWL_EXSTYLE) ! #WS_EX_TOOLWINDOW And GetWindowLongPtr_(hwnd,#GWL_STYLE) & #WS_VISIBLE
String$ = Space(250)
GetWindowText_(hwnd,String$,250)
If Not String$=""
If FindString(String$,"PureBasic",1,#PB_String_NoCase)
xx+1
EndIf
EndIf
EndIf
ProcedureReturn #True
EndProcedure
;********************************************************************
; in der Ereignisschleife
Repeat
.......
xx = 0
EnumChildWindows_(FindWindow_("ToolbarWindow32",#Null),@ListWindows(),0)
If xx = 0
quitForm1 = 1
EndIf
Until quitForm1
Tips und Hinweise willkommen