Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Copilot keyboard shortcut (Windows key + C) #347

Open
baek-sang opened this issue Apr 22, 2024 · 5 comments
Open

Disable Copilot keyboard shortcut (Windows key + C) #347

baek-sang opened this issue Apr 22, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@baek-sang
Copy link

copilot

Run the above script.

  • Windows 11 23H2 (22631.2715)

Type win + c and the Copilot widget will appear on the right.

@baek-sang baek-sang added the enhancement New feature or request label Apr 22, 2024
@undergroundwires
Copy link
Owner

Hi,

Run these commands in command line:

1.

PowerShell -ExecutionPolicy Unrestricted -Command "$keyToDisable='C'; $keyToDisableInUppercase = $keyToDisable.ToUpper(); $registryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'; $propertyName = 'DisabledHotkeys'; $disabledKeys = Get-ItemProperty -Path $registryPath -Name $propertyName -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "^""$propertyName"^""; if ($disabledKeys) {; if ($disabledKeys.Contains($keyToDisableInUppercase)) {; Write-Host "^""Skipping: Key `"^""$keyToDisableInUppercase`"^"" is already disabled. All disabled keys: `"^""$disabledKeys`"^"". No action needed."^""; exit 0; }; $newKeysToDisable = "^""$($disabledKeys)$($keyToDisableInUppercase)"^""; Write-Host "^""Some keys are already disabled: `"^""$disabledKeys`"^"", but not `"^""$keyToDisableInUppercase`"^"", disabling it too, new disabled keys: `"^""$newKeysToDisable`"^""."^""; try {; Set-ItemProperty -Path $registryPath -Name $propertyName -Value "^""$newKeysToDisable"^"" -Force -ErrorAction Stop; Write-Host "^""Successfully disabled,`"^""$keyToDisableInUppercase`"^"", all disabled keys: `"^""$newKeysToDisable`"^""."^""; Exit 0; } catch {; Write-Error "^""Failed to disable `"^""$newKeysToDisable`"^"": $_"^""; Exit 1; }; } else {; Write-Host "^""No keys has been disabled before, disabling: `"^""$keyToDisableInUppercase`"^""."^""; try {; Set-ItemProperty -Path $registryPath -Name $propertyName -Value "^""$keyToDisableInUppercase"^"" -Force -ErrorAction Stop; Write-Host "^""Successfully disabled,`"^""$keyToDisableInUppercase`"^""."^""; Exit 0; } catch {; Write-Error "^""Failed to disable `"^""$keyToDisableInUppercase`"^"": $_"^""; Exit 1; }; }"

2. (It will restart explorer, needed to activate it):

taskkill /f /im explorer.exe & start explorer

You can test directly after running this script and feel free to report if it worked, if it did not, try to restart your computer and test again.

@baek-sang
Copy link
Author

I ran the script from CMD and rebooted.

Skipping: Key "C" is already disabled. All disabled keys: "C". No action needed.

But the shortcut still works.

@undergroundwires undergroundwires changed the title Disable Copilot widget Disable Copilot keyboard shortcut (Windows key + C) Apr 25, 2024
@undergroundwires
Copy link
Owner

Ok thanks for the feedback. The Copilot you're seeing is not a traditional "app" but an Edge process, making it harder to target it. The script I provided would work if it was Explorer/Taskbar that was handling Win+C, but it does not seems to be the case, and the behavior is undocumented (microsoft/PowerToys#29042).

Now you can revert disabling C like this to restore default state of your computer:

PowerShell -ExecutionPolicy Unrestricted -Command "$keyToRestore='C'; $keyToRestoreInUppercase = $keyToRestore.ToUpper(); $registryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'; $propertyName = 'DisabledHotkeys'; $disabledKeys = Get-ItemProperty -Path $registryPath -Name $propertyName -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "^""$propertyName"^""; if (-Not $disabledKeys) {; Write-Host "^""Skipping: No keys has been disabled before, no need to restore `"^""$keyToRestoreInUppercase`"^""."^""; Exit 0; }; if (-Not $disabledKeys.Contains($keyToRestoreInUppercase)) {; Write-Host "^""Skipping: Key `"^""$keyToRestoreInUppercase`"^"" is not disabled. All disabled keys: `"^""$disabledKeys`"^"". No action needed."^""; Exit 0; }; $newKeysToDisable = $disabledKeys.Replace($keyToRestoreInUppercase, "^"""^""); if (-Not $newKeysToDisable) {; Write-Host "^""Removing all entries from the disabled keys as the last key `"^""$keyToRestoreInUppercase`"^"" is being restored."^""; try {; Remove-ItemProperty -Path $registryPath -Name $propertyName -Force -ErrorAction Stop; Write-Host "^""Successfully removed the `"^""$propertyName`"^"" property from the registry, no disabled keys remain."^""; Exit 0; } catch {; Write-Error "^""Failed to remove the empty `"^""$propertyName`"^"" property from the registry: $_"^""; Exit 1; }; }; try {; Write-Host "^""Restoring `"^""$keyToRestoreInUppercase`"^"", all disabled keys: `"^""$disabledKeys`"^"", new disabled keys: `"^""$newKeysToDisable`"^""."^""; Set-ItemProperty -Path $registryPath -Name $propertyName -Value "^""$newKeysToDisable"^"" -Force -ErrorAction Stop; Write-Host "^""Successfully restored `"^""$keyToRestoreInUppercase`"^"", disabled keys now: `"^""$newKeysToDisable`"^""."^""; Exit 0; } catch {; Write-Error "^""Failed to restore `"^""$keysToDisable`"^"": $_"^""; Exit 1; }"

Now that the OS is clean, I'll suggest trying three other methods.
Your feedback is important and I'll update privacy.sexy based on this. So please test these one by one and see if any of them work.

I. Limit edge

Now that your OS is clean. We can try to target Edge to limit its functionality to run Copilot and see if it works.

  1. Disable web widgets:
reg add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "WebWidgetAllowed"  /t "REG_DWORD" /d "0" /f
  1. Disable Copilot and Bing Discover in Edge:
reg add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "HubsSidebarEnabled" /t REG_DWORD /d "0" /f

You can now restart your computer and test. If they do not work, you can restore your OS back to its defaults:

reg delete "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "WebWidgetAllowed" /f 2>nul
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v "HubsSidebarEnabled" /f 2>nul

II. Remove Edge AI app

If the above does not work, we can try this. This is an undocumented app released by Microsoft, and you might not have it.

This code would remove it:

PowerShell -ExecutionPolicy Unrestricted -Command "Get-AppxPackage 'Microsoft.Windows.Ai.Copilot.Provider' | Remove-AppxPackage"

You should not have Copilot open when you run this. This will most likely do nothing, but you'd see it in cmd if it does something.

III. Test GPO manually

If none of the above works, you can follow what @hhoneeyy reported in #335. And it's about manually running GPO. I do not understand how it can resolve the issue, this GPO is set by privacy.sexy anyway (TurnOffWindowsCopilot). You can see this article (section starting with "Click Start and open the Group policy editor") and follow to set-up this GPO and see if it would work.

@baek-sang
Copy link
Author

I've done I, II, and III, but the shortcut still launches the Copilot.
Is there anything else I need to check?

@undergroundwires
Copy link
Owner

My best shot was the first setting in my first comment. All other global Windows key shortcuts are handled by taskbar.dll and explorer.exe, which reads that configuration.

As you report that it does not work, Copilot seems to be a different case, deeply integrated in some another process.

I cannot come up with more ideas, but I expect Microsoft to provide a documented setting for this to keep enterprises happy. I'm leaving this the community, there may be another solution in the wild that someone else knows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants