ein Skript, das niemand wriklich benötigt, aber ich hatte gerade etwas Langeweile.
Das Skript startet (ggf. Pfade anpassen) die Loxone-Konfiguration-Software mit der zuletzt gespeicherten Konfigdatei (aus einem angegebenen Ordner) und klickt die StartPopUps weg.
Des Weiteren läuft es so lange im Hintergrund mit, bis die Instanz der Loxone-Konfig-Software geschlossen wird und klickt weiterhin die nervigen PopUps weg, wenn z.B. eine andere Konfig geladen wird.
Sprache ist Autoit.
Zuverlässigere Variante mit Handles:
#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <Date.au3> #include <Array.au3> Opt('WinSearchChildren', 1) ;0=no, 1=search children also Opt('WinTextMatchMode', 1) ;1=complete, 2=quick Opt('WinTitleMatchMode', 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Global $title1 = 'Loxone Config' Global $title2 = 'Projekt Analyse' Global $path_ConfigFiles = @UserProfileDir & '\Documents\Loxone\Loxone Config\Projects\' Global $path_loxone = @ProgramFilesDir & '\Loxone\LoxoneConfig\LoxoneConfig.exe' Global $configFile = getLatestConfigFile($path_ConfigFiles) Global $pid_LoxoneConfig = _startLoxoneConfig() Global $win_A = 0 _main() Exit(0) Func _main() Do _closeAnnoyingPopUps() Sleep(250) Until Not ProcessExists($pid_LoxoneConfig) ConsoleWrite(_NowCalc() & 'Konfiguration wurde geschlossen!' & @CRLF) Return 1 EndFunc ;==>_main Func _closeAnnoyingPopUps() $win_A = _ProcessGetWin($pid_LoxoneConfig) ;~ _ArrayDisplay($r) For $i = 0 To UBound($win_A) - 1 If $win_A[$i][0] = 'Loxone Config' And WinActive($win_A[$i][1]) Then ControlSend($win_A[$i][1], '', '', '{ESC}') If $win_A[$i][0] = 'Projekt Analyse' And WinActive($win_A[$i][1]) Then ControlSend($win_A[$i][1], '', '', '{ESC}') Next EndFunc ;==>_closeAnnoyingPopUps Func _startLoxoneConfig() Local $pid = ShellExecute($path_loxone, '"' & $path_ConfigFiles & '\' & $configFile & '"') _closeAnnoyingPopUps() ConsoleWrite(_NowCalc() & ' : Gestartet: ' & $path_loxone & ' "' & $path_ConfigFiles & '\' & $configFile & '"' & @CRLF) Return $pid EndFunc ;==>_startLoxoneConfig Func getLatestConfigFile($path_ConfigFiles) Local $aFileList = _FileListToArray($path_ConfigFiles, '*.Loxone', $FLTA_FILES, False) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, '', 'Path was invalid.') Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, '', 'No file(s) were found.') Exit EndIf Local $re_A[UBound($aFileList)][2] For $i = 1 To UBound($re_A) - 1 $re_A[$i][0] = $aFileList[$i] $re_A[$i][1] = FileGetTime($path_ConfigFiles & '\' & $aFileList[$i], $FT_MODIFIED, $FT_STRING) Next _ArraySort($re_A, 1, 0, 0, 1) ;~ _ArrayDisplay($re_A) If IsArray($re_A) Then Return $re_A[0][0] Return -1 EndFunc ;==>getLatestConfigFile Func _ProcessGetWin($iPID = 0, $iOption = -1) Local $aList = WinList(), $aTemp If Not $iPID Then $iPID = @AutoItPID $iPID = ProcessExists($iPID) If $iPID = 0 Then Return SetError(1) Switch $iOption Case 0, 1 Local $aHWnd[1] = [0] For $i = 1 To $aList[0][0] If $iPID = WinGetProcess($aList[$i][1]) Then ReDim $aHWnd[$aHWnd[0] + 2] $aHWnd[0] += 1 $aHWnd[$aHWnd[0]] = $aList[$i][$iOption] EndIf Next Case 2 Local $aHWnd[1] = [0] For $i = 1 To $aList[0][0] If $iPID = WinGetProcess($aList[$i][1]) Then ReDim $aHWnd[$aHWnd[0] + 2] $aHWnd[0] += 1 $aTemp = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $aList[$i][1], "wstr", "", "int", 4096) $aHWnd[$aHWnd[0]] = $aTemp[2] EndIf Next Case Else Local $aHWnd[1][3] = [[0]] For $i = 1 To $aList[0][0] If $iPID = WinGetProcess($aList[$i][1]) Then ReDim $aHWnd[$aHWnd[0][0] + 2][3] $aHWnd[0][0] += 1 $aHWnd[$aHWnd[0][0]][0] = $aList[$i][0] $aHWnd[$aHWnd[0][0]][1] = $aList[$i][1] $aTemp = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $aList[$i][1], "wstr", "", "int", 4096) $aHWnd[$aHWnd[0][0]][2] = $aTemp[2] EndIf Next EndSwitch Return $aHWnd EndFunc ;==>_ProcessGetWin
#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <Array.au3> Opt('WinSearchChildren', 1) ;0=no, 1=search children also Opt('WinTextMatchMode', 1) ;1=complete, 2=quick Opt('WinTitleMatchMode', 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Local $title1 = 'Loxone Config' Local $title2 = 'Projekt Analyse' Local $path_ConfigFiles = @UserProfileDir & '\Documents\Loxone\Loxone Config\Projects\' Local $path_loxone = @ProgramFilesDir & '\Loxone\LoxoneConfig\LoxoneConfig.exe' Local $configFile = getLatestConfigFile($path_ConfigFiles) Local $pid_LoxoneConfig = _startLoxoneConfig() Do _closeAnnoyingPopUps() Sleep(250) Until Not ProcessExists($pid_LoxoneConfig) Func _closeAnnoyingPopUps() If WinExists($title1) And WinActive($title1) Then WinActivate($title1) ;~ ConsoleWrite($title1 & ' gefunden!' & @CRLF) Send('{ESC}') EndIf If WinExists($title2) And WinActive($title2) Then WinActivate($title2) ;~ ConsoleWrite($title2 & ' gefunden!' & @CRLF) Send('{ESC}') EndIf EndFunc ;==>_closeAnnoyingPopUps Func _startLoxoneConfig() Local $pid = ShellExecute($path_loxone, '"' & $path_ConfigFiles & '\' & $configFile & '"') Local $hTitle1 = WinWaitActive($title1, '', 10) WinActivate($hTitle1) Send('{ESC}') Local $hTitle2 = WinWaitActive($title2, '', 3) WinActivate($hTitle2) Send('{ESC}') ConsoleWrite('Gestartet: ' & $path_loxone & ' "' & $path_ConfigFiles & '\' & $configFile & '"' & @CRLF) Return $pid EndFunc ;==>_startLoxoneConfig Func getLatestConfigFile($path_ConfigFiles) Local $aFileList = _FileListToArray($path_ConfigFiles, '*.Loxone', $FLTA_FILES, False) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, '', 'Path was invalid.') Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, '', 'No file(s) were found.') Exit EndIf Local $re_A[UBound($aFileList)][2] For $i = 1 To UBound($re_A) - 1 $re_A[$i][0] = $aFileList[$i] $re_A[$i][1] = FileGetTime($path_ConfigFiles & '\' & $aFileList[$i], $FT_MODIFIED, $FT_STRING) Next _ArraySort($re_A, 1, 0, 0, 1) ;~ _ArrayDisplay($re_A) If IsArray($re_A) Then Return $re_A[0][0] Return -1 EndFunc ;==>getLatestConfigFile
Kommentar