Posts: 2,765
Threads: 138
Joined: Nov 2002
Hiya! I know how to get a keystroke from anywhere but how do I replace it with soemthing?
Like I type
a
but it shows up
b
Thanks!
EDIT: BTW this is anywhere
So if I type 'a' in the address bar it says 'b'
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,279
Threads: 170
Joined: Nov 2003
You can try using SendKeys...
I'd knock on wood, but my desk is particle board.
Posts: 2,765
Threads: 138
Joined: Nov 2002
does that replace it or just add to it?
so if I type 'a' would it spit out 'ab'?
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 320
Threads: 9
Joined: Dec 2004
If you write a keyboard hook, then you should in theory be able to change the value of the keypress. In your windows hook function, you will be passed information about the key that was pressed. If you modify this value, then call CallNextHookEx with the modified value, then return 0 from your routine, the target window should end up receiving your modified value.
I'm not sure whether this would work, but it's worth a shot.
-shiftLynx
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Posts: 358
Threads: 15
Joined: May 2003
EDIT::: Sorry...I didn't read the subject and didn't realize this was a VB6 Question...please ignore my response. Mango
Quote:Hiya! I know how to get a keystroke from anywhere but how do I replace it with soemthing?
Like I type
a
but it shows up
b
Thanks!
EDIT: BTW this is anywhere
So if I type 'a' in the address bar it says 'b'
well...if you add 1 to the value of the keystroke, it should do what you want. However, based on your EDIT, i'm not sure I get what you're after.
Code:
#include <windows.h>
#include <iostream>
using namespace std;
int main() {
CHAR buffer[1] = "";
DWORD w;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE keyboard = GetStdHandle(STD_INPUT_HANDLE);
INPUT_RECORD input[1];
do {
// Read an input record.
ReadConsoleInput(keyboard, input, 1, &w);
// Process a key down input event.
if (input[0].EventType == KEY_EVENT
&& input[0].Event.KeyEvent.bKeyDown) {
// Retrieve the character that was pressed.
buffer[0] = input[0].Event.KeyEvent.uChar.AsciiChar;
buffer[0] += 1;
// Echo this character to the middle of the console.
WriteConsoleOutputCharacter(console, buffer, 1,
(COORD){35, 12}, &w);
}
} while (buffer[0] != 'x');
}