Click here to Skip to main content
15,919,358 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Pass class member function as paramter? Pin
Todd Smith28-Mar-02 8:02
Todd Smith28-Mar-02 8:02 
AnswerRe: Pass class member function as paramter? Pin
soptest27-Mar-02 8:51
soptest27-Mar-02 8:51 
AnswerRe: Pass class member function as paramter? Pin
Jim Crafton27-Mar-02 10:50
Jim Crafton27-Mar-02 10:50 
GeneralHistory list in browser window Pin
Aaron Schaefer27-Mar-02 6:24
Aaron Schaefer27-Mar-02 6:24 
Generalsending keystrokes to window Pin
vins27-Mar-02 5:14
vins27-Mar-02 5:14 
GeneralRe: sending keystrokes to window Pin
Tim Deveaux27-Mar-02 6:12
Tim Deveaux27-Mar-02 6:12 
GeneralRe: sending keystrokes to window Pin
vins27-Mar-02 6:22
vins27-Mar-02 6:22 
GeneralRe: sending keystrokes to window Pin
Tim Deveaux27-Mar-02 7:41
Tim Deveaux27-Mar-02 7:41 
Ok - here is the example I posted, which should be made into a SendKeys type function. Here I hardcoded a known window handle - (Calculator).

Basically, the trick is to post messages for keydown and keyup, and its nice to format the lparam properly.

// Console.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "crtdbg.h"
#include "conio.h"
#include "windows.h"
#include "winbase.h"
 
 
int main(int argc, char* argv[])
{
    HWND    hwnd = (HWND)  0x025c;
     
    INT Vk;
    INT Scan;
    CHAR character[2];
    CHAR oemchar[2];
    CHAR ch;
    do {
        while(!_kbhit());
        ch = getch();
        
        character[0]=ch;
        character[1]='\0';
        
        // Get the virtual key code for this character
        Vk = VkKeyScan(character[0]) & 0xFF;  
        CharToOem(character, oemchar);
        
        // Get the scan code for this key
        Scan = OemKeyScan(oemchar[0]) & 0xFF;
        
        // show the key:
        printf("Key = %c, VK code = %d, scan = %d\n", ch, Vk, Scan);
        
        UINT    lKeydata = 0;
 
        UINT    mask = 1;
        lKeydata |= mask;         // repeat count of 1;
        lKeydata |= Scan << 15;   // not really necessary for most apps
         
        ::PostMessage(hwnd, WM_KEYDOWN, Vk, lKeydata);
         
        lKeydata |= mask;         // repeat count of 1;
        lKeydata |= Scan << 15;
        lKeydata |= mask << 31;   // transition (fUp) is 1 for key up.
         
        ::PostMessage(hwnd, WM_KEYUP, Vk, lKeydata);
    }
    while(1);
    return 0;
}

GeneralRe: sending keystrokes to window Pin
vins27-Mar-02 8:16
vins27-Mar-02 8:16 
QuestionHow do I determine what functions a dll are exporting? Pin
Tommy Svensson27-Mar-02 5:03
Tommy Svensson27-Mar-02 5:03 
AnswerRe: How do I determine what functions a dll are exporting? Pin
Chris Losinger27-Mar-02 5:27
professionalChris Losinger27-Mar-02 5:27 
GeneralRe: How do I determine what functions a dll are exporting? Pin
Tommy Svensson27-Mar-02 6:08
Tommy Svensson27-Mar-02 6:08 
AnswerRe: How do I determine what functions a dll are exporting? Pin
Paul M Watt27-Mar-02 5:48
mentorPaul M Watt27-Mar-02 5:48 
GeneralRe: How do I determine what functions a dll are exporting? Pin
Tommy Svensson27-Mar-02 6:16
Tommy Svensson27-Mar-02 6:16 
GeneralRe: How do I determine what functions a dll are exporting? Pin
Tommy Svensson27-Mar-02 6:36
Tommy Svensson27-Mar-02 6:36 
GeneralRe: How do I determine what functions a dll are exporting? Pin
Paul M Watt27-Mar-02 9:03
mentorPaul M Watt27-Mar-02 9:03 
GeneralRe: How do I determine what functions a dll are exporting? Pin
Tommy Svensson1-Apr-02 21:49
Tommy Svensson1-Apr-02 21:49 
GeneralRe: How do I determine what functions a dll are exporting? Pin
Tomasz Sowinski27-Mar-02 10:24
Tomasz Sowinski27-Mar-02 10:24 
AnswerRe: How do I determine what functions a dll are exporting? Pin
JT Anderson27-Mar-02 6:04
JT Anderson27-Mar-02 6:04 
AnswerRe: How do I determine what functions a dll are exporting? Pin
sanjay mishra2-Apr-02 0:35
sanjay mishra2-Apr-02 0:35 
GeneralCOleVariant's and globally unique ID's Pin
funbag27-Mar-02 4:40
funbag27-Mar-02 4:40 
GeneralRetrieve pointer of the view into Mainframe Pin
27-Mar-02 4:20
suss27-Mar-02 4:20 
GeneralRe: Retrieve pointer of the view into Mainframe Pin
Mazdak27-Mar-02 7:01
Mazdak27-Mar-02 7:01 
GeneralRe: Retrieve pointer of the view into Mainframe Pin
Mazdak27-Mar-02 7:02
Mazdak27-Mar-02 7:02 
GeneralProfiling - weird problem. Pin
Alex Deem27-Mar-02 4:11
Alex Deem27-Mar-02 4:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.