954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Tracking Clipboard Paste

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 ?

perito
Newbie Poster
3 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

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).

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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

perito
Newbie Poster
3 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

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?

perito
Newbie Poster
3 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You