[SOLVED] I need to copy (CTRL+C) a web page... C++ [modified]
-
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
-
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
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
-
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
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
-
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
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.
-
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
Thanks for the replay.