“Ctrl + C” buttons pressed handle C# console app

2019-04-08 01:59发布

How can I handle two buttons pressed simultaneously ('Ctrl' + 'C'), not in the WindowsForms application, but in console C# application?

2条回答
smile是对你的礼貌
2楼-- · 2019-04-08 02:43

I suspect you want to set Console.TreatCtrlCAsInput to true. (Assuming you don't want this to terminate the app.)

查看更多
聊天终结者
3楼-- · 2019-04-08 02:51

Check out Console.TreatControlCAsInput property;

Gets or sets a value indicating whether the combination of the Control modifier key and C console key (Ctrl+C) is treated as ordinary input or as an interruption that is handled by the operating system.

查看更多
登录 后发表回答