Home > Software engineering >  VB how to realize the automatic fill out (in the third party software text box to fill in)
VB how to realize the automatic fill out (in the third party software text box to fill in)

Time:11-30



Write B program, how to implement the following functions?
1. Click on the "complete", the "application B" ABCD the contents of the text box, automatically fill in to "A software" ABCD text box, corresponding,
2. Click on "remove", "A software" ABCD text box capacity,

Each great god! The younger brother, online waiting for...

CodePudding user response:

The simplest, sendkeys function was used to simulate keyboard to keyboard input to the activated form, if you want to simulate the mouse operation, you need to obtain specific to operate with Windows API to send the coordinates of the mouse operation messages,
To gm, is called a series of windowsAPI, first find the need to manipulate the window handle, and then in this form to find the specific input box handle, finally sends a message to the input box to adjust the content,

Suggest try the sendkeys can solve your problem,

https://www.cnblogs.com/demonxian3/p/6263948.html

CodePudding user response:

To obtain input box handle should be the most simple

CodePudding user response:

It is recommended to use software Spy4Win

CodePudding user response:

It is recommended to use clswindow, easy to use, specifically to handle such problems

CodePudding user response:

A kind of method is: use the API to find A handle to the window, and then obtain the text frame's handle, and then you can operate A window in the program of B text box, and A kind of method is: through the vb form Linktopic and LinkMode attribute to connect two forms, then the window is A window to receive B's instructions, do the related operations, about Linktopic and LinkMode connection form method is simple, is also called the DDE communication, you check on the Internet, is the equivalent of two forms of pipeline, true not line, I'll give you do, for example,

CodePudding user response:

reference 5 floor hsgzr1 reply:
A kind of method is: use the API to find A handle to the window, and then obtain the text frame's handle, and then you can operate A window in the program of B text box, and A kind of method is: through the vb form Linktopic and LinkMode attribute to connect two forms, then the window is A window to receive B's instructions, do the related operations, about Linktopic and LinkMode connection form method is simple, is also called the DDE communication, you check on the Internet, is the equivalent of two forms of pipeline, true not line, I'll give you do, for example,
this is the third party software, he is not so DDE, estimates that the building had already gone, and I wrote clswindow code, just as popularization of its usage,



The
refer to the original poster XDKDMLF response:


Write B program, how to implement the following functions?
1. Click on the "complete", the "application B" ABCD the contents of the text box, automatically fill in to "A software" ABCD text box, corresponding,
2. Click on "remove", "A software" ABCD text box capacity,

Each great god! The younger brother, online waiting for...


Clswindow usage is introduced: http://blog.csdn.net/sysdzw/article/details/9083313
Clswindow library download: https://download.csdn.net/download/sysdzw/9295969
Principle is based on the handle to get the window and then set the value, for the moment as the window of the host signal is at the top of the title, and assumes that the text box class named Edit, using clswindow code is as follows:
 Private Sub Command1_Click () 
Dim w1 As New clsWindow
Dim w2 As New clsWindow
Dim a, $b $, $c, d $

W1. GetWindowByTitle "A software"
W2. GetWindowByTitle "application B"
'get the right window w2 four values
A=w2. GetElementHwndByClassName (" Edit ", 1)
B=w2. GetElementHwndByClassName (" Edit ", 2)
C=w2. GetElementHwndByClassName (" Edit ", 3)
D=w2. GetElementHwndByClassName (" Edit ", 4)
'set four values to w1 window of four text box
W1. SetElementTextByClassName "Edit", a, 1
W1. SetElementTextByClassName "Edit", b, 2
W1. SetElementTextByClassName "Edit", c, 3
W1. SetElementTextByClassName "Edit", 4 d,
End Sub

CodePudding user response:

The code above is wrong, GetElementHwndByClassName modified to GetElementTextByClassName
See how method name, according to the name of the class get element's text content, about the various methods of explanation: https://wenku.baidu.com/view/c983a463d1f34693dbef3e33.html
 Private Sub Command1_Click () 
Dim w1 As New clsWindow
Dim w2 As New clsWindow
Dim a, $b $, $c, d $

W1. GetWindowByTitle "A software"
W2. GetWindowByTitle "application B"
'get the right window w2 four values
A=w2. GetElementTextByClassName (" Edit ", 1)
B=w2. GetElementTextByClassName (" Edit ", 2)
C=w2. GetElementTextByClassName (" Edit ", 3)
D=w2. GetElementTextByClassName (" Edit ", 4)
'set four values to w1 window of four text box
W1. SetElementTextByClassName "Edit", a, 1
W1. SetElementTextByClassName "Edit", b, 2
W1. SetElementTextByClassName "Edit", c, 3
W1. SetElementTextByClassName "Edit", 4 d,
End Sub

CodePudding user response:

I don't know where to go,
This thing is very simple,
Two kinds of methods, one kind is SendMessage, is a kind of simulated keyboard,
But actually do, there will be some unexpected pit,
This I have been doing special software, an implementation of function, a set of
Penguin, 5507350:5507350

CodePudding user response:

You can also use VB6 own SendKeys statement:

SendKeys statement


One or more key message is sent to the active window, like on the keyboard input,

Syntax

SendKeys string [wait]

SendKeys statement syntax has the following several named parameters:

Part of the description
String required, string expression, specify the message to be sent buttons,
Specified Wait Wait optional, [email protected] value, if False (the default), the process control in the button to return to the right after he sent out, if it is True, is the key message must be processed before control is returned to the process,


Description

Each key consists of one or more characters, said to specify A single keyboard characters, must press the character itself, for example, to show the letters A, you can use "A" as A string, to show more characters, must be behind the character directly with another character, for example, to A, B and C, available "ABC" as A string,

For SendKeys, plus sign (+), caret (^), percent sign (%), on line (~) and the parentheses () has a special significance, in order to specify the above any one character at a time, to put it in curly braces ({}), for example, to specify the plus sign, and expressed by {+}, square brackets ([]) does not have a special meaning for SendKeys, but they must be placed in curly braces, in other applications, square brackets have special significance, in the event of a dynamic data exchange (DDE), it may have important significance, in order to specify the braces characters, please use {{} and {}},

To those specified in the press button does not display the characters, such as the ENTER or TAB and that means the action rather than the character of the key, please use the following code:

The key code
BACKSPACE {BACKSPACE}, {BS} or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
The DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
The LEFT ARROW {LEFT}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • API
  • Related