ok here is exactly what Im trying to do,

I have to insert 10 strings in 10 different textboxes in the shortest possible time (half a second counts), so I thought the best way is to store them all in a program before the timer starts and then simply press TAB 10 times when the timer starts, and my application would paste them each in a separate text box...
so I want it to paste it on the old focused control then move to the other control ...
After help of some friends, I got this code

#include <windows.h>
#include <stdio.h>
int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nFunsterStil)

{
HWND hWnd;
    for(;;)
    {
        MSG Msg;
        while(GetMessage(&Msg, NULL, 0, 0)){
            if(Msg.message == WM_KEYUP && Msg.wParam == VK_TAB){
                PostMessage(Msg.hwnd, WM_PASTE, 0, 0);
                printf("K\n"); //Never shows this == not entering the if statment ... why ?
                // you might need to try GetFocus() instead of Msg.hwnd
            }              
            if(!IsDialogMessage(hWnd, &Msg)){
                TranslateMessage(&Msg);
                DispatchMessage(&Msg);
            }
        }
    }
    return 0;
}

the code is never entering the If statment, even when I press TAB
I tried adding printf("test\n"); to check, it never shows

why is it not entering the If Statment ?

Recommended Answers

All 5 Replies

printf() can not be used to display text in a MS-Windows GUI program because there is no console window. Depending on your compiler the simplest way to test it is to compile for debug then set a breakpoint on the printf() line. Another alternative is to create a console window then output text to it (see the console win32 api functions).

no only printf is not working, but PostMessage is also not working ...
do you have any idea why ?

Is the code you posted only a tiny part of some much larger windows gui program ? According to the code you posted PostMessage() doesn't work because there is no window.

Post the complete code you have. If it is large, zip it and attach the zipped file.

no, this is the code, and I need help completing it...
how can I make a window? and why do i need it,
I dont want to create any text box ... I want to capture the tab press where ever it is pressed (my case on a website running by firefox) and when the tab is pressed I want to paste the clipboard and move to the next text box...

how can I do this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.