Auto Text Highlighter

My AutoTextHighlighter app in C# gave me trouble for a little while when I use it in Windows 7 desktop. Was I using Vista before?

Short story version:

1. http://stackoverflow.com/questions/2346281/vb-net-sendkeys-letters-duplicate

2. http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait.aspx

3. http://msdn.microsoft.com/en-us/library/ms184658.aspx

4. Be sure to keep the app.config (*.exe.config) file next to the exe app.

Long Story version:

SendKeys.SendWait was doing unpredictable repeats ({ENTER} key). It turns out Microsoft was aware of it and blames it on .NET Framework 3.0 timing issues. Before this, I had lost the latest source code for my application due to Desktop HDD reformat/upgrade. So I used JetBrain dotPeek to disassemble my exe file. After that, there was a Callback issue with "garbage collected delegate...invoke" stuff. I had no idea and no time. So I fixed it via comments on the site of the globalkeyboardhook script:

you have no reference of the callback-method.
  After:
public delegate int keyboardHookProc(int code, int wParam, ref keyboardHookStruct lParam);
just add a new line with:
private keyboardHookProc _keyboardHookProc;
And in function "hook" you have to change code to:
hInstance = LoadLibrary("User32"); _keyboardHookProc = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, _keyboardHookProc, hInstance, 0);

Then, the source code is fully back. To fix the SendKeys.SendWait issue, I have to add:
<appSettings>
<add key="SendKeys" value="SendInput"/>
</appSettings>

to my app.config file. This is in the Solution Explorer -> program name-> app.config. Just before the text </configuration>.

After the build, in bin folder, there is another *.exe.config file which is the same as app.config. I made sure both exe and exe.config files are together. Perhaps it could release both files as one single exe file, but I don't have time to find that out now.

This entry was posted in Technical. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

ERROR: si-captcha.php plugin: GD image support not detected in PHP!

Contact your web host and ask them to enable GD image support for PHP.

ERROR: si-captcha.php plugin: imagepng function not detected in PHP!

Contact your web host and ask them to enable imagepng for PHP.

This site uses Akismet to reduce spam. Learn how your comment data is processed.