473,395 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

keybd_event strange behaviour

19
Hi devs

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
  1. keybd_event(0x11, 0, 0, 0);// press 
  2. keybd_event(0x43, 0, 0, 0); // press 
  3. keybd_event(0x43, 0, 2, 0); //release;
  4. keybd_event(0x11, 0, 2, 0); //release ctrl 
After this keystroke, I one to get the copied text from te clipboard using this code:

Expand|Select|Wrap|Line Numbers
  1. IDataObject iData = Clipboard.
  2.  
  3. // Determines whether the data is in a format you can 
  4. if (iData.GetDataPresent(DataFormats.Text))
  5. {
  6.      //Yes it is, so display it in a text box.
  7.      tbClipboard.Text = "Calling: " + (String)iData.GetData(DataFormats.Text);
  8. }

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.
Jan 25 '08 #1
0 1281

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: chella | last post by:
ok. I have finally got to the point where Im about to give up on that... I thought maybe you guys can help I have an ascii code (suppose 65 for the letter 'A') and have to use the function...
3
by: bradfordh | last post by:
I cannot seem to get this to work. How do I use this (or should I be using SendInput() ) to send keystrokes to Iapplications/games? I know I need to use a getfocus function. For instance, I could...
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
6
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
31
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
1
by: roshan | last post by:
All, Hello. I am a Software Developer currently creating an emulation program for our company's System Administrator. He will be able to call the program and emulate any keyboard combination,...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
20
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code -----------------------------------...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.