1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Moombas

Beiträge von Moombas

  • Kleine PS Sammlung durch Migration

    • Moombas
    • 19. Januar 2026 um 07:57

    Kein Ding, den API Bereich werde ich ggf. noch erweitern auf Lancom Management Cloud, wie gesagt alles sehr speziell bei mir.

    Aber ggf. hilft das dem ein oder anderem. Und ja die integrierte Co-Pilot Vervollständigung hat doch das ein oder andere Mal geholfen aber auch oft zu Verwirrung und tlw. Überforderung ("zu Viel Code auf einen Schlag ergänzt/vorgeschlagen") gesorgt.

  • Kleine PS Sammlung durch Migration

    • Moombas
    • 16. Januar 2026 um 12:55

    Moin,

    da das Thema so ein bisschen durch mich aufgeploppt ist, wollte ich ein paar Powershell Funktionen, die ich mir beim Migrieren von AutoIt zu PS geschrieben habe teilen.
    Vielleicht hilft dies anderen, egal ob fürs Migrieren oder weil er/sie einfach das für PS sucht.

    Achtung: Es sind auch ein paar sehr spezielle API Funktionen für Soti Mobicontrol dabei.

    PowerShell
    $Logfile = ".\Output_$((Get-Date).ToString("yyyy-MM-dd_HH-mm-ss")).log"
    
    Function LogWrite{
        Param (
            [string]$logstring,
            [string]$Type = 'INFO',
            [bool]$Debug = $false
        )
        If ($Debug) {
            Write-Host "$Type`: $logstring"
        }
        Add-content $Logfile -value "$((Get-Date).ToString("yyyy-MM-dd_HH-mm-ss")) - $Type - $logstring"
    }
    
    Function SendMail {
        Param (
            [string]$Path,
            [string]$To,
            [string]$CC,
            [string]$Subject,
            [string]$Body,
            [string]$Attachments = '',
            [bool]$Debug = $false
        )
        Set-Variable olMailItem -option Constant -value 0 -ErrorAction Ignore
        Set-Variable olFormatHTML -option Constant -value 2 -ErrorAction Ignore
    
        If ($Debug) { LogWrite "$Path - Sending mail to: $To, CC: $CC, Subject: $Subject, Body: $Body, Attachments: $Attachments" 'DEBUG' $Debug }
    
        $outlook = New-Object -ComObject Outlook.Application
        $mail = $outlook.CreateItem($olMailItem)
        $mail.To = $To
        $mail.CC = $CC
        $mail.Subject = $Subject
        $mail.BodyFormat = $olFormatHTML 
        $mail.HTMLBody = $Body
        $mail.Attachments.Add($Attachments)
        $Result = $mail.Send()
    
        [System.Runtime.Interopservices.Marshal]::ReleaseComObject($mail) | Out-Null
        [System.Runtime.Interopservices.Marshal]::ReleaseComObject($outlook) | Out-Null
        return $Result
    }
    
    Function EncodeStatusCode { #returns true/false based on the response code
        param (
            [string]$ResponseValue,
            [bool]$Debug = $false
        )
    	Switch ($ResponseValue) {
            '200'   { 
                        if ($Debug) { LogWrite "EncodeStatusCode - Data retrieved successfully" 'INFO' $false }
                        Return $true 
                    }
            '204'   { 
                        if ($Debug) { LogWrite "EncodeStatusCode - Data permitted successfully" 'INFO' $false }
                        Return $true 
                    }
            '400'   { 
                        if ($Debug) { LogWrite "EncodeStatusCode - Contract validation error" 'ERROR' $false }
                        Return $false 
                    }
            '401'   { 
                        if ($Debug) { LogWrite "EncodeStatusCode - Authentication error" 'ERROR' $false }
                        Return $false 
                    }
            '403'   { 
                        if ($Debug) { LogWrite "EncodeStatusCode - No user permission to read the data" 'ERROR' $false }
                        Return $false 
                    }
            '422'   { 
                        if ($Debug) { LogWrite "EncodeStatusCode - Logic error" 'ERROR' $false }
                        Return $false 
                    }
            '500'   { 
                        if ($Debug) { LogWrite "EncodeStatusCode - Internal Server Error" 'ERROR' $false }
                        Return $false 
                    }
            Default {
                        if ($Debug) { LogWrite "EncodeStatusCode - Unknown error: $ResponseValue" 'ERROR' $false }
                        Return $false 
                    }
        }
    }
    
    # MobiControl API
    # https://servername/MobiControl/api/token
    function SendTokenRequest { #returns an access token
        param (
            [string]$Target, 
            [string]$Method, 
            [string]$Request, 
            $OptionalData = $null, 
            [bool]$Debug = $false
        ) 
        $Url = "https://$Target$Request"
        $Authorization = ConvertIntoBase64("$ID`:$Secret")
    
        $headers = @{
            Authorization = "Basic $Authorization"
        }
        
        If ($Debug -eq $true) {
            LogWrite "$Target - URL: $Url" 'DEBUG' $Debug
            LogWrite "$Target - Headers: $($headers | Out-String)" 'DEBUG' $Debug
            LogWrite "$Target - Data: $OptionalData" 'DEBUG' $Debug
        }
    
        $response = Invoke-WebRequest -Uri $Url -Method $Method -Headers $headers -ContentType 'application/x-www-form-urlencoded' -Body $OptionalData
        $response = $response | Select-String -Pattern '"access_token":"([^"]+)"' -CaseSensitive -AllMatches
        return $response.Matches.Groups[1].Value
    }
    
    # https://servername/MobiControl/api/...
    function SendRequest {
        param (
            [string]$Target, 
            [string]$Method, 
            [string]$Request, 
            [string]$ContentType = 'application/json',
            [string]$ReturnType = 'Content',
            $OptionalData = $null, 
            [bool]$Debug = $false
        ) 
        $Url = "https://$Target$Request"
        
        $headers = @{
            Accept = $ContentType
            Authorization = "Bearer $accessToken"
        }
    
        If ($Debug -eq $true) {
            LogWrite "$Target - URL: $Url" 'DEBUG' $Debug
            LogWrite "$Target - Headers: $($headers | Out-String)" 'DEBUG' $Debug
        }
        
        if ($null -eq $OptionalData) {
            $response = Invoke-WebRequest -Uri $Url -Method $Method -Headers $headers -ContentType $ContentType
        } else {
            If ($Debug -eq $true) { LogWrite "$Target - Data: $OptionalData" 'DEBUG' $Debug}
            $response = Invoke-WebRequest -Uri $Url -Method $Method -Headers $headers -ContentType $ContentType -Body $OptionalData
        }
        if ($Debug -eq $true) { 
            LogWrite "$Target - Response StatusCode: $($response.StatusCode)" 'DEBUG' $Debug
            LogWrite "$Target - Response Content: $($response.$ReturnType)" 'DEBUG' $Debug
        }
        return $response.$ReturnType
    }
    
    # https://servername/MobiControl/api/customattributes
    Function GetCustomAttributes{ #returns an array of all custom attributes with their names and IDs: Name | ID
        param (
            [bool]$Debug = $false
        )
        $Attributes = @(,0)
    
    	$Return = SendRequest $API 'GET' "/MobiControl/api/customattributes" 'application/json' 'Content' $null $false
        If ($Debug) { LogWrite "$Path - Return: $Return" 'DEBUG' $Debug }
    
        $Return = $Return | Select-String -Pattern '"Name": "([^"]+)"|"ReferenceId": "([^"]+)"' -CaseSensitive -AllMatches
        For ($i = 0; $i -gt $Return.Matches.Count; $i++) {
            If ($Debug) { LogWrite "$Path - Name: $($Return.Matches[$i].Groups[1].Value) - Value: $($Return.Matches[$i+1].Groups[2].Value)" 'DEBUG' $Debug }
            $Attributes += ''
            $Attributes[0] += 1
            $Attributes[$Attributes[0]] = @("$($Return.Matches[$i].Groups[1].Value)", "$($Return.Matches[$i+1].Groups[2].Value)")
            $i++
        }
        return $Attributes
    }
    
    # https://servername/MobiControl/api/customdata
    Function GetCustomData{ #returns an array of all custom data with their names and IDs: Name | ID
        param (
            [bool]$Debug = $false
        )
        $Data = @(,0)
    
    	$Return = SendRequest $API 'GET' "/MobiControl/api/customdata" 'application/json' 'Content' $null $false
        If ($Debug) { LogWrite "$Path - Return: $Return" 'DEBUG' $Debug }
    
        $Return = $Return | Select-String -Pattern '"Name": "([^"]+)"|"ReferenceId": "([^"]+)"' -CaseSensitive -AllMatches
        For ($i = 0; $i -lt $Return.Matches.Count; $i++) {
            If ($Debug) { LogWrite "$Path - Name: $($Return.Matches[$i].Groups[1].Value) - ID: $($Return.Matches[$i+1].Groups[2].Value)" 'DEBUG' $Debug }
            $Data += ''
            $Data[0] += 1
            $Data[$Data[0]] = @("$($Return.Matches[$i].Groups[1].Value)", "$($Return.Matches[$i+1].Groups[2].Value)")
            $i++
        }
        return $Data
    }
    
    Function GetCustomAttributeValues{ #returns an array of all custom attributes with their names and Values: Name | Value
        param (
            [string]$Path,
            [bool]$Debug = $false
        )
        $Values = @(,0)
        $SotiPath = [URI]::EscapeUriString([URI]::EscapeUriString($Path))
    
    	$Return = SendRequest $API 'GET' "/MobiControl/api/devicegroups/$SotiPath/customAttributes" 'application/json' 'Content' $null $false
        If ($Debug) { LogWrite "$Path - Return: $Return" 'DEBUG' $Debug }
    
        $Pattern = '"Name": "([^"]+)"|"Value": "([^"]+)"|"Value": ([^"]+),'
        If ($Debug) { LogWrite "$Path - Pattern: $Pattern" 'DEBUG' $Debug }
        $Return = $Return | Select-String -Pattern $Pattern -CaseSensitive -AllMatches
        If ($Debug) { LogWrite "$Path - Matches: $($Return.Matches)" 'DEBUG' $Debug }
    
        For ($i = 0; $i -lt $Return.Matches.Count; $i++) {
            If ($Debug) { LogWrite "$Path - Name: $($Return.Matches[$i].Groups[1].Value) - Value: $($Return.Matches[$i+1].Groups[2].Value)" 'DEBUG' $Debug }
            $Values += ''
            $Values[0] += 1
            $Values[$Values[0]] = @("$($Return.Matches[$i].Groups[1].Value)", "$($Return.Matches[$i+1].Groups[2].Value)")
            $i++
        }
        return $Values
    }
    
    function SetCustomAttribute { #sets the custom attribute for all devices in a group
        param (
            [string]$Path,
            [string]$AttributeName,
            [string]$Value,
            [bool]$Debug = $false
        )
        $SotiPath = [URI]::EscapeUriString([URI]::EscapeUriString($Path))
    
        $Content = "{`"Attributes`":[{`"AttributeName`":`"$AttributeName`",`"AttributeValue`":`"$Value`"}]}"
        If ($Debug) { 
            LogWrite "$Path - Content: $Content" 'DEBUG' $true
            LogWrite "$Path - /MobiControl/api/devicegroups/$SotiPath/customAttributes" 'DEBUG' $true
        }
    
        $Return = SendRequest $API 'PUT' "/MobiControl/api/devicegroups/$SotiPath/customAttributes" 'application/json' 'StatusCode' $Content $false
        $EncodeStatusCode = EncodeStatusCode $Return $Debug
        If ($Debug) { LogWrite "$Path - Return: $EncodeStatusCode" 'DEBUG' $true}
        LogWrite "$Path - Set $AttributeName to $Value" 'INFO' $false
        
        return $EncodeStatusCode
    }
    
    Function SetCustomAttribute_Path { #sets the custom attribute for all devices in a group
        param (
            [string]$Path,
            $Values,
            [string]$ValueName,
            [string]$Value,
            [bool]$Debug = $false
        )
        If ($null -eq $Value) {
            LogWrite "$Path - No value provided for $ValueName`: $Value" 'ERROR' $false
            return $false
        }
    
        For ($a = 1; $a -le $Values[0]; $a++) {
            if ($Values[$a][0] -eq $ValueName -and $Values[$a][1] -ne $Value) {
                LogWrite "$Path - Setting $ValueName to $Value" 'INFO' $false
                $Values[$a][1] = $Value
                if (SetCustomAttribute $Path $ValueName $Value $false) {
                    LogWrite "$Path - $ValueName set successfully" 'INFO' $false
                    return $true
                } else {
                    LogWrite "$Path - Failed to set $ValueName" 'ERROR' $false
                    return $false
                }
            } elseif ($Values[$a][0] -eq $ValueName -and $Values[$a][1] -eq $Value) {
                LogWrite "$Path - Name: $($Values[$a][0]) - Value: $($Values[$a][1]) (no change needed)" 'INFO' $false
                return $true
            }
        }
        LogWrite "$Path - $ValueName not found in custom attributes" 'ERROR' $false
        return $false
    }
    
    function GetDevices {
        param (
            [string]$Path,
            [string]$Filtertype = 'DeviceName', #DeviceName, IMEI_MEID_ESN, HardwareSerialNumber, LastAgentConnectTime, LastAgentDisconnectTime, DeviceId
            [string]$Filter = '',
            [string]$OrderType = '+', # + -> %2B
            [string]$OrderField = $Filtertype,
            [bool]$Debug = $false
        )
        if ($OrderType -eq "+") {
            $OrderType = '%2B'
        }
        $Order    = "$OrderType$OrderField"
        $SotiPath = [System.Uri]::EscapeDataString($Path)
    
        $Return = SendRequest $API 'GET' "/MobiControl/api/devices?path=$SotiPath&order=$Order" 'application/json' 'Content' $null $Debug
        If ($Debug) { LogWrite "$Path - Return: $Return" 'DEBUG' $Debug }
        $Return = $Return | ConvertFrom-Json
        $Devices = @(:Loop for($i = 0; $i -lt $Return.DeviceName.Count; $i += 1){
            Switch ($Filtertype) {
                'DeviceName' {
                    If ($Return.DeviceName[$i] -notlike "*$Filter*") {
                        continue Loop
                    }
                }
                'IMEI_MEID_ESN' {
                    If ($Return.IMEI_MEID_ESN[$i] -notlike "*$Filter*") {
                        continue Loop
                    }
                }
                'HardwareSerialNumber' {
                    If ($Return.HardwareSerialNumber[$i] -notlike "*$Filter*") {
                        continue Loop
                    }
                }
                'LastAgentConnectTime' {
                    If ($Return.LastAgentConnectTime[$i] -notlike "*$Filter*") {
                        continue Loop
                    }
                }
                'LastAgentDisconnectTime' {
                    If ($Return.LastAgentDisconnectTime[$i] -notlike "*$Filter*") {
                        continue Loop
                    }
                }
            }
            [pscustomobject]@{
                DeviceName = $Return.DeviceName[$i]
                IMEI = $Return.IMEI_MEID_ESN[$i]
                SerialNumber = $Return.HardwareSerialNumber[$i]
                LastConnect = $Return.LastAgentConnectTime[$i]
                LastDisconnect = $Return.LastAgentDisconnectTime[$i]
                DeviceId = $Return.DeviceId[$i]
            }
        })
        if ($Debug) { LogWrite "$Path - Devices: $Devices" 'DEBUG' $Debug }
    
        return $Devices
    }
    
    Function GetOfflineDevices {
        Param (
            [string]$Path,
            [int]$DurationValue = 30,
            [string]$DurationType = 'DAYS', #DAYS, HOURS, MINUTES
            [bool]$Debug = $false
        )
        $SotiPath = [URI]::EscapeUriString([URI]::EscapeUriString($Path))
        if ($Debug) { LogWrite "$Path - Getting offline devices for more than $DurationValue $DurationType" 'DEBUG' $Debug }
    
        $Return = SendRequest $API 'GET' "/MobiControl/api/devices/search?groupPath=$SotiPath&filter=LastAgentDisconnectTime%2520NOT%2520WITHIN%2520$DurationValue%2520$DurationType%2520AND%2520IsAgentOnline%2520%253D%2520FALSE&includeSubgroups=true&verifyAndSync=true&order=%2BDeviceName" 'application/json' 'Content' $null $false
        If ($Debug) { LogWrite "$Path - Return: $Return" 'DEBUG' $Debug }
        $Return = $Return | ConvertFrom-Json 
    
        $timeformat = 'MM/dd/yyyy HH:mm:ss'
        $Devices = @(for($i = 0; $i -lt $Return.DeviceName.Count; $i++){    
            $Now = Get-Date
            $Offline = [datetime]::ParseExact(($Return.LastAgentDisconnectTime[$i]), $timeformat, [System.Globalization.CultureInfo]::InvariantCulture)
            $DaysOffline = NEW-TIMESPAN -Start $Offline -End $Now
            $DaysOffline = $DaysOffline.Days
    
            if ($Return.DeviceName.Count -eq 1) {
                if ($Debug) { 
                    LogWrite "$Path\$($Return.DeviceName) - $($Return.LastAgentDisconnectTime)" 'DEBUG' $Debug
                    LogWrite "$Path\$($Return.DeviceName) - Online: $Now - Offline: $Offline - Days offline: $($DaysOffline)" 'DEBUG' $Debug 
                }
                [pscustomobject]@{
                    DeviceName = $Return.DeviceName
                    Path = $Return.Path
                    Offline = $DaysOffline
                    IMEI = $Return.IMEI_MEID_ESN
                    SerialNumber = $Return.HardwareSerialNumber
                }
            } else {
                if ($Debug) { 
                    LogWrite "$Path\$($Return.DeviceName[$i]) - $($Return.LastAgentDisconnectTime[$i])" 'DEBUG' $Debug 
                    LogWrite "$Path\$($Return.DeviceName[$i]) - Online: $Now - Offline: $Offline - Days offline: $($DaysOffline)" 'DEBUG' $Debug 
                }
                [pscustomobject]@{
                    DeviceName = $Return.DeviceName[$i]
                    Path = $Return.Path[$i]
                    Offline = $DaysOffline
                    IMEI = $Return.IMEI_MEID_ESN[$i]
                    SerialNumber = $Return.HardwareSerialNumber[$i]
                }
            }
        })
        return $Devices
    }
    
    Function Getgroup {
        Param (
            [string]$Path,
            [string]$GroupNumber,
            [bool]$Debug
        )
        $Return = GetGroups $Path 'group' $false
        If ($Debug) { LogWrite "Return: $Return" 'DEBUG' $Debug }
        If ($Return -contains $GroupNumber) {
            Return $true
        }
        Return $false
    }
    
    Function GetGroups{ #returns an array of all groups in a given path and mode: Name
        param (
            [string]$Path,
            [string]$Mode,
            [bool]$Debug = $false
        )
        if ($Mode -eq 'A') { # replaced our expectations, so need to be aligned for own usage
           $Length = 10
        } elseif ($Mode -eq 'B') {
           $Length = 11
        } elseif ($Mode -eq 'C') {
           $Length = 12
        } elseif ($Mode -eq 'D') {
           $Length = 99
        }
    
        $SotiPath = [URI]::EscapeUriString([URI]::EscapeUriString($Path))
        $Groups = @(,0)
    
    	$Return = SendRequest $API 'GET' "/MobiControl/api/devicegroups?parentPath=$SotiPath" 'application/json' 'Content' $null $false
        If ($Debug) { LogWrite "$Path - Return: $Return" 'DEBUG' $Debug }
    
        $Return = $Return | Select-String -Pattern '"Name": "([^"]+)"' -CaseSensitive -AllMatches
        For ($i = 0; $i -lt $Return.Matches.Count; $i++) {
            If ($Return.Matches[$i].Groups[1].Value.Length -le $Length) {
                $Groups += "$($Return.Matches[$i].Groups[1].Value)"
                $Groups[0] += 1
                if ($Debug) { LogWrite "$Path - Added: $($Return.Matches[$i].Groups[1].Value)" 'DEBUG' $Debug }
            }
        }
        return $Groups
    }
    
    Function AddGroup {
        Param (
            [string]$Path,
            [string]$GroupNumber,
            [bool]$Debug
        )
        $SotiPath = "$Path\$GroupNumber" -replace '\\','\\'
        If ($Debug) { LogWrite "SotiPath: $SotiPath" 'DEBUG' $Debug }
        $Data = '{"Name":"' + $GroupNumber + '","Path":"' + $SotiPath + '","Icon":"None","Kind": "Regular"}'
        If ($Debug) { LogWrite "Data: $Data" 'DEBUG' $Debug }
    
        $Return = SendRequest $API 'POST' '/MobiControl/api/devicegroups' 'application/json' 'Content' $Data $False
        If ($Debug) { LogWrite "Return: $Return" 'DEBUG' $Debug }
        $Return = $Return | Select-String -Pattern '"ReferenceId": "([^"]+)"' -CaseSensitive -AllMatches
        return $Return.Matches.Groups[1].Value
    }
    
    Function GetDeviceGroupID {
        Param (
            [string]$Path,
            [bool]$Debug = $false
        )
        $SotiPath = [URI]::EscapeUriString([URI]::EscapeUriString($Path))
    
        $Return = SendRequest $API 'GET' "/MobiControl/api/devicegroups/$SotiPath" 'application/json' 'Content' $null $false
        If ($Debug) { LogWrite "$Path - Return: $Return" 'DEBUG' $Debug }
    
        $Return = $Return | Select-String -Pattern '"ReferenceId": "([^"]+)"' -CaseSensitive -AllMatches
        $ID = $Return.Matches.Groups[1].Value
        return $ID
    }
    
    Function GetRelocationID {
        Param (
            [string]$Name,
            [bool]$Debug = $false
        )
    
    	$Return = SendRequest $API 'GET' "/MobiControl/api/deviceRelocationPolicies?searchString=$Name&statuses=Assigned" 'application/json' 'Content' $null $false
        If ($Debug) { LogWrite "$Name - Return: $Return" 'DEBUG' $Debug }
    
        $Return = $Return | Select-String -Pattern '"ReferenceId": "([^"]+)"' -CaseSensitive -AllMatches
        $ID = $Return.Matches.Groups[1].Value
        return $ID
    }
    
    Function GetRelocationData {
        Param (
            [string]$RelocationRuleID,
            [string]$GroupID,
            [string]$Group,
            [bool]$Debug = $false
        )
        $Values = @(,0)
        
    
        $Return = SendRequest $API 'GET' "/MobiControl/api/deviceRelocationPolicies/$RelocationRuleID" 'application/json' 'Content' $null $false
        If ($Debug) { LogWrite "$Group - GetRelocationData Response: $Return" 'DEBUG' $Debug }
        
        $Return = $Return | Select-String -Pattern '"DeviceGroupReferenceId": "([^"]+)"|"DeviceGroupPath": "([^"]+)"' -CaseSensitive -AllMatches
        For ($i = 0; $i -le $Return.Matches.Count-1; $i++) {
            If ($Debug) { LogWrite "$Group - DeviceGroupReferenceId: $($Return.Matches[$i].Groups[1].Value) - DeviceGroupPath: $($Return.Matches[$i+1].Groups[2].Value)" 'DEBUG' $Debug }
            $Values += ''
            $Values[0] += 1
            $Values[$Values[0]] = @("$($Return.Matches[$i].Groups[1].Value)", "$($Return.Matches[$i+1].Groups[2].Value)")
            if ($Debug) { LogWrite "$Group - Added Data Values ($i/$($i+1)/$($Return.Matches.Count)): $($Return.Matches[$i].Groups[1].Value) | $($Return.Matches[$i+1].Groups[2].Value)" } 
            $i++
        }
    
        $Values += ''
        $Values[0] += 1
        $Values[$Values[0]] = @("$GroupID", "$Group")   
        if ($Debug) { 
            LogWrite "$Group - Added Data Values ($i/$($i+1)/$($Return.Matches.Count)): $($Return.Matches[$i].Groups[1].Value) | $($Return.Matches[$i+1].Groups[2].Value)"
            LogWrite "$Group - Relocation Data Values: $Values" 'DEBUG' $Debug 
        }
        return $Values
    }
    
    $login = Get-Credential
    $accessToken = SendTokenRequest $API 'POST' '/MobiControl/api/token' "grant_type=password&username=$($login.UserName)&password=$($login.GetNetworkCredential().Password)" $false
    Alles anzeigen
  • Weihnachtsgrüße

    • Moombas
    • 5. Januar 2026 um 10:08

    So, zurück aus dem Urlaub, nachträglich schöne Weihnachten :D

    Und natürlich ein frohes neues Jahr.

  • Arbeiten mit AutoIt (Windows Defender, UAC ...)

    • Moombas
    • 24. November 2025 um 15:17

    Also ich habe damit nur beim Kompilieren Probleme.
    Dafür sind entsprechende Verzeichnisse im Defender ausgeschlossen worden und klappt nun.
    Entsprechend würde ich Verfahren, wenn er auch für die exe Dateien anschlägt, die entsprechenden Verzeichnisse oder (besser) nur die Datei(en) ausnehmen.

    Denn diese einzusenden um sie raus zu bekommen, dauert nicht nur ewig, sondern hält in der Regel auch nur eine gewisse Zeit.

  • PCIe 5 SSD

    • Moombas
    • 7. November 2025 um 09:23
    Zitat von Oscar

    "wer misst, misst Mist"

    Eigentlich heißt es "wer viel misst, misst Mist" ;)

  • Funktion mit unbestimmter Anzahl von Parametern

    • Moombas
    • 29. Oktober 2025 um 10:56

    Hmm wieder was gelernt^^ Das @NumParams kannte ich auch noch nicht.

    Aber anstatt X Parameter zu übergeben, würde ich, wenn irgendwie möglich, eher dazu übergehen wenige, dafür z.B. sinnvoll in Array(s) gepackt diese zu übergeben. Aber das hängt wohl auch stark vom Anwendungsfall ab.

  • Fronius Webseite auslesen

    • Moombas
    • 11. September 2025 um 11:32

    Mal nebenbei Tweaky.

    Hast du mal versucht ob du aus folgendem Link informationen bekommst?
    http://ipvomfronius/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System

    Quelle: https://homematic-forum.de/forum/viewtopic.php?t=24675

  • Fronius Webseite auslesen

    • Moombas
    • 8. September 2025 um 15:58
    Zitat von Gun-Food
    DatenpaketeDatenpunkte/MonatKosten / Monat
    Basic*1 - 500.00040,00 €
    Small500.001 - 2.500.000150,00 €
    Medium2.500.001 - 10.000.000380,00 €
    Large10.000.001 - 30.000.000520,00 €
    Advanced30.000.001 - 60.000.000750,00 €
    Pro> 60.000.0001.200,00 €

    Die Preise sind ja schon dreist...

    Wo hast du die denn gefunden? hab versucht das herauszufinden aber nur die Tabelle mit den Datenpunkten (ohne Preise) gefunden...
    Aber 40€/Monat frisst mal eben deinen "Gewinn" der Einspeisung ggf. mehr als auf...

    Das erinnert mich an das Webmodul von unserer Wärmepumpe (Nibe), das war (zumindest vor ~10 Jahren) auch kostenpflichtig...

  • Fronius Webseite auslesen

    • Moombas
    • 8. September 2025 um 09:43

    Achja btw, für mich auch nicht ganz uninteressantes Thema, denn wir bekommen eine neue PV Anlage aufs dach, auch mit einem Fronius WR ;)

  • Fronius Webseite auslesen

    • Moombas
    • 8. September 2025 um 08:16

    Blöde Frage, warum nicht die API verwenden?

    📈 Solar.web Query API - REST API
    Solar.web Query API eine REST API für Gewerbe & Industrie. Ermöglicht automatisierten Datenaustausch zwischen zwei Applikationen. 👉 Mehr erfahren
    www.fronius.com

    Edit: Ach, ich sehe gerade, das das leider nciht kostenfrei möglich ist (pay per use) -.- also damit fällt meine Frage wohl flach :D

  • Windows Graphics Capture API (WinRT) Fullscreen Capturing Test

    • Moombas
    • 27. August 2025 um 15:50

    Aber 3440*1440 wäre UWQHD (das habe ich z.B. auch zu Hause), die nächste wirkliche 4K Auflösung wäre 3840x2160.

  • Splashscreen-Gui mit Terminate Button / GuiEvents richtig abfangen

    • Moombas
    • 21. August 2025 um 10:40

    Ganz abgesehen von Kanashius ansatz, und nur wegen meiner Anmerkung musst du natürlich die Variable $Button1 (+alle anderen angesteuerten GUI Elemente der anderen GUI) Global haben, nicht lokal. Sprich Global leer definieren und in der Funktion dann füllen oder von der Funktion füllen lassen.

    Denn klar kann guigetmsg nicht drauf reagieren wenn es diese Variable nicht kennt/gefüllt ist.

  • Splashscreen-Gui mit Terminate Button / GuiEvents richtig abfangen

    • Moombas
    • 20. August 2025 um 15:32

    Case $Button1 in der While schleife oder soll er dann wirklich aus allen schleifen durchläufen zurückspringen?

  • Festgelegten Ordner in den aktuell ausgewählten Ordner kopieren

    • Moombas
    • 16. Juli 2025 um 10:17

    Du musst das am Anfang des Scriptes einfügen und dann sollte der shortcut (sofern nicht von anderen Sachen in z.B. Windows belegt) überall im Skript funktionieren.

    Wenn du aber einfach nach dem SetError(3) das ausführen willst, also immer, dann ruf dort einfach UmbenennenUndLeeren() auf.

    Allerdings musst du das Return dann später aufrufen.

  • Android 12 - WLAN priorisieren

    • Moombas
    • 17. Juni 2025 um 07:46
    Zitat von BugFix

    Mein Smartphone hat diese Einstellung nicht. Speichere ich das Kennwort, wird auch automatisch neu verbunden. Alternativ müsste also bei jedem Verbinden das Passwort händisch eingegeben werden.

    Hmm, ich habe leider kein Smartphone mit einem so alten OS mehr rum liegen aber diese Einstellung kannst du nur machen NACHDEM du es gespeichert hast, also du musst den Eintrag "bearbeiten".
    Habe noch ein einziges bei uns in der Firma gefunden und mich eben kurz aufgeschaltet, auch dort kann ich auf A12 diese Einstellung sehen. Gehe dazu in die Wifi settings, gespeicherte WiFi, wähle das entsprechende aus und dort solltest du den entsprechenden Haken sehen.

    Und wegen der Fritzbox, wenn ich mich nicht irre müsste beides gehen, denn die Wifi settings sind ja unabhängig von den Intterneteinstellungen der Fritzbox. Musst sie nur von "Mesh-Master" auf "Mesh-Repeater" umstellen und wahrscheinlich dann dort WLAN als Quelle nehmen und nicht LAN.

  • Android 12 - WLAN priorisieren

    • Moombas
    • 16. Juni 2025 um 08:16

    BugFix Also zunächst einmal die einfachste Lösung: Warum schaltest du nicht das Wifi der Fritzbox einfach ab oder löschst es aus dem Gerät wo du es nicht nutzen willst?

    Android nimmt sich in der Tat immer das Wifi, das die (scheinbar) beste Verbindung zum Internet bereitstellt. Die Eckpunkte dafür sind leider nicht immer ganz plausibel.
    Du solltest jedoch in deinen Wifi Einstellungen von der jeweiligen SSID den Haken "automatisch erneut verbinden" raus nehmen können und auch damit das Problem (hoffentlich) beheben. Da ich das bisher nicht genutzt habe, keine Garantie darauf ;)

    Ansonsten frage ich gerne mal bei Google nach (https://productexperts.withgoogle.com/directory/a80c…6a-330ee7a38920) da mein Spezialgebiet ein klein wenig woanders liegt ;)

    Btw.: Den Einwand von Gun-Food finde ich zudem auch sehr treffend.

  • Switch GUI

    • Moombas
    • 13. Juni 2025 um 08:51
    Zitat von wuff100

    Das stimmt! Aber vielleicht gibt es für die Version ja eine Lösung.

    Mal ganz abgesehen von dem was hier schon (sehr relevanter Weise) gepostet wurde. Warum sollte es das, wenn du es nicht brauchst? Also warum unbedingt 2 Loops benutzen?

  • Switch GUI

    • Moombas
    • 12. Juni 2025 um 15:56

    Warum überhaupt 2 loops? Du kannst doch beides in einer abfragen...

  • zeit berechnung zwischen zwei zeiten aber inklusive millisekunden

    • Moombas
    • 4. Juni 2025 um 14:54

    Hier hat keiner "drauf gehauen" und ich habe jetzt nicht auf die beiden Zeitstempel geschaut, muss ich zugeben aber für mich (Stand jetzt) auch nicht zu 100% ersichtlich:

    Der Inhalt kann nicht angezeigt werden, da du keine Berechtigung hast, diesen Inhalt zu sehen.

    Würde ich hier irgendwo "drauf hauen" wäre der Ton weitaus anders.

  • zeit berechnung zwischen zwei zeiten aber inklusive millisekunden

    • Moombas
    • 4. Juni 2025 um 11:44

    Um mal das Beispiel von AspirinJunkie zu nehmen, Zeile ab Zeile 10 folgendes eingetragen:

    Code
    Global Const $ms = _SystemTimeDiff($tNow, $tThen)
    ConsoleWrite("Zeitdifferenz: " & $ms & " ms" & @CRLF)
    ConsoleWrite("Zeitdifferenz: " & StringFormat("%.2d:%.2d:%06.3f", (Floor($ms / 3600000)), (Floor(Mod($ms,3600000) / 60000)), (Mod(Mod($ms,3600000),60000) / 1000)) & @CRLF)

    Und Zeile 22 wie erwähnt verändert: Return _SystemTime2JulianMSecs($tTime2) - _SystemTime2JulianMSecs($tTime1)

    Ergibt dann als Ausgabe (z.B. bei 35456000ms):

    Zeitdifferenz: 35456123 ms
    Zeitdifferenz: 09:50:56.123

    Hier ein kleines sample mit GUI aber Augabe nur in der Konsole:

    AutoIt
    Opt('MustDeclareVars', 1)
    #include <Date.au3>
    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    
    Example()
    
    Func Example()
    Local $tNow, $tThen, $ms
            ; Create a GUI with various controls.
            Local $hGUI = GUICreate("Example", 300, 200)
    
            ; Create a checkbox control.
            Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25)
            Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)
    
            ; Display the GUI.
            GUISetState(@SW_SHOW, $hGUI)
    
            ; Loop until the user exits.
            While 1
                    Switch GUIGetMsg()
                            Case $GUI_EVENT_CLOSE, $idButton_Close
                                    ExitLoop
    
                            Case $idCheckbox
                                    If GUICtrlRead($idCheckbox) = $GUI_CHECKED Then
    									$tNow = _Date_Time_EncodeSystemTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC, @MSEC)
                                    Else
    									$tThen = _Date_Time_EncodeSystemTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC, @MSEC)
    									$ms = _SystemTimeDiff($tNow, $tThen)
    									ConsoleWrite("Zeitdifferenz: " & $ms & " ms" & @CRLF)
    									ConsoleWrite("Zeitdifferenz: " & StringFormat("%.2d:%.2d:%06.3f", (Floor($ms / 3600000)), (Floor(Mod($ms,3600000) / 60000)), (Mod(Mod($ms,3600000),60000) / 1000)) & @CRLF)
    									$tNow = ''
    									$tThen = ''
    									$ms = ''
                                    EndIf
    
                    EndSwitch
            WEnd
    
            ; Delete the previous GUI and all controls.
            GUIDelete($hGUI)
    EndFunc   ;==>Example
    
    ; Berechnet die Differenz zweier Zeitstempel in Millisekunden (tTime1 - tTime2)
    Func _SystemTimeDiff($tTime1, $tTime2)
    	If Not IsDllStruct($tTime1) Then Return SetError(1,0, Null)
    	If Not IsDllStruct($tTime2) Then Return SetError(2,0, Null)
    
    	Return _SystemTime2JulianMSecs($tTime2) - _SystemTime2JulianMSecs($tTime1)
    EndFunc
    
    ; konvertiert eine SYSTEMTIME-Struktur in ein julianisches Datum mit Millisekundenauflösung
    Func _SystemTime2JulianMSecs($tSystemTime)
    	If Not IsDllStruct($tSystemTime) Then Return SetError(1,0, Null)
    
    	Local $dYear =   DllStructGetData($tSystemTime, "Year"), _
    	      $dMonth =  DllStructGetData($tSystemTime, "Month"), _
              $dDay =    DllStructGetData($tSystemTime, "Day"), _
              $dHour =   DllStructGetData($tSystemTime, "Hour"), _
              $dMinute = DllStructGetData($tSystemTime, "Minute"), _
              $dSecond = DllStructGetData($tSystemTime, "Second"), _
              $dMs =     DllStructGetData($tSystemTime, "MSeconds")
    
    	Local $fMsecs = Int(_DateToDayValue($dYear, $dMonth, $dDay) * 86400000, 2) _ ; julianisches Datum aus Jahr, Monat, Tag berechnen
    		  + $dHour   * 3600000 _
    		  + $dMinute * 60000 _
    		  + $dSecond * 1000 _
    		  + $dMs
    
    	Return $fMsecs
    EndFunc
    Alles anzeigen

    Credits to AspirinJunkie and zaNergal habs nur zusammen gefügt :P

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™