Solved

Transfer text from Explorer to Notepad

Posted on 1998-11-06
2
170 Views
Last Modified: 2013-11-20

I want to design a program which can do such things.

In Microsoft Internet Explorer, I make a selection of text.
After I press the Ctrl-C (or other), the text selection be
transfered or insert to Notepad automatically.
That means it does not need me to cut and to paste text from one program to another.
What should I do.

Will it use the hook programming technique?

Thanx in advance
0
Comment
Question by:murphylee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 1324317
Hooking would definitely make life easier, e.g. something like this:

BOOL CALLBACK FindCreatedTask( HWND hwnd, LPARAM lParam);

DWORD   g_dwState;
HWND    g_hwnd;

// This is a WH_GETMESSAGE hook
LRESULT CALLBACK HookProc   (   int     nCode,  // hook code
                                WPARAM  wParam, // removal flag
                                LPARAM  lParam  // address of structure with message
                            )
{
    PMSG    pmsg    =   ( PMSG) lParam;

    if  (   0   >   nCode   ||  PM_NOREMOVE ==  wParam)
        {
            return  (   CallNextHookEx  (   g_hhk,
                                            nCode,
                                            wParam,
                                            lParam
                                        )
                    );
        }

    if  (       WM_KEYDOWN  ==  pmsg->message  
        )
        {
            /* this one is for us, so check key state & app*/
            if  (       !strstr (   GetCommandLine  (), "IEXPLORE.EXE")
                    &&  0x80000000 & GetKeyState    (   VK_CONTROL)
                    &&  0x80000000 & GetKeyState    (   'c') //see winuser.h
                )
                {
                    g_dwState   =   STATE_CTRL_C_PRESSED;

                    PostMessage (   pmsg->hwnd, WM_COPY,    0,  0L);
                }
        }

    if  (       WM_COPY ==  pmsg->message
            &&  STATE_CTRL_C_PRESSED    ==  g_dwState
        )
        {
            g_dwState   =   STATE_WM_COPY_RECEIVED;

            return  (   CallNextHookEx  (   g_hhk,
                                            nCode,
                                            wParam,
                                            lParam
                                        )
                    );
        }

    if  (   STATE_WM_COPY_RECEIVED  ==  g_dwState)
        {
            STARTUPINFO si;
            PROCESS_INFORMATION pi;

            ZeroMemory  (   &si,    sizeof  (   STARTUPINFO));

            if  (   CreateProcess   (   "notepad.exe",...)) //  notepad is running
                {
                    g_hwnd  =   NULL;

                    EnumWindows (   FindCreatedTask,    ( LPARAM) pi.dwProcessId));

                    // copy text
                    if  (   g_hwnd)
                            PostMessage (   g_hwnd, WM_PASTE,   0,  0L);

                    g_dwState   =   STATE_INITIAL;
                }
        }

    return  (   CallNextHookEx  (   g_hhk,
                                    nCode,
                                    wParam,
                                    lParam
                                )
            );
}

BOOL CALLBACK FindCreatedTask( HWND hwnd, LPARAM lParam)
{
    DWORD   dwPID2Find  =   ( DWORD) lParam;
    DWORD   dwPID       =   0;

    if  (   GetWindowThreadProcessId    (   hwnd,   &dwPID))
        {
            if  (   dwPID   ==  dwPID2Find)
                {
                    g_hwnd  =   hwnd;

                    return  (   FALSE);
                }
        }

    return  (   TRUE);
}
 

0
 
LVL 86

Expert Comment

by:jkr
ID: 2031985
comment
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Looking for a specific application/software 2 124
abstract class with all non abstract mentods 6 87
Problem to App source 6 120
moto 4g phone enable finger print 4 73
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question