Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Thanked 203 Times in 202 Posts

    Key Listen C#/C++

    I am trying to make a global 'hot key' for use in my SQL- I have to do a lot of scroll-to-bottom=>highlight text=>paste=>save=>close
    So my thoughts were to make two of my function keys do this so
    F4 => scroll to bottom
    ... use mouse to highlight ...
    F5 => paste,save,close

    instead of having to do ctrl + V, ctrl + S, click 'X'

    I have found 'how' to listen in C++, and I am right now thinking of doing in C++; however, I have not done C++ in a while. I was looking for something in C# but the Key enum is part of forms class and while I can make re-make it or reference the namespace, it seems like all the keyboard interaction is for use in forms. I wanted to run a background console hidden. Even the API for RegisterHotKey (or whatever it's called) is form based.

    Does anyone know if there is a C# that does not use forms?

    Along with that,
    Does anyone know the processor impact for running a form hidden VS a console hidden (if it won't cause a problem then I can just run the form hidden)

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #2
    New Coder
    Join Date
    Aug 2012
    Odessa, Ukraine
    Thanked 4 Times in 4 Posts
    I think, you will need to p/invoke a WinAPI function.
    Last edited by Bismark; 08-14-2012 at 02:15 PM.

  • #3
    New Coder
    Join Date
    Aug 2012
    Thanked 1 Time in 1 Post
    For C# you should have a look at global hooks and the getasynchkeystate() function


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts