Trying to get program to recognize keys pressed.

Jul 15, 2010 at 3:27am
I'm making a automatic spell checker program but it doesn't work as planned. I got it to work once but it would change all I's and not just I's that need capitalization. I talked to a friend and he said look into buffers. I'm running a 32-bit Vista. Compiled with Dev-C++ 2.9.9.2. Any help whatsoever would be most appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <windows.h>
//#include <iostream>


void SendKey (char Vk) 
{
char VkKey = VkKeyScan(Vk);
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VkKey, 0, 0, 0); 
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VkKey, 0, KEYEVENTF_KEYUP, 0);
}



int main()
{

while(1)
{
        restart:
    if (GetAsyncKeyState(0x20)) {
       if (GetAsyncKeyState(0x329)) {
          if (GetAsyncKeyState(0x20)) {
   
       keybd_event(VK_BACK,0,0,0); // Press Backspace
       keybd_event(VK_BACK,0, KEYEVENTF_KEYUP, 0);
       
       keybd_event(VK_BACK,0,0,0); // Press Backspace
       keybd_event(VK_BACK,0, KEYEVENTF_KEYUP, 0); 
       
       SendKey('a'); // For testing purposes only.
        
       //keybd_event(0x330,0,0,0); // Type "I"
       //keybd_event(0x330,0, KEYEVENTF_KEYUP, 0);
       
       
       keybd_event(VK_SPACE,0,0,0); // Press Spacebar
       keybd_event(VK_SPACE,0, KEYEVENTF_KEYUP, 0);
        
          } else if (!GetAsyncKeyState(0x20)) {goto restart;}
          
       } else if (!GetAsyncKeyState(0x329)) {goto restart;}
       
    } else if (!GetAsyncKeyState(0x20)) {goto restart;}
    
   else {goto restart;} 
}    
    return 0;
}
Last edited on Jul 15, 2010 at 3:27am
Jul 15, 2010 at 8:15am
try posting in the windows programming section
Jul 16, 2010 at 3:45am
closed account (D80DSL3A)
Why should he post in the windows programming forum? That's a console app. up there!
Jul 16, 2010 at 4:36am
But the functions being used are Windows-dependent.
Topic archived. No new replies allowed.