473,498 Members | 1,379 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 3528
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
2015
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...
13
3325
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...
2
3047
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...
1
2872
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...
2
1641
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. ***...
0
1760
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...
0
914
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
1087
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...
1
9043
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...
0
6998
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
7163
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,...
0
7200
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...
1
6884
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
5460
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3090
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...
0
1416
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 ...
0
287
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...

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.