当前位置: 动力学知识库 > 问答 > 编程问答 >

c# backspace simulator - deletes entire word instead of just a letter?

问题描述:

I am writing a simple C# program in which when I press "ctrl+g" I want my program to automatically delete the character directly left of the cursor in any program (ex: chrome browser, word document, powerpoint document, etc...).

I have installed a global hook for "ctrl+g" and it works fine. I am using a keyboard simulator that I found from codeproject: http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library

My issue is that when I simulate a backspace like so:

KeyboardSimulator.KeyPress(Keys.Back);

the entire word is deleted instead of just the character to the left of the cursor. For example, if I am in a Microsoft Word document with the following line of text:

"Happy new year"

if my cursor is at the end of "year" and I press ctrl+g, my program deletes "year" and puts the cursor just to the right of "new" instead of just deleting the letter "r" of "year".

I have tried other simulators as well with the same result. Does anyone have a solution or know what I am doing incorrectly?

Thanks.

网友答案:

Apparently, Ctrl+Backspace commonly means delete the entire word in Windows. When you press Ctrl+g, and your hook simulates the back space key, the program sees Ctrl+Backspace because the Ctrl is down.

分享给朋友:
您可能感兴趣的文章:
随机阅读: