Hack Forums
[.NET] Hotkey - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Hotkey (/showthread.php?tid=5850515)



Hotkey - Bossk - Jun 17, 2018

I'm trying to setup a simple hotkey for my app so that when the user hits CTRL + C when the app is minimized certain code will still be executed. Best and easiest way to achieve this?

(NOT DOING TIMERS)


RE: Hotkey - Nick (Name) - Jun 17, 2018

These are usually called Low Level Keyboard Hooks, there’s quite a few examples on the Internet, most of them will probably be detected as keyloggers. Here’s an old example

http://www.dylansweb.com/2014/10/low-level-global-keyboard-hook-sink-in-c-net/


RE: Hotkey - Bossk - Jun 17, 2018

(Jun 17, 2018 01:52 AM)Nick (Name) Wrote:  These are usually called Low Level Keyboard Hooks, there’s quite a few examples on the Internet, most of them will probably be detected as keyloggers. Here’s an old example

http://www.dylansweb.com/2014/10/low-level-global-keyboard-hook-sink-in-c-net/

Thank you, this was very helpful.


RE: Hotkey - Kali_Shadow - Jun 26, 2018

I don't know How to do This , But if I'm welling to do such thing I'll create a menu give it a shortcut Ctrl + C and hide it , write your code on it .
I think this is the simplest way to do it , Plus it will work as long as the form is on focus .


RE: Hotkey - debug - Jun 28, 2018

Easiest way is to use the Form KeyDown event.

PHP Code

<?php 
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
 
  if (e.Modifiers == Keys.Control && e.KeyCode == Keys.C)
 
  {
 
        // Do something
 
  }
} 



RE: Hotkey - Vyxn - Jun 29, 2018

(Jun 28, 2018 06:25 PM)debug Wrote:  Easiest way is to use the Form KeyDown event.

PHP Code

<?php 
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
 
  if (e.Modifiers == Keys.Control && e.KeyCode == Keys.C)
 
  {
 
        // Do something
 
  }
} 

It won't work if the application is not on focus just like what OP said (after minimized).