Home > Software engineering >  VB control another program, click simulation application any button menu bar, in the pop-up drop-dow
VB control another program, click simulation application any button menu bar, in the pop-up drop-dow

Time:09-29

I want to use the VB control VB editor, such as clicking on a menu bar file, and then in the pop-up drop-down menu, click open project





Handle to the menu bar I can catch, simulate the mouse click is always not achieve them,
The following program work in notepad, but for VB editor not achieve them, is there getmenu applicable condition?
Option Explicit

Private Declare Function GetMenu Lib "user32. DLL" (ByVal HWND) As Long As Long
Private Declare Function SendMessage Lib "user32. DLL" Alias "SendMessageA" (ByVal HWND As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32. DLL" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetMenuItemID Lib "user32. DLL" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetSubMenu Lib "user32. DLL" (ByVal hMenu As Long, ByVal nPos As Long) As Long

Private Const WM_COMMAND As Long=& amp; H111

Private Sub Command1_Click ()
Dim h1 As Long, h2 As Long, id As Long

H1=FindWindow (vbNullString, "no title - notepad") 'meter things this handle
The Debug. Print h1
The h2=GetMenu (h1)
H2=GetSubMenu (h2, 0) 'file "menu handle to change the back of the 0, can
'get a different menu handle
Id=GetMenuItemID (h2, 0) 'submenu "new" the id of the
SendMessage h1, WM_COMMAND, id, ByVal 0 & amp;

End Sub
Search more heterogeneous

CodePudding user response:

Window handle,
Take the window coordinates,
Move the mouse to the coordinates,
Simulation by pressing the left mouse button,

CodePudding user response:

Use the
http://www.autohotkey.com
Or
Wizard button

CodePudding user response:

Use the command can do good:
A, open the project
 "C: \ Program Files \ Microsoft Visual Studio \ VB98 \ vb6 exe" "D: \ VB \ Project1. VBP" 

Second, direct compilation does not display the IDE
 "C: \ Program Files \ Microsoft Visual Studio \ VB98 \ vb6 exe" "D: \ VB \ Project1. VBP"/make 

CodePudding user response:

reference 1st floor vansoft response:
window handle,
Take the window coordinates,
Move the mouse to the coordinates,
Simulation by pressing the left mouse button,


Menu bar buttons handle I can catch, but click on the handle to the drop-down menu after won't catch

CodePudding user response:

refer to the second floor zhao4zhong1 response:
using
http://www.autohotkey.com
Or
Wizard button



What is that you, thank you!

CodePudding user response:

reference Tiger_Zhao reply: 3/f
use command can do good:
A, open the project
 "C: \ Program Files \ Microsoft Visual Studio \ VB98 \ vb6 exe" "D: \ VB \ Project1. VBP" 

Second, direct compilation does not display the IDE
 "C: \ Program Files \ Microsoft Visual Studio \ VB98 \ vb6 exe" "D: \ VB \ Project1. VBP"/make 



I will open, I'm going to control

CodePudding user response:

Control do you use?
Every time the same programming what's the point?

CodePudding user response:

Junshengxingyun
reference 4 floor response:
Quote: refer to 1st floor vansoft response:

Window handle,
Take the window coordinates,
Move the mouse to the coordinates,
Simulation by pressing the left mouse button,


Menu bar buttons handle I can catch, but click on the handle to the drop-down menu after won't catch


Do not need to handle to the menu, it is need the coordinates of the menu, using API simulation by pressing the left mouse button,

CodePudding user response:

This menu in front of each icon, sometimes is not the original sense of the menu

CodePudding user response:

Name: the name of the class: MsoCommandBar, toolbar menu bar
This menu is point out after this toolbar, menu bar is not ordinary way the

CodePudding user response:

Generally this can use VBA plug-in method to control, not only can add menu, read the menu, click, and will do, also can be used for processing, click on the way to the front desk mouse clicks, also can click the background simulation, can see menu there are a few lines, and how much each row height, horizontal lines to take up much space, so as to calculate the line each menu in the longitudinal relative coordinates, and then click, still have a kind of method could be a MSAA way, that is the blind point of the WINDOWS screen can read most of the text, in that way, and then click techniques have been used for each object is general,
  •  Tags:  
  • API
  • Related