Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

c# key sequence

Comments

  • Registered Users, Registered Users 2 Posts: 2,082 ✭✭✭Tobias Greeshman


    The problem with the key combination Ctrl+Pause/Break is that it's a special key combination that get triggered before the KeyDown handler gets access to it. It will terminate/pause a program in execution.

    There is a way to get around this, by means of what is called a Keyboard Hook.

    Have a look at the Win API Function SetWindowsHookEx

    Example: http://delphi.about.com/library/bluc/text/uc063001a.htm


  • Registered Users, Registered Users 2 Posts: 362 ✭✭theone


    Thanks for that

    I'm using it to send a break to a serial device, I could simulate that key sequence by changin the com port settings then simulating the spacebar being held down,but doing it by just simulating the key sequence is a much more efficient way of doing it.

    I'll check it out thanks.


  • Registered Users, Registered Users 2 Posts: 362 ✭✭theone


    got it to work once hasn't worked since though

    SendKeys.SendWait("^{BREAK}");

    thats under a button click event

    that simulates ctrl +pause/break,I'm guessing thats where the hook comes in,but if it worked once can't understand why it won't work again.


Advertisement