I'm develloping for Windows Mobile 6 (HTC TYTN II) in C# .NET 2.0
Information:
I defined a windows keyboard hook, so my application listens to all key hits.
When one specific key is hit a method is called. This method invokes a ctrl+c keystroke.
Expand|Select|Wrap|Line Numbers
- keybd_event(0x11, 0, 0, 0);// press
- keybd_event(0x43, 0, 0, 0); // press
- keybd_event(0x43, 0, 2, 0); //release;
- keybd_event(0x11, 0, 2, 0); //release ctrl
Expand|Select|Wrap|Line Numbers
- IDataObject iData = Clipboard.
- // Determines whether the data is in a format you can
- if (iData.GetDataPresent(DataFormats.Text))
- {
- //Yes it is, so display it in a text box.
- tbClipboard.Text = "Calling: " + (String)iData.GetData(DataFormats.Text);
- }
Problem:
Thiss works almost perfect except that the data shown in the textbox is always the previously copied value.
example:
1. I select: "MyText"
2. I Copy
3. Nothing appears in the textbox
6. I select: "BlaBla"
7. I Copy
8. "MyText" is shown in the textbox
9. I select: "foo"
10. I copy
11. "BlaBla" is shown
...
it's always a step behind
Solutions I tried:
- use different threads for copy and paste
- place Application.DoEvents between copy and paste
- use AutoResetEvent to make sure the copy is finished before the paste
all without result
Remarks:
When the copy has finished (keybd_event), and I tab ctrl+v on the soft input panel, I get the correct value.
Who can help me solving this annoying issue?
Thanks for time and effort;
Regards
W.