CPU Frequency Limiter — Donanımınızın Sınırlarını Siz Belirleyin

Programlama ve Script dilleri konusunda bilgi paylaşım alanıdır.
Cevapla
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15572
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2702 kez
Teşekkür edildi: 5602 kez

CPU Frequency Limiter — Donanımınızın Sınırlarını Siz Belirleyin

Mesaj gönderen TRWE_2012 »

Merhabalar

Hemen konuya giriş yapalım...Bu bir powershell gerçek yönetim donanım katmanı müdahale betiğidir.Gerçek sistem (Windows11) ve donanımda (Lenovo Idepad Gaming 3) test edilmiştir.Sonuç olarak, "GEÇER" not almıştır, uygulayan tarafından...(TRWE_2012)

Dizüstü bilgisayarınızın işlemcisi bazen gereğinden fazla ısınıyor, fanlar gürültü yapıyor ya da bataryanız hızla tükeniyor mu? Bu betik, Windows'un yerleşik güç yönetim altyapısını (powercfg) kullanarak CPU'nuzun maksimum hızını saniyeler içinde GHz cinsinden sınırlamanıza olanak tanır.

Neden güvenli?

Bu bir aşırı hızlandırma (overclock) aracı değildir ,tam tersi. CPU'nun zaten fabrika tarafından desteklediği hız aralığının üst sınırını belirler, voltaj veya firmware'e hiç dokunmaz. İstediğiniz an tek tıkla temel hıza ya da tam performansa geri dönebilirsiniz; kalıcı hiçbir değişiklik veya risk yoktur.

Neden herkes için çalışır?

Betik hiçbir donanıma özel sabit değer içermez , açıldığında kendi CPU'nuzun temel hızını otomatik önerir, siz yalnızca Turbo Boost tavanınızı bir kez girersiniz. Intel, AMD, hangi model olursa olsun aynı mantıkla çalışır.

Üç basit buton, üç net sonuç:

1. Return to Base Speed : Günlük kullanım için sessiz, serin, düşük güç tüketimi
2 .Remove Limit (100%) : Oyun veya ağır iş yükü için tam performans
3. Apply Custom GHz : Kendi belirlediğiniz hassas bir tavan

Tek tık, sıfır risk, tam kontrol... Ve uzun ömürlü donanım parçası...

Ekran Görüntüsü : (Aşağıdakiler bana (donanıma özel betik ) görüntüleridir.
Resim
Resim
Benim sizler için tasarladığım bu...
Resim
Birinci değer Base Speed (GHz) = Windows'un otomatik okuduğu değer (temel çalışma hızınız), isterseniz bunu da değiştirebilirsiniz.
İkinci değer kutucuğuna sahip olduğunuz CPU'nun maksimum hızını (Turbo hız) yazın.
Üçüncü değer kutucuğuna sahip olduğunuz CPU'nuza kullanmak istediğiniz bir değeri (min-mak değerleri arasında bir değer) yazın.
Sonra, "Appy Custom GHz" butonuna basın...

Bu kadar.

Güle güle kullanın....

CPU-Frequency-Limiter.ps1

Kod: Tümünü seç

# ============================================================
# CPU Frequency Limiter (simple: set target GHz / return to base / no hardware risk)
# System : Windows 11
# ============================================================

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
[System.Windows.Forms.Application]::EnableVisualStyles()

# --- ADMIN CHECK (required to write power scheme values) ---
$currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal($currentIdentity)
if (-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    [System.Windows.Forms.MessageBox]::Show(
        "This script must be run with Administrator privileges.",
        "Error",
        [System.Windows.Forms.MessageBoxButtons]::OK,
        [System.Windows.Forms.MessageBoxIcon]::Error
    ) | Out-Null
    exit 1
}

# --- SUB_PROCESSOR / PROCTHROTTLEMAX GUIDs (fixed, built-in to Windows) ---
$SubProcessorGuid = "54533251-82be-4824-96c1-47b60b740d00"
$ProcThrottleMaxGuid = "bc5038f7-23e0-4960-96da-33abaf5935ec"

# --- GET CPU NAME AND AUTO-DETECTED BASE SPEED SUGGESTION ---
$cpuInfo = Get-CimInstance -ClassName Win32_Processor | Select-Object -First 1
$cpuName = $cpuInfo.Name.Trim()

# WMI's MaxClockSpeed usually reports the BASE clock reliably (confirmed on this system:
# it matched 3.3 GHz exactly), so it is used only as an auto-filled SUGGESTION.
# Turbo Boost max has no reliable WMI source, so it has no auto-detected value.
$SuggestedBaseGHz = [math]::Round($cpuInfo.MaxClockSpeed / 1000, 2)

# --- GET CURRENT ACTIVE POWER SCHEME (registry-based, locale-independent) ---
$activeSchemeGuid = $null
try {
    $activeSchemeGuid = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes' -Name 'ActivePowerScheme' -ErrorAction Stop).ActivePowerScheme
} catch {
    $activeSchemeGuid = $null
}

if (-not $activeSchemeGuid) {
    [System.Windows.Forms.MessageBox]::Show(
        "Could not determine the active power scheme.",
        "Error",
        [System.Windows.Forms.MessageBoxButtons]::OK,
        [System.Windows.Forms.MessageBoxIcon]::Error
    ) | Out-Null
    exit 1
}

# --- GET CURRENT PROCTHROTTLEMAX VALUE (registry-based, locale-independent) ---
function Get-CurrentThrottlePercent {
    $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\$activeSchemeGuid\$SubProcessorGuid\$ProcThrottleMaxGuid"
    try {
        return [int](Get-ItemProperty -Path $regPath -Name 'ACSettingIndex' -ErrorAction Stop).ACSettingIndex
    } catch {
        return 100
    }
}

# --- APPLY A GIVEN PERCENTAGE (used by both manual Apply and quick buttons) ---
function Set-ThrottlePercent {
    param([int]$Percent)

    if ($Percent -lt 5) { $Percent = 5 }
    if ($Percent -gt 100) { $Percent = 100 }

    powercfg /setacvalueindex $activeSchemeGuid $SubProcessorGuid $ProcThrottleMaxGuid $Percent | Out-Null
    powercfg /setdcvalueindex $activeSchemeGuid $SubProcessorGuid $ProcThrottleMaxGuid $Percent | Out-Null
    powercfg /setactive $activeSchemeGuid | Out-Null

    Start-Sleep -Milliseconds 800
    return Get-CurrentThrottlePercent
}

# -------------------------------
# Culture-safe number parsing (fixes the earlier tr-TR comma/period bug)
# -------------------------------
function Parse-GhzValue {
    param([string]$InputText)

    $normalized = $InputText.Trim().Replace(',', '.')
    $value = 0.0
    $ok = [double]::TryParse(
        $normalized,
        [System.Globalization.NumberStyles]::Float,
        [System.Globalization.CultureInfo]::InvariantCulture,
        [ref]$value
    )
    if ($ok) { return $value } else { return $null }
}

# -------------------------------
# Main form
# -------------------------------

function Show-FrequencyLimiterForm {
    $currentPercent = Get-CurrentThrottlePercent

    $form = New-Object System.Windows.Forms.Form
    $form.Text = "CPU Frequency Limiter"
    $form.Width = 460
    $form.Height = 400
    $form.StartPosition = "CenterScreen"
    $form.FormBorderStyle = "FixedDialog"
    $form.MaximizeBox = $false

    $infoLabel = New-Object System.Windows.Forms.Label
    $infoLabel.Text = "CPU: $cpuName`nCurrent limit: $currentPercent%"
    $infoLabel.Location = New-Object System.Drawing.Point(15, 15)
    $infoLabel.Width = 420
    $infoLabel.Height = 40
    $form.Controls.Add($infoLabel)

    $baseLabel = New-Object System.Windows.Forms.Label
    $baseLabel.Text = "Base speed (GHz):"
    $baseLabel.Location = New-Object System.Drawing.Point(15, 65)
    $baseLabel.Width = 220
    $form.Controls.Add($baseLabel)

    $baseBox = New-Object System.Windows.Forms.TextBox
    $baseBox.Location = New-Object System.Drawing.Point(240, 63)
    $baseBox.Width = 100
    $baseBox.Text = $SuggestedBaseGHz.ToString([System.Globalization.CultureInfo]::InvariantCulture)
    $form.Controls.Add($baseBox)

    $turboLabel = New-Object System.Windows.Forms.Label
    $turboLabel.Text = "Known Turbo Boost max (GHz):"
    $turboLabel.Location = New-Object System.Drawing.Point(15, 95)
    $turboLabel.Width = 220
    $form.Controls.Add($turboLabel)

    $turboBox = New-Object System.Windows.Forms.TextBox
    $turboBox.Location = New-Object System.Drawing.Point(240, 93)
    $turboBox.Width = 100
    $turboBox.Text = ""
    $turboBox.ForeColor = [System.Drawing.Color]::Gray
    $form.Controls.Add($turboBox)

    $ghzLabel = New-Object System.Windows.Forms.Label
    $ghzLabel.Text = "Target maximum speed (GHz):"
    $ghzLabel.Location = New-Object System.Drawing.Point(15, 125)
    $ghzLabel.Width = 220
    $form.Controls.Add($ghzLabel)

    $ghzBox = New-Object System.Windows.Forms.TextBox
    $ghzBox.Location = New-Object System.Drawing.Point(240, 123)
    $ghzBox.Width = 100
    $ghzBox.Text = ""
    $form.Controls.Add($ghzBox)

    $noteLabel = New-Object System.Windows.Forms.Label
    $noteLabel.Text = "Base and Turbo values are not the same on every CPU - enter`nyour own processor's specs here. This only caps the maximum`nP-state Windows will request: no overclocking, no firmware`nchanges, fully reversible at any time - no hardware risk."
    $noteLabel.Location = New-Object System.Drawing.Point(15, 155)
    $noteLabel.Width = 420
    $noteLabel.Height = 65
    $noteLabel.ForeColor = [System.Drawing.Color]::DimGray
    $form.Controls.Add($noteLabel)

    # --- Quick action buttons ---
    $baseButton = New-Object System.Windows.Forms.Button
    $baseButton.Text = "Return to Base Speed"
    $baseButton.Location = New-Object System.Drawing.Point(15, 225)
    $baseButton.Width = 250
    $script:quickAction = $null
    $baseButton.Add_Click({
        $script:quickAction = "base"
        $form.DialogResult = [System.Windows.Forms.DialogResult]::OK
        $form.Close()
    })
    $form.Controls.Add($baseButton)

    $unlimitedButton = New-Object System.Windows.Forms.Button
    $unlimitedButton.Text = "Remove Limit (100%)"
    $unlimitedButton.Location = New-Object System.Drawing.Point(275, 225)
    $unlimitedButton.Width = 160
    $unlimitedButton.Add_Click({
        $script:quickAction = "unlimited"
        $form.DialogResult = [System.Windows.Forms.DialogResult]::OK
        $form.Close()
    })
    $form.Controls.Add($unlimitedButton)

    $okButton = New-Object System.Windows.Forms.Button
    $okButton.Text = "Apply Custom GHz"
    $okButton.Location = New-Object System.Drawing.Point(15, 265)
    $okButton.Width = 160
    $okButton.Add_Click({
        $script:quickAction = "custom"
        $form.DialogResult = [System.Windows.Forms.DialogResult]::OK
        $form.Close()
    })
    $form.Controls.Add($okButton)

    $cancelButton = New-Object System.Windows.Forms.Button
    $cancelButton.Text = "Cancel"
    $cancelButton.Location = New-Object System.Drawing.Point(350, 265)
    $cancelButton.Width = 85
    $cancelButton.Add_Click({
        $script:quickAction = $null
        $form.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
        $form.Close()
    })
    $form.Controls.Add($cancelButton)
    $form.CancelButton = $cancelButton

    $result = $form.ShowDialog()

    if ($result -ne [System.Windows.Forms.DialogResult]::OK -or -not $script:quickAction) {
        return $null
    }

    return [PSCustomObject]@{
        Action    = $script:quickAction
        TargetGhz = $ghzBox.Text
        TurboGhz  = $turboBox.Text
        BaseGhz   = $baseBox.Text
    }
}

# -------------------------------
# Main flow
# -------------------------------

$selection = Show-FrequencyLimiterForm

if (-not $selection) {
    exit 0
}

switch ($selection.Action) {

    "base" {
        $baseGhz = Parse-GhzValue $selection.BaseGhz
        $turboGhz = Parse-GhzValue $selection.TurboGhz

        if (-not $baseGhz -or -not $turboGhz -or $baseGhz -le 0 -or $turboGhz -le 0) {
            [System.Windows.Forms.MessageBox]::Show(
                "Please enter valid values for both Base speed and Turbo Boost max.",
                "Error",
                [System.Windows.Forms.MessageBoxButtons]::OK,
                [System.Windows.Forms.MessageBoxIcon]::Error
            ) | Out-Null
            exit 1
        }
        if ($baseGhz -gt $turboGhz) {
            [System.Windows.Forms.MessageBox]::Show(
                "Base speed cannot be higher than Turbo Boost max.",
                "Error",
                [System.Windows.Forms.MessageBoxButtons]::OK,
                [System.Windows.Forms.MessageBoxIcon]::Error
            ) | Out-Null
            exit 1
        }

        $percent = [math]::Round(($baseGhz / $turboGhz) * 100)
        $verified = Set-ThrottlePercent -Percent $percent
        [System.Windows.Forms.MessageBox]::Show(
            "Returned to base speed ($baseGhz GHz).`nApplied limit: $verified%",
            "Base Speed",
            [System.Windows.Forms.MessageBoxButtons]::OK,
            [System.Windows.Forms.MessageBoxIcon]::Information
        ) | Out-Null
    }

    "unlimited" {
        $verified = Set-ThrottlePercent -Percent 100
        [System.Windows.Forms.MessageBox]::Show(
            "Limit removed.`nApplied limit: $verified%",
            "Unlimited",
            [System.Windows.Forms.MessageBoxButtons]::OK,
            [System.Windows.Forms.MessageBoxIcon]::Information
        ) | Out-Null
    }

    "custom" {
        $targetGhz = Parse-GhzValue $selection.TargetGhz
        $turboGhz = Parse-GhzValue $selection.TurboGhz

        if (-not $turboGhz -or $turboGhz -le 0) {
            [System.Windows.Forms.MessageBox]::Show(
                "Please enter your CPU's known Turbo Boost max (GHz) first.",
                "Error",
                [System.Windows.Forms.MessageBoxButtons]::OK,
                [System.Windows.Forms.MessageBoxIcon]::Error
            ) | Out-Null
            exit 1
        }

        if (-not $targetGhz -or $targetGhz -le 0) {
            [System.Windows.Forms.MessageBox]::Show(
                "Invalid GHz value entered.",
                "Error",
                [System.Windows.Forms.MessageBoxButtons]::OK,
                [System.Windows.Forms.MessageBoxIcon]::Error
            ) | Out-Null
            exit 1
        }

        if ($targetGhz -gt $turboGhz) {
            [System.Windows.Forms.MessageBox]::Show(
                "Target speed ($targetGhz GHz) cannot exceed the Turbo Boost max ($turboGhz GHz).",
                "Error",
                [System.Windows.Forms.MessageBoxButtons]::OK,
                [System.Windows.Forms.MessageBoxIcon]::Error
            ) | Out-Null
            exit 1
        }

        $percent = [math]::Round(($targetGhz / $turboGhz) * 100)
        $verified = Set-ThrottlePercent -Percent $percent
        $verifiedGhz = [math]::Round(($turboGhz * $verified) / 100, 2)

        [System.Windows.Forms.MessageBox]::Show(
            "Target: $targetGhz GHz`nApplied limit: $verified% (~$verifiedGhz GHz)`n`nIf the real-world speed does not match, an OEM service (Intel DTT / Lenovo Intelligent Cooling) may be overriding this setting - check running services if so.",
            "Applied",
            [System.Windows.Forms.MessageBoxButtons]::OK,
            [System.Windows.Forms.MessageBoxIcon]::Information
        ) | Out-Null
    }
}

Read-Host "`nPress ENTER to exit."
Cevapla

“Programlama ve Script dilleri” sayfasına dön