Skip to content

Commit

Permalink
Add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jsakamoto committed Jan 26, 2018
1 parent d5406d8 commit ac0095e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CtrlCEnabler.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ VisualStudioVersion = 15.0.27130.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CtrlCEnabler", "CtrlCEnabler.csproj", "{027A0D34-5D00-432C-AC73-17390F0D93C8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "README", "README", "{D5E01393-C29E-4CE5-9943-58B1CBCBD909}"
ProjectSection(SolutionItems) = preProject
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Ctrl+C Enabler for PowerShell

## Summary

This is a .NET class library that allows you to enable Ctrl+C break on PowerShell console, always.

## Why should be use this?

In some case, a PowerShell console, which is launched from Visual Studio IDE external tools menu, doesn't accept Ctrl+C.

This class library can fix it :)

## How to install in your PowerShell?

1. Download "CtrlCEnabler.dll" from [release page](releases), and save it into "%HOME%\Documents\WindowsPowerShell" folder.
2. Open the PowerShell console and enter the following command:
```powershell
PS> notepad $PROFILE
```
3. Then, the file "Microsoft.PowerShell_profile.ps1" is opened in a text editor.
4. Append lines as follows at the bottom of "Microsoft.PowerShell_profile.ps1", and save it.
```powershell
# Enable Ctrl+C force.
Add-Type -Path "$env:HOME\Documents\WindowsPowerShell\CtrlCEnabler.dll"
[CtrlCEnabler]::EnableCtrlC() > $null
```

After this instruction, the PowerShell console always enables Ctrl + C break, even when launched from Visual Studio's external tools menu.

## How does it work?

This class library just calls the `SetConsoleCtrlHandler` Win32 API.

```csharp
public static bool EnableCtrlC()
{
return SetConsoleCtrlHandler(null, false);
}
```

See also:

- https://docs.microsoft.com/en-us/windows/console/ctrl-c-and-ctrl-break-signals
- https://docs.microsoft.com/en-us/windows/console/setconsolectrlhandler

## LICENSE

[The Unlicense](LICENSE)

0 comments on commit ac0095e

Please sign in to comment.