visual-studio-2013


Click on external application menu items - visual basic


Hi I've been struggling with this for a while now, would really appreciate help. I am developing a windows form application in visual studio 2013. It will open an external application, find a specific window and then I need to click on the menu's. Everything works fine, I find the window & menus but it won't click on the menu. If you look at the pic below, I need to click on "Print transaction listing":
Imports System
Imports System.IO
Imports System.Windows.Forms.Menu
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop
Imports System.Timers
Module FileMenu
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Int32) As Boolean
Public Declare Function GetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Int32) As Int32
Public Declare Function GetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As Int32, ByVal nPos As Int32) As Int32
Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal winHandle As Int32, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32) As Int32
Public Const BM_GETCHECK = &HF0
Public Const BM_SETCHECK = &HF1
Public Const WM_LBUTTON_DOWN = &H201
Public Const WM_LBUTTON_UP = &H202
Public Const WM_COMMAND = &H111
<DllImport("user32.dll")> _
Public Function GetAsyncKeyState(ByVal vKey As Int32) As Short
End Function
Public Sub OpenMenu()
Dim ParentHWND As Int32
Dim sMenu As Int32
ParentHWND = FindWindow(vbNullString, "*******")
Threading.Thread.Sleep(1000)
If ParentHWND <> 0 Then
SetForegroundWindow(ParentHWND)
Threading.Thread.Sleep(1000)
Dim hMenu As Int32 = GetMenu(ParentHWND)
If hMenu <> 0 Then
SendMessage(hMenu , WM_COMMAND, 0, 0)
Threading.Thread.Sleep(1000)
sMenu = GetSubMenu(hMenu, 0)
Threading.Thread.Sleep(1000)
SendMessage(sMenu, WM_COMMAND, 0, 0)
Threading.Thread.Sleep(1000)
End If
End If
End Sub
End Module

Related Links

Access to App_Data path where ldf file is denied when checking in with Team Explorer
The platform toolset for Windows phone 8.1(v120_wp81) appears as not installed in vs2013 update 4
Project building but not debugging
Visual Studio Diagnostics session failed to start - What access rights are required to run Visual Studio 2013 Diagnostic
Environment specific Nuget feeds: how to deal with local solutions
Visual Studio asks me to reference a nonexistent assembly
visual studio 2013 intellisense for html tags
Visual Studio not checking files into TFS from Workspace Mapping to Two TFS Servers
VisualStudio 2013+.json file. How to use utf8 coding?
Simple Coded UI login test on remote server
NTVS Moved .d.ts files now VSTSC error not found with old file location
Exporting time series response data for VS2013 load tests
Can we change all the word at once in visual studio
Install package Mvc 6 Beta 2 on VS 2013 Fails via nuget
How to see solution explorer in vs 2013 community edition while MVC app is running
Unable to connect build service to TFS2013: Error TF30063 You are not authorized

Categories

HOME
spring
visual-studio-2015
dotnetrdf
cil
wildcard
agile
label
phonegap-cli
rebol
gspread
ng-admin
slim-3
dropbox
keystore
x11
tee
cpanel
data-analysis
postmessage
rebol2
arraylist
ms-access-2007
thumbnails
cython
excel-2010
searchbar
yosys
bus-error
helper
hana-studio
blackboard
pygooglechart
consumer
data-extraction
openpgp
passenger
socketpair
parse-android-sdk
poco-libraries
jquery-multidatespicker
nsexception
tripwire
amazon-clouddrive
nstouchbar
spring-data-hadoop
cgcontext
jexl
uicollectionviewlayout
unity3d-editor
gmt
festival
settimeout
android-navigationview
typhoon
cfeclipse
foxit
freetype2
gradle-eclipse
gemini
dac
fill
lemoon
application-loader
ubercart
google-earth-plugin
ejabberd-saas
orientation-changes
named-ranges
scala-2.11
node-inspector
ghostdoc
firebug-lite
author
eclipse-classpath
system.web
hamsterdb
modeshape
osx-snow-leopard
image-zoom
installshield-2009
ng-hide
qtgui
xslkey
bulbs
couchdb-lucene
entity-framework-ctp5
posting
msn
sitemappath
task-management
graniteds
usability-testing
soft-keyboard
odbc-sql-server-driver
virtualquery

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App