Home > Software engineering >  VB OSTMESSAGE background input problem...
VB OSTMESSAGE background input problem...

Time:09-28

Type of program is a Y, to achieve the background automatically the content of the input function,
First of all a Y is based on QT interface (QWidget class) is the entire program is only a form, control is no handle,

Using VB to write a piece of code, and test type input was successful,

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal HWND As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam) As Long As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal HWND) As Long As Long

Private Sub Command1_Click ()

Dim hw As Long
Hw=66908 'window handle

'- the following code type is OK,

'-- will handle to the window to activate
The SetForegroundWindow hw

'- click on the handle to the window coordinates 500 * 500
PostMessage hw, & amp; H201, 1, 500 * 65536 + 500
PostMessage hw, & amp; H202, 0, 500 * 65536 + 500

'- enter A letter A
PostMessage hw, & amp; H102, Asc (" A "), 0

End Sub


If you remove the target window is set to focus window that SetForegroundWindow, cannot the background input,

Have a great god know how to break through the limit, background input content?
More 0

CodePudding user response:

You can't,
The foreground application does not respond to the input, this is the common rules,
Unless it is a Trojan program will only be in the background when intercepted input,

CodePudding user response:

Repeating questions also useless,

CodePudding user response:

Post sometimes to low priority process, thread message would be to eat
First test sendmessage
If not, can have a try simply attxxxthreadwindow,,, that is the Shared thread input API
Not to consider such as hook, hook is too trouble and easy to intercept, so it's best to consider other ways first

CodePudding user response:

refer to the second floor Tiger_Zhao response:
repeating questions also useless,



The previous post: jiaxueq published in: 2014-12-15
This post: qq_15350647 published in: 2015-08-23

The content of the questions, basically can be said to be the "same", this is what people ah,
  •  Tags:  
  • API
  • Related