Ich vermute mal, dass ihr ebenfalls portable Programme in einem Ordner führt und von dort per Verknüpfung / Hotkey / Menü die Programme aufruft.
Ich habe mir jetzt eine GUI mit Übersicht über alle Programmordner erstellt. Beim Auswählen eines Ordners werden die enthaltenen EXE-Dateien aufgelistet. Beim Klick auf diese schließt die GUI und startet die EXE.
Um jetzt nicht händisch aktiv werden zu müssen, wenn ich Programme hinzufüge oder entferne, habe ich eine INI-Datei, die automatisiert erstellt wird und aus der die GUI die Daten zieht. Bei Änderungen einfach die makeINI neu aufrufen und die INI wird neu erstellt.
Nun brauch ich nur noch einen Hotkey zum Einblenden der GUI.
AutoIt: makeINI.au3
;-- TIME_STAMP 2023-01-16 13:32:45
#cs
Automatisiertes Erstellen einer INI mit folgenden Daten
- INI-Name: "NAME_vom_RootOrdner.ini"
- Struktur im RootOrdner: OrdnerName\*.exe (mehrere EXE möglich)
- für jeden Ordner wird eine Sektion erstellt: "OrdnerName"
- in jeder Sektion werden die Schlüssel:
"path"=kpl. Ordnerpfad
"run"=file1.exe|file2.exe|...
angelegt
Sollten neue Ordner hinzugefügt worden sein - Programm erneut ausführen, alte INI wird gelöscht.
#ce
#include <File.au3>
#include <Array.au3>
_Scan()
Func _Scan()
Local $INI = @ScriptDir & '\' & StringTrimLeft(@ScriptDir, StringInStr(@ScriptDir, '\', 0, -1)) & '.ini'
If FileExists($INI) Then FileDelete($INI)
Local $aFolder = _FileListToArray(@ScriptDir, '*', 2, True)
If Not @error Then
For $i = 1 To $aFolder[0]
_CreateSection($INI, $aFolder[$i])
Next
EndIf
EndFunc
Func _CreateSection($INI, $_sPath)
Local $aEXE = _FileListToArray($_sPath, '*.exe', 1)
If Not @error Then
Local $sSection = StringTrimLeft($_sPath, StringInStr($_sPath, '\', 0, -1))
IniWrite($INI, $sSection, 'path', $_sPath)
IniWrite($INI, $sSection, 'run', _ArrayToString($aEXE, '|', 1))
EndIf
EndFunc
Alles anzeigen
AutoIt: PortableRun.au3
;-- TIME_STAMP 2023-01-16 13:36:42
#cs
Nutzt INI, die mit "makeINI.au3" erstellt wurde
#ce
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <WinAPIIcons.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>
Global $mSections, $hGui, $cListProg, $hLVRun, $hImage
_CreateGUI()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW, $hGui)
While True
Switch GUIGetMsg()
Case -3
_GUIImageList_Destroy($hImage)
Exit
Case $cListProg
_LV_AddItemWithImage()
EndSwitch
WEnd
Func _CreateGUI()
Local $aAll = _INIReadAllSections()
$mSections = $aAll[1]
$hGui = GUICreate('Portable', 320, 595, @DesktopWidth-330, 10)
GUICtrlCreateLabel('Programm Ordner', 10, 15)
$cListProg = GUICtrlCreateList('', 10, 35, 300, 450, BitOR(0x00800000,0x00200000)) ; ($WS_BORDER,$WS_VSCROLL)
GUICtrlSetData($cListProg, $aAll[0])
_GUICtrlListBox_SetCurSel(GUICtrlGetHandle($cListProg), 0)
Local $cLVRun = GuiCtrlCreateListView('Ausführen', 10, 495, 300, 90)
$hLVRun = GUICtrlGetHandle($cLVRun)
_GUICtrlListView_SetColumnWidth($hLVRun, 0, $LVSCW_AUTOSIZE_USEHEADER )
_LV_AddItemWithImage()
EndFunc
Func _INIReadAllSections()
Local $INI = @ScriptDir & '\' & StringTrimLeft(@ScriptDir, StringInStr(@ScriptDir, '\', 0, -1)) & '.ini'
Local $aSections = IniReadSectionNames($INI)
Local $map[]
For $i = 1 To $aSections[0]
$map[$aSections[$i]] = _newMap()
$map[$aSections[$i]]['path'] = IniRead($INI, $aSections[$i], 'path', '')
$map[$aSections[$i]]['run'] = IniRead($INI, $aSections[$i], 'run', '')
Next
Local $aRet[] = [_ArrayToString($aSections, '|', 1), $map]
Return $aRet
EndFunc
Func _newMap()
Local $m[]
Return $m
EndFunc
Func _LV_AddItemWithImage()
_GUICtrlListView_DeleteAllItems($hLVRun)
_GUIImageList_Destroy($hImage)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
Local $aExe = StringSplit($mSections[GUICtrlRead($cListProg)]['run'], '|')
Local $sPath = $mSections[GUICtrlRead($cListProg)]['path']
Local $aIconSmall
For $i = 1 To $aExe[0]
If _WinAPI_ExtractIconEx($sPath & '\' & $aExe[$i], -1, 0, $aIconSmall, 0) = 0 Then
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 98) ; add default
Else
_GUIImageList_AddIcon($hImage, $sPath & '\' & $aExe[$i])
EndIf
Next
_GUICtrlListView_SetImageList($hLVRun, $hImage, 1)
For $i = 1 To $aExe[0]
_GUICtrlListView_AddItem($hLVRun, $aExe[$i], $i-1)
Next
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
If HWnd($tNMHDR.hWndFrom) = $hLVRun Then
If $tNMHDR.Code = $NM_CLICK Then
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $sItem = _GUICtrlListView_GetItemText($hLVRun, $tInfo.Index)
Exit ShellExecute($mSections[GUICtrlRead($cListProg)]['path'] & '\' & $sItem)
EndIf
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Alles anzeigen