473,549 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change the output of a keyboard press?

2 New Member
Hey there! I'm preparing a 1st of april- joke for my roomate and decided I wanted to create a little hidden program that would take control of the user's keyboard.

So for example, when you press on 'a' you don't really get an 'a' on the screen, rather its supposed to be changed to a random letter.

So far: I have successefully hooked the keyboard to my application and I can read all keystrokes that are pressed. But i'm unable to change the "resulted" keystroke...

Uhm, sorry if i havnt given enough information, if so. Please let me know!
Mar 27 '11 #1
2 3534
Sfreak
64 New Member
Karl,

The following code may help you

On event KeyDown
Expand|Select|Wrap|Line Numbers
  1.  
  2. if (e.KeyCode == Keys.Enter)
  3. {
  4.     SendKeys.Send("{TAB}");
  5. }
Where tab is the name of the key
This case when the user hits Enter i send TAB
Mar 30 '11 #2
Karl Johansson
2 New Member
Thank you for your reply. I'm sorry It seems I have not supplied with enough information.
--

I want it to have "Full" control of all running applications and replacing the input key with a new key.

What I want to do is kinda like:

Expand|Select|Wrap|Line Numbers
  1. // this is just a pseudo code
  2. // ---
  3. // just a list of pressed keys
  4. // GetPressedKeys() Can be iterated with a function using like GetAsyncKeyState();
  5. var pressedKeys = GetPressedKeys(); 
  6. foreach(var pKey in pressedKeys)
  7. {
  8.     // Disables the output/Ignores the keypress by
  9.     // any running processes.
  10.     pKey.Cancel = true; 
  11.  
  12.     var hwnd = GetForegroundWindow();
  13.     var randomKey = GetRandomKey();
  14.     KeyboardUtility.SendKey(hwnd, randomKey);
  15. }
  16.  
Anyone aware of how this could be possible?
Mar 31 '11 #3

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

Similar topics

13
2026
by: FlickChick | last post by:
I don't usually post questions, but 2 days of googleing and frustration have broken my resistance. I have some scary looking xml that looks something like this: <?xml version="1.0"?> <foo xmlns='urn:xxx:yyy'> <stuff type="why"> <morestuff type="do"> <evenmore>
13
3329
by: Ole Hanson | last post by:
Hi I am in need of a way to launch my WinForms-app (app.exe) just by pressing a keyboard combination like (Ctrl-Alt-P). This functionality should be present "out of the box" after the app (app.exe) is deployed on the Client's PC. The only way I know - is to place a shortcut on the desktop and associate a "ShortCut Key" to it by...
2
3052
by: Gwl | last post by:
I'm writing an application in which the user can change the default ouput language while the program is running. I have no problem to do it when there is only a form opened, but if I have a situation like a second form opened I don't know how I could change the otuput language in the main form and in all the background forms. Any advice? ...
1
2878
by: Lacka | last post by:
Hi, Is it possible, to change the keyboard layout on an asp.net page? I have two textboxes: one for the greek text, and one for the hungarian. If the greek gets the focus, it would be nice to change to the greek keyboard layout, and when the other, to the hungarian. Is it possible, or not? (I know, that in a normal Windows application it is...
2
1645
by: ahmed ahmed | last post by:
VB.NET hi i'm asking about How To Change System Keyboard langauge from the VB.NET or Keyboard langauge from langauge to another without the API function. and thanks about helping me. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
0
1767
by: Freddy | last post by:
In my Access db (which I have created to help me learn Greek) I am using text box controls on a form. Some of these controls require English input and some require Greek input. Currently I have to keep toggling the keyboard input language bar settings manually from the keyboard whenever I wish to switch languages - this is a real pain. ...
0
916
by: dotnettester | last post by:
Hi, I am trying to change the output folder on an application. Instead of //myserver/myapplication/bin I want the output of build to be written on //myserver/bin
0
1095
by: Peter | last post by:
Hi Is it possible to change the output name of a assembly dynamicly e.g. by code (#define) I use #define and #if direktive and the assembly name shall be depend of the define. The Code Classname etc in Setting1 is similar to Setting2, but I will not use inheritance or different classes because the generated dll may not contain the...
1
9059
by: MBMSOFT | last post by:
Any idea how to change system keyboard language with vba I tried changing keyboard property in the control property and it works but i need change in one control only, and if i change property it change for all contols after so i need code on exit control event to change the system keyboard language \e.g....
0
7546
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7740
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7985
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7830
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1082
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
784
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.