Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. [SOLVED] I need to copy (CTRL+C) a web page... C++ [modified]

[SOLVED] I need to copy (CTRL+C) a web page... C++ [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++htmldesignjson
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ram Shmider
    wrote on last edited by
    #1

    Hi All, I am tring to write an application that open a web page and Copy its data to the clipboard. I know i can use function to httpRead the page into a buffer, but in this case i have all the html's tags and i do not need them, if i use copy (CTRL+C) i am able to only get the text. I thought to open an IE process with the url as parameter and then use the SendMessage API with the process handle and the CTRL+A as the message and then CTRL+C as the message (hopefully it will generate a Select All and Copy). If this works would it be able to work when the user is logout (no visible UI). Love to hear your thought about it, i am working with C++ or C# on windows. Thanks a lot for your time, Ram.

    modified on Wednesday, April 20, 2011 2:11 AM

    _ N 2 Replies Last reply
    0
    • R Ram Shmider

      Hi All, I am tring to write an application that open a web page and Copy its data to the clipboard. I know i can use function to httpRead the page into a buffer, but in this case i have all the html's tags and i do not need them, if i use copy (CTRL+C) i am able to only get the text. I thought to open an IE process with the url as parameter and then use the SendMessage API with the process handle and the CTRL+A as the message and then CTRL+C as the message (hopefully it will generate a Select All and Copy). If this works would it be able to work when the user is logout (no visible UI). Love to hear your thought about it, i am working with C++ or C# on windows. Thanks a lot for your time, Ram.

      modified on Wednesday, April 20, 2011 2:11 AM

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      Ram Shmider wrote:

      and i do not need them, if i use copy (CTRL+C) i am able to only get the text.

      Can you parse the HTML content using some class for ex: HTML Reader C++ Class Library[^]

      You talk about Being HUMAN. I have it in my name AnsHUMAN

      R 1 Reply Last reply
      0
      • R Ram Shmider

        Hi All, I am tring to write an application that open a web page and Copy its data to the clipboard. I know i can use function to httpRead the page into a buffer, but in this case i have all the html's tags and i do not need them, if i use copy (CTRL+C) i am able to only get the text. I thought to open an IE process with the url as parameter and then use the SendMessage API with the process handle and the CTRL+A as the message and then CTRL+C as the message (hopefully it will generate a Select All and Copy). If this works would it be able to work when the user is logout (no visible UI). Love to hear your thought about it, i am working with C++ or C# on windows. Thanks a lot for your time, Ram.

        modified on Wednesday, April 20, 2011 2:11 AM

        N Offline
        N Offline
        Nitheesh George
        wrote on last edited by
        #3

        Hi Ram, This is possible and your thinking is correct. Only you need is to get focus to the browser control then simulate the Ctrl+A and Ctrl+C using SendInput API. So in your code you need to wait for the browser window to appear and find the browser control then give focus to that by sending SetFocus. now simulate the keystrokes. But there always a chance for something unexpected results since any other window activation will make your task difficult. hope this helps Nitheesh George http://www.simpletools.co.in

        R 1 Reply Last reply
        0
        • N Nitheesh George

          Hi Ram, This is possible and your thinking is correct. Only you need is to get focus to the browser control then simulate the Ctrl+A and Ctrl+C using SendInput API. So in your code you need to wait for the browser window to appear and find the browser control then give focus to that by sending SetFocus. now simulate the keystrokes. But there always a chance for something unexpected results since any other window activation will make your task difficult. hope this helps Nitheesh George http://www.simpletools.co.in

          R Offline
          R Offline
          Ram Shmider
          wrote on last edited by
          #4

          Thanks a lot for the help, it realy helps... by using SendInput i was able to solved it. This is a the part code i use...(C++) INPUT input; input.type = INPUT_KEYBOARD; // ctrl down input.ki.wVk = VK_LCONTROL; input.ki.dwFlags = 0; SendInput(1, &input, sizeof(INPUT)); Sleep(50); // C down input.ki.wVk = 'C'; SendInput(1, &input, sizeof(INPUT)); Sleep(50); // C up input.ki.dwFlags = KEYEVENTF_KEYUP; SendInput(1, &input, sizeof(INPUT)); Sleep(50); // Ctrl up input.ki.wVk = VK_LCONTROL; SendInput(1, &input, sizeof(INPUT)); Sleep(50); To simulate the CTRL+A just update this part to 'A' // A down input.ki.wVk = 'A'; SendInput(1, &input, sizeof(INPUT)); Sleep(50); Again, Thanks a lot for the help. Ram.

          1 Reply Last reply
          0
          • _ _AnsHUMAN_

            Ram Shmider wrote:

            and i do not need them, if i use copy (CTRL+C) i am able to only get the text.

            Can you parse the HTML content using some class for ex: HTML Reader C++ Class Library[^]

            You talk about Being HUMAN. I have it in my name AnsHUMAN

            R Offline
            R Offline
            Ram Shmider
            wrote on last edited by
            #5

            Thanks for the replay.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups