Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB6 Replace Keystroke
#1
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'
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#2
You can try using SendKeys... Big Grin
I'd knock on wood, but my desk is particle board.
Reply
#3
does that replace it or just add to it?

so if I type 'a' would it spit out 'ab'?
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#4
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]
Reply
#5
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');
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)