Home > Back-end >  How use Delphi to an existing web page within a text box assignment or extract the text frame's
How use Delphi to an existing web page within a text box assignment or extract the text frame's

Time:12-08

How use Delphi to an existing web page within a text box assignment or extract the text frame's text

For example, an existing need input student information website, I have a large number of student information need to entry (tens of thousands of article), but don't want to a one entry, can want to write a program to make it automatic input the information, after the student information input, the website will be returned to the legacy information such as the degree of students (also is in the inside of the text box), the program can also obtain these text boxes inside the text,
I tried to simulate keystrokes + Clipboard method, but often there will be a Clipboard "always open a Clipboard" this mistake, can't solve, could you tell me how to achieve within the existing web page or a text box assignment to extract the text frame's text? Had better have code examples, please comment, thank you very much!!!!!

CodePudding user response:

Did try, can only manual mode, put forward the automation of the building Lord seen,

Methods:
1, the mouse move to get the browser text box, handle,
2, through the handle for text information; Read in the clipboard,
3, written to the database,

Note that some web sites, the text box to make image form, is the key to the text data is read,

CodePudding user response:

With Delphi browser control, open the web page, so you can call or perform JS script, specific what to do, your own analysis of the inside of the web page HTML

CodePudding user response:

Use webbrowser open your site
WebBrowser1. Navigate (' http://www.baidu.com ');

 WebBrowser1. OleObject. Document. GetElementById (' ABC '). The value:='ABC'; 
ShowMessage (WebBrowser1 OleObject. Document. GetElementById (' ABC '). The value).

CodePudding user response:

Fill in the id of the getElementById is page id of the input box

CodePudding user response:

The function TForm1. Keystroke (S1: String) : String;//-- -- -- -- -- -- -- -- -- -- - simulate keystrokes
Var
TempStr: String;
The begin

Clipboard. AsText:=S1;

Setcursorpos (pt. X, pt. Y);
,0,0,0 mouse_event (MOUSEEVENTF_LEFTDOWN, 0);//-- -- -- -- -- -- -- -- -- -- - left-click the mouse
,0,0,0 mouse_event (MOUSEEVENTF_LEFTUP, 0);
Sleep (50);
,0,0,0 mouse_event (MOUSEEVENTF_LEFTDOWN, 0);//-- -- -- -- -- -- -- -- -- -- - left-click the mouse
,0,0,0 mouse_event (MOUSEEVENTF_LEFTUP, 0);

Keybd_event (VK_CONTROL, 0, 0);
Keybd_event,0,0,0 (86);
KEYEVENTF_KEYUP keybd_event (86, 0, 0);//Ctrl + V
Keybd_event (KEYEVENTF_KEYUP VK_CONTROL, 0, 0);

Setcursorpos (pt. X + 30, pt. Y + 50);
,0,0,0 mouse_event (MOUSEEVENTF_LEFTDOWN, 0);//-- -- -- -- -- -- -- -- -- -- - left-click the mouse
,0,0,0 mouse_event (MOUSEEVENTF_LEFTUP, 0);

Sleep (StrToint (Edit2. Text));//pause

Keybd_event (VK_TAB, 0, 0);
Keybd_event (KEYEVENTF_KEYUP VK_TAB, 0, 0);//-- -- -- -- -- -- -- -- -- -- -- -- the TAB
Sleep (100);

Keybd_event (VK_CONTROL, 0, 0);
Keybd_event,0,0,0 (67);
KEYEVENTF_KEYUP keybd_event (67, 0, 0);//Ctrl + C
Keybd_event (KEYEVENTF_KEYUP VK_CONTROL, 0, 0);
Sleep (100);

Result:=Clipboard. AsText;

end;

CodePudding user response:

The original poster is a bit complicated to the! 3rd floor of the method is feasible. Direct execution js code!

CodePudding user response:

This is a batch collection work, in addition to technical issues, there is the question of efficiency.
  • Related